How to extrude along a line with a triangle cross-section
-
While this may not be directly useful for most, it still might be interesting to show the capabilities of the Sim4Life modeler, and how to use the Python API for complex modeling.
I wanted to create a triangle mesh representing the ribs but with a very low number of triangles. The Remesh tool has difficulty making the surface very coarse: typically volume loss occurs and triangles start self-intersecting. So instead I opted to draw a single triangle and extrude it along the center lines of the ribs.
To draw the triangle I used the "Sketch -> Lines" tool and drew three lines in a closed loop. Then I used the "Wire Tools -> Cover Loops" to cover the loop and create a sheet. Finally, I converted it to a triangle mesh ("Mesh Tools -> To Mesh").
Then using a simple python script I extruded the triangle along each center line:
import XCoreMath import XCoreModeling Vec3 = XCoreMath.Vec3 sel = XCoreModeling.GetActiveModel().SelectedEntities sel = XCoreModeling.CollectEntities(sel) trimesh = [e for e in sel if isinstance(e, XCoreModeling.TriangleMesh)][0] wires = [e for e in sel if isinstance(e, XCoreModeling.Body)] prisms = [] for w in wires: len = XCoreModeling.MeasureLength([w]) num_layers = int(len / 10.0) wire = XCoreModeling.GetWires(w)[0] c = wire.GetGeometry(True) trimesh.Transform = XCoreModeling.Transform() T = XCoreMath.Translation(c.Eval(0.0)) R = XCoreMath.Rotation(Vec3(0.0, 0.0, 1.0), c.EvalTangent(0.0)) trimesh.ApplyTransform(T * R) meshes = XCoreModeling.ExtrudeMesh([trimesh], w, npoints=num_layers) for p in meshes: s = XCoreModeling.ExtractUnstructuredMeshSurface(p) prisms.append(s) p.Delete()