0 Replies Latest reply on May 9, 2016 7:54 AM by Christian Löwenbrück

    How to built a widening with API; InsertSheetMetalLoftedBend2

    Christian Löwenbrück

      Hi I'm Christian and I try to make a Makro in C# for a widening.

       

      my code so far:

       

      IModelDoc2 modDoc = (IModelDoc2)iSwApp.NewDocument(partTemplate, (int)swDwgPaperSizes_e.swDwgPaperA2size, 0.0, 0.0);

                     
                      modDoc.Extension.SaveAs("Test.sldprt", 0, 1, null, 0, 0);
                      //Insert Sketch
                      modDoc.InsertSketch2(true);              
                      modDoc.SketchManager.CreateArc(0, 0, 0, 0, iD/1000/2 , 0, Math.Sin(355 * Math.PI / 180) * iD/2 / 1000, (-iD / 2 / 1000 + Math.Cos(355* Math.PI / 180) * iD / 2) / 1000, 0, -1);
                    
                      // second Sketch on a Plane
                      modDoc.InsertSketch2(false);
                      modDoc.ClearSelection2(true);
                      modDoc.Extension.SelectByID2("Ebene vorne", "PLANE", 0, 0, 0, false, 0, null, 0);
                      modDoc.FeatureManager.InsertRefPlane(8, L/1000, 0, 0, 0, 0);
                      modDoc.ClearSelection2(true);
                      modDoc.Extension.SelectByID2("Ebene1", "PLANE", 0, 0, 0, false, 0, null, 0);
                      modDoc.InsertSketch2(true);
                      modDoc.SketchManager.CreateArc(0, 0, 0, 0, aD/2/1000, 0, Math.Sin(355 * Math.PI / 180) * aD / 2 / 1000, (-aD / 2 / 1000 + Math.Cos(355 * Math.PI / 180) * aD / 2) / 1000, 0, -1);              

                      modDoc.InsertSketch2(false);
                      modDoc.ClearSelection2(true);            
                      modDoc.Extension.SelectByID2("Skizze1", "SKETCH", 0, 0, 0, false, 1, null, 0);              
                      modDoc.Extension.SelectByID2("Skizze2", "SKETCH", 0, 0, 0, true, 1, null, 0);
                      //create sheet feature
                      modDoc.FeatureManager.InsertSheetMetalLoftedBend2(1, t/1000, true, 0 , false, 0, 0, 0, 0, 0);

       

      the code does everything I want exept creating the Feature. Did i made a mistake?

      In the end it should look like the attached picture