public bool InitCATIAPart() { try { oPartDoc = (MECMOD.PartDocument)CATIA.ActiveDocument; oPart = oPartDoc.Part; oBodies = oPart.Bodies; oBody = oPart.MainBody; oHBodies = oPart.HybridBodies; oSF = (ShapeFactory)oPart.ShapeFactory; oHSF = (HybridShapeFactory)oPart.HybridShapeFactory; } catch { } return(true); }
public bool InitCATIAPart(bool bNewPart, string strPart) { if (bNewPart) { //初始化 docCATIA = CATIA.Documents; oPartDoc = (MECMOD.PartDocument)docCATIA.Add("Part"); } else { if (strPart.Trim() == "") { oPartDoc = (MECMOD.PartDocument)CATIA.ActiveDocument; if (oPartDoc == null) { docCATIA = CATIA.Documents; oPartDoc = (MECMOD.PartDocument)docCATIA.Add("Part"); } } else { if (System.IO.File.Exists(strPart)) //有文件 { oPartDoc = (MECMOD.PartDocument)CATIA.Documents.Open(strPart); } else { return(false); } } } oPart = oPartDoc.Part; oBodies = oPart.Bodies; oBody = oPart.MainBody; oHBodies = oPart.HybridBodies; oSF = (ShapeFactory)oPart.ShapeFactory; oHSF = (HybridShapeFactory)oPart.HybridShapeFactory; return(true); }