Skip to content

CAD Modeling

Working with CAD models

57 Topics 193 Posts
  • CAD Projection tool

    7
    1 Votes
    7 Posts
    507 Views
    L

    I see- thank you!

  • how to draw exponential line

    2
    1 Votes
    2 Posts
    305 Views
    SylvainS

    Here is a piece of code that creates a coil wrapped onto a torus, using lines defined from 3D parametric equations.

    It makes use of Law(), Curve(), CreateWireBody() and SweepAlongPath() from the XCoreModeling package.

    import numpy as np import s4l_v1.document as document import s4l_v1.model as model import XCoreModeling def create_toroidal_coil(R, r, m, n=1, i=1, name="Toroid"): """ Create a spline model object with a spiral shape. The shape is defined from a 3D parametric equation. """ # equation b = 2. * np.pi * float(i) / float(m) x_component = "({R}-{r}*cos({b} + {n}*t)) * cos(t)".format(R=str(R), r=str(r), b=str(b), n=str(n)) y_component = "({R}-{r}*cos({b} + {n}*t)) * sin(t)".format(R=str(R), r=str(r), b=str(b), n=str(n)) z_component = "{r}*sin({b}+{n}*t)".format(r=str(r), b=str(b), n=str(n)) path = XCoreModeling.Law("vec({}, {}, {})".format(x_component, y_component, z_component)) curve = XCoreModeling.Curve(path, 0.0, 2.*np.pi) # Create a spline wire body to visualize wire = XCoreModeling.CreateWireBody( curve ) wire.Name = name torus_centerline = model.CreateCircle(model.Vec3(0,0,0), model.Vec3(0,0,1), 10) torus_centerline.Name = 'Centerline' torus = model.CreateSolidCylinder(model.Vec3(10,0,0),model.Vec3(10,0,0), 3) torus.ApplyTransform(model.Rotation(model.Vec3(1,0,0), np.pi/2)) XCoreModeling.SweepAlongPath(torus, torus_centerline, make_solid=True, cut_off_end=True) # Theoretical self-inductance: area = np.pi * (r*1e-3)**2 L_theoretical = 4.0e-7 * np.pi * n * n * area/ (2.0* np.pi *R * 1e-3) print(L_theoretical * 40) return wire, torus if __name__=="__main__": wire, torus = create_toroidal_coil(10,3,1, n=100)
  • Import a 3D geometry to sim4life

    2
    0 Votes
    2 Posts
    717 Views
    brynB

    when you write inventor, do you mean "Autodesk Inventor" or "Open Inventor"?

    I guess the file is some kind of assembly, which is exported as a single STL file. STL does not support multi-part models, so you would need to export each part a separate STL file (or other format supported by Sim4Life), or you export it to a file format that supports multiple parts (ACIS .sab/.sat, STEP .step, ... VTK .vtm (multiblock)).

    STL also only supports triangle surface representations, so if you had a NURBS CAD file, you loose the that by exporting to STL.

    Searching for the topic I found this information for Autodesk Inventor to export as a multibody sab file:
    https://knowledge.autodesk.com/support/inventor/troubleshooting/caas/sfdcarticles/sfdcarticles/How-to-convert-Inventor-Assembly-file-to-a-multi-body-part-file.html

    btw. if the points in different parts aren't coincident, you may be lucky with your single STL file: try Modeling -> Mesh Tools -> Separate Meshes. This could separate disconnected parts.

  • Ellipsoid

    2
    0 Votes
    2 Posts
    291 Views
    SylvainS

    Yes, there is. Create a sphere, then use the "Move" tool and look for the "Stretch" button on the right side of the 3D window.
    You can then stretch any of the 3 principal axis of the sphere.

  • Medical Image Segmentation

    3
    0 Votes
    3 Posts
    583 Views
    brynB

    To comment on this case. The surface extraction in iSEG is inferior to the surface extraction in Sim4Life. So you probably want to export the labelfield as voxels (e.g. in Nifty, Nrrd or Metaheader format - the VTK format does not preserve the transformations correctly). You can also extract the tissue list as txt file in iSEG in order to set the tissue names e.g. via a python script in Sim4Life.

  • 'Electroceuticals - Implantable Stimulator' CAD missing (S4L Light)

    4
    0 Votes
    4 Posts
    474 Views
    L

    @Jexyll_S Oh perhaps, thanks!

  • Export parts of ViP models as IGES

    3
    0 Votes
    3 Posts
    1k Views
    H

    Hi Micol and Frodi,

    One free alternative is to use the shell provided with the Fitness Tracker tutorial. This is the skin shell of the model Billie. It is not license protected and can be exported to any one of the available export formats.

    Best,
    Habib

  • Sweep a cross-section geometry along a spline

    2
    0 Votes
    2 Posts
    564 Views
    SylvainS

    Hi, when sweeping an object along a path, the normal of the cross-section should in principle follow the path. This, however, does not prevent having self-intersections in locations where the curvature of the path is too large compared to the size of the cross-section.

    The best way to experiment (different geometries, different paths, etc...) is to use the Python API:

    import s4l_v1.model as model from s4l_v1.model import Vec3 import XCoreModeling spline1 = model.CreateSpline([Vec3(0,0,0), Vec3(50,0,0), Vec3(50,50,50)]) section = model.CreateCircle(Vec3(0,0,0), Vec3(1,0,0), 10) region1 = XCoreModeling.SweepAlongPath(section, spline1, make_solid=True)
  • Thicken the helix wire

    4
    0 Votes
    4 Posts
    424 Views
    L

    @PeterStijnman Thank you so much for your solution,I will try it.

  • Helix problem

    5
    0 Votes
    5 Posts
    430 Views
    SylvainS

    @LCL You are welcome! Enjoy the Helix tool and do not hesitate to post some screenshots on this forum if you create some nice looking helixes 🙂

  • Voxelling problem -posable model

    6
    2 Votes
    6 Posts
    609 Views
    S

    Those look llike ghost voxels (i.e. voxels produced by a bug in the voxeler). Look at the regularity of those voxels. If this is reproducible, can you please provide a project file with that model in it and report a bug case?

  • Boolean operation with Anatomical models

    5
    1 Votes
    5 Posts
    742 Views
    brynB

    just to comment on doing booleans with licensed models. this is completely possible, as Suchit says. Sometimes I think users get confused by the lock symbols shown in the model. These locks are not related to the license protection at all, they are there because the model is posable and modifying individual parts would break the posability.

    For you I would suggest to download the shell (surface enclosing the complete model) of DUKE and do the boolean operation with the shell only. For Duke you could use: https://itis.swiss/virtual-population/virtual-population/vip2/duke/duke-whole-body-shell-v2-0/

    Since the shell is not license protected you can modify it, save it as STL or whatever format and load it other software tools if needed (e.g. MATLAB). To make it a solid the easiest method is to import the STL file and check the box "Import as Solid".

    We are planning to restructure the downloads soon, and I want to add the shell surface by default to the zip file containing the full V3.x model, since it is often useful, e.g. to create uniform thickness offset surfaces (skin layers), and other operations.

  • CAD formats that can be imported in Sim4Life / SEMCAD X Matterhorn

    2
    0 Votes
    2 Posts
    728 Views
    brynB

    The list is actually quite a bit longer.

    For surface meshes is includes:

    VTK PLY OBJ OFF DAT (iSEG/ViP surface format)

    For image data it includes:

    PRJ (iSEG project files) NIFTY (NII, NII.GZ) DICOM MHA/MHD NRRD

    For unstructured meshes it includes:

    Exodus II VTU NASTRAN (partial support)
  • Importing polylines from text file

    Unsolved
    2
    0 Votes
    2 Posts
    392 Views
    brynB

    You would have to define the polylines in a supported file format, e.g. VTK.

    To create such a file from Python, you could do something like this:

    import vtk # define points x1,y1,z1, etc. # add the actual points points = vtk.vtkPoints() points.InsertNextPoint(x1,y1,z1) points.InsertNextPoint(x2,y2,z2) points.InsertNextPoint(x3,y3,z3) # define the lines lines = vtk.vtkCellArray() lines.InsertNextCell(3) # next line is composed of 3 vertices lines.InsertCellPoint(0) # vertex 1 lines.InsertCellPoint(1) # vertex 2 lines.InsertCellPoint(2) # vertex 3 # assemble as surface mesh mesh = vtk.vtkPolyData() mesh.SetPoints(points) mesh.SetLines(lines) # write to file, supported by Sim4Life, Paraview, etc. writer = vtk.vtkDataSetWriter() writer.SetInputData(mesh) writer.SetFileName(r"E:\temp\Foo.vtk") writer.Write()
  • Introducing the Image Modeling module: Image and LabelField

    1
    0 Votes
    1 Posts
    497 Views
    No one has replied
  • How can I export a mesh model as IGES

    4
    3 Votes
    4 Posts
    611 Views
    brynB

    @pcrespo By the way. Converting to Solid (using either method) only works well when
    a) the mesh resolution is not too high (else it will take forever and use huge amounts of memory)
    b) the surface mesh is manifold and has no self-intersections. these defects can be identified and often fixed using the Mesh Doctor ("Automatically Fix").

    0_1525763901226_d38bb2c1-efd5-4038-b84a-605be284dda1-image.png

    0_1525763910904_3d828313-84bb-4410-9be9-d584b6318823-image.png

  • Nearest point to a spline

    Solved
    2
    0 Votes
    2 Posts
    376 Views
    SylvainS

    got it:

    wire = GetWires(spline)[0] curve = wire.GetGeometry(transform_to_model_space=True) law = curve.GetLaw() t0 = curve.MinDistParameter(point_start)