// create lines private void button1_Click(object sender, EventArgs e) { try { prtDoc = (PartDocument)catia.ActiveDocument; Part prt = prtDoc.Part; hbdy = prt.HybridBodies.Item(1); HybridShapeFactory hfac = (HybridShapeFactory)prt.HybridShapeFactory; //SelGS = (HybridBody)Sel.Item(1).Value; //INFITF.AnyObject aaa = Pts[0]; for (int i = 0; i <= (Pts.Count - 1); i++) { for (int j = i + 1; j < Pts.Count; j++) { HybridShapeTypeLib.Point pt1 = (HybridShapeTypeLib.Point)Pts.ElementAt(i); HybridShapeTypeLib.Point pt2 = (HybridShapeTypeLib.Point)Pts.ElementAt(j); INFITF.Reference ref1 = prt.CreateReferenceFromGeometry(pt1); INFITF.Reference ref2 = prt.CreateReferenceFromGeometry(pt2); HybridShapeTypeLib.Line lin = hfac.AddNewLinePtPt(ref1, ref2); hbdy.AppendHybridShape(lin); } } prt.Update(); } catch (Exception) { MessageBox.Show("선택된 정보가 없습니다."); return; } }
//create3Dline-------------------------------------------- private void button5_Click(object sender, EventArgs e) { // object[] HpCrd1 = new object[3]; // object[] HpCrd2 = new object[3]; try { sel = catia.ActiveDocument.Selection; HyShpPtCoord1 = (HybridShapeTypeLib.Point)sel.FindObject("CATIAHybridShapePoint"); //sel = catia.ActiveDocument.Selection; HyShpPtCoord2 = (HybridShapeTypeLib.Point)sel.FindObject("CATIAHybridShapePoint"); //HyShpPtCoord1.GetCoordinates(HpCrd1); //HyShpPtCoord1.GetCoordinates(HpCrd2); PartDocument prtDoc = (PartDocument)catia.ActiveDocument; Part prt = prtDoc.Part; HybridBody hbdy = prt.HybridBodies.Item(1); HybridShapeFactory hfac = (HybridShapeFactory)prt.HybridShapeFactory; INFITF.Reference ref1 = prt.CreateReferenceFromGeometry(HyShpPtCoord1); INFITF.Reference ref2 = prt.CreateReferenceFromGeometry(HyShpPtCoord2); HybridShapeTypeLib.Line lin = hfac.AddNewLinePtPt(ref1, ref2); hbdy.AppendHybridShape(lin); prt.Update(); } catch (Exception) { MessageBox.Show("선택된 정보가 없습니다."); return; } }