ufun方法:UF_MODL_intersect_bodies_with_retained_options
直接上源码:
public static void Main(string[] args)
{
try
{
theSession = Session.GetSession();
displayPart = theSession.Parts.Display;
theUFSession = UFSession.GetUFSession();
workPart = theSession.Parts.Work;
Body bodyblock = (Body)workPart.Bodies.FindObject("BLOCK(1)");
Body bodyCylinder = (Body)workPart.Bodies.FindObject("CYLINDER(2)");
Tag tag = Tag.Null;
theUFSession = UFSession.GetUFSession();
//获得两个实体的相交体,保留原始目标实体
theUFSession.Modl.IntersectBodiesWithRetainedOptions(bodyblock.Tag, bodyCylinder.Tag, true, true, out tag);
string str = ((NXOpen.NXObject)(NXObjectManager.Get(tag))).JournalIdentifier;
Body targetBody = (Body)workPart.Bodies.FindObject(str);
Auto_Init.BodyInit init = new Auto_Init.BodyInit(targetBody);
BodyModel model = init.ProcBody();
}
catch (NXOpen.NXException ex)
{
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}
}