Skip to content
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

ZMT zurich med tech

  1. Home
  2. Sim4Life
  3. CAD Modeling
  4. How to extrude along a line with a triangle cross-section

How to extrude along a line with a triangle cross-section

Scheduled Pinned Locked Moved CAD Modeling
1 Posts 1 Posters 283 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • brynB Offline
    brynB Offline
    bryn
    ZMT
    wrote on last edited by bryn
    #1

    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()
    

    Youtube Video

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Search