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()
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login