Exemplo n.º 1
0
        public void MakeTriangles()
        {
            swSketchManager = modDoc.SketchManager;
            var i = 0;

            foreach (var verts in stlSurfaceVertices)
            {
                swSketchManager.Insert3DSketch(true);
                var p1 = verts[0];
                var p2 = verts[1];
                var p3 = verts[2];
                stlSurfaces[i].l1 = swSketchManager.CreateLine((double)p1.x, (double)p1.y, (double)p1.z, (double)p2.x, (double)p2.y, (double)p2.z) as SketchLine;
                stlSurfaces[i].l2 = swSketchManager.CreateLine((double)p2.x, (double)p2.y, (double)p2.z, (double)p3.x, (double)p3.y, (double)p3.z) as SketchLine;
                stlSurfaces[i].l3 = swSketchManager.CreateLine((double)p3.x, (double)p3.y, (double)p3.z, (double)p1.x, (double)p1.y, (double)p1.z) as SketchLine;
                var plane = modDoc.InsertPlanarRefSurface();
                var name  = "Surface-Plane" + (i + 1).ToString();
                modDoc.Extension.SelectByID(name, "SURFACEBODY", 0, 0, 0, false, 0, null);
                Body2 body = modDoc.ISelectionManager.GetSelectedObject(1);
                body.SetMaterialProperty("Default", "solidworks materials.sldmat", "Pure Gold");
                stlSurfaces[i].b = body;
                i++;
            }
            modDoc.ViewZoomtofit2();
            //swSketchManager.InsertSketch(true);
            Finish();
        }