private void GetSubPrd(ProductStructureTypeLib.Product Prd) { string PrtNum = Prd.get_PartNumber(); INFITF.Document Doc = (INFITF.Document)Prd.ReferenceProduct.Parent; string FullPath = Doc.FullName; SPATypeLib.SPAWorkbench SPAWB; SPAWB = (SPATypeLib.SPAWorkbench)Doc.GetWorkbench("SPAWorkbench"); SPATypeLib.Measurable Mea = SPAWB.GetMeasurable((INFITF.Reference)Prd); double Vol; try { Vol = Mea.Volume; } catch { Vol = 0; } textBox1.Text += Level.ToString() + "." + PrtNum + "." + FullPath + "\r\n"; for (int i = 1; i <= Prd.Products.Count; i++) { ProductStructureTypeLib.Product tPrd = Prd.Products.Item(i); Level++; GetSubPrd(tPrd); Level--; } }
public void SetRobotFixMechanism(Form FM, INFITF.Document document, Mechanism mechanism) { Selection Uselect = GetInitTargetProduct(FM, document, "请选择固定的对象!"); if (Uselect == null) { return; } mechanism.FixedPart = (Product)Uselect.Item(1).Value; Uselect = GetInitTargetProduct(FM, document, "请选择固联的对象!", true); if (Uselect == null) { return; } try { Reference reference = Uselect.Item(1).Reference; Reference reference1 = Uselect.Item(2).Reference; AnyObject[] RefenceObject = new AnyObject[] { reference, reference1 }; Joint joint = mechanism.AddJoint("CATKinRigidJoint", RefenceObject); mechanism.Update(); } catch (Exception) { throw; } }
/// <summary> /// Delmia 在非仿真示教模式下使用 /// </summary> /// <param name="FM">当前窗口</param> /// <param name="DelmiaDocument">DelmiaDocument</param> /// <returns></returns> public Selection GetInitTargetProduct(Form FM, INFITF.Document DelmiaDocument, string Msg = "请选择初始化对象", bool MultSelect = false) { FM.WindowState = FormWindowState.Minimized; INFITF.Document PPRP = DelmiaDocument; Selection USelect = null; if (PPRP == null) { return(null); } USelect = PPRP.Selection; USelect.Clear(); string Result; if (MultSelect) { Result = USelect.SelectElement3(DataType.InputObjectType(9), Msg, true, CATMultiSelectionMode.CATMultiSelTriggWhenUserValidatesSelection, false); } else { Result = USelect.SelectElement2(DataType.InputObjectType(9), Msg, true); } if (Result == "Cancel") { return(null); } if (USelect.Count < 1) { MessageBox.Show("请先选择对象后再点此命令!"); return(null); } return(USelect); }
public void ConnectToDelmia() { DelmiaInstance = (INFITF.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("DELMIA.Application"); actualDocument = DelmiaInstance.ActiveDocument; Selection sel = actualDocument.Selection; processDoc = (PPRDocument)actualDocument.GetItem("PPRDocument"); resources = processDoc.Resources; }
// sets CATIA active document public bool setActiveDocument() { if (Program.ENGAGE_CATIA_MODE) { try { activeDoc = catia.ActiveDocument; } catch (COMException ex) { Console.WriteLine("Could not obtain the CATIA active document!" + " Exception: " + ex.ToString()); MessageBox.Show("Could not obtain a CATIA active document. Please open one.", "Oops! No open document!", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); } return(false); }