Message Boards Message Boards

Export 3D models from SystemModeler or Mathematica

Posted 2 years ago

Dear Colleagues, I have set up a workflow with the following steps.

  1. Algorithmically generate a multibody Modelica model with Mathematica;
  2. "Fine-tune” and debug the Modelica model in System Modeler;
  3. Simulate the model in System Modeler to check its sanity.

I have a requirement to export 3D models of the multibody at each time step of the simulation. The file formats are multitude; here are several examples, STL, IGES, LWO, (Lightwave Object), STEP203, STEP214CD. It would be great if the exported file preserved the hierarchy and names of the objects in the Modelica file. For example, I don’t think STL stores any information about the objects; it just saves points and facets definitions. I would have to check the others.

To summarize, I need to export in the 3D model used to generate the screenshots in the images posted below.

I haven't been able to find a solution on my own and I have decided to ask the community while I wait for Tech Support.

Thank you,

BU Deployment screenshots from SystemModeler

POSTED BY: Bogdan Udrea
4 Replies

The Tech Support request has not reached us yet at Wolfram MathCore, but we'll take a shot to reply here. We have some very experimental and undocumented support for the reproduction of 3D graphics produced in System Modeler simulation results in Mathematica. The corresponding Graphics3D objects at time t are produced with sim["Graphics3D", t], with sim being the SystemModelSimulationData object. For instance: enter image description here If this works for your model, then you could then export these objects. But from the phrasing of your question you seem to want to export each multibody object separately in a directory structure at each time step. In that case, the call above may still be helpful. You can selectively turn off the animation of all but one of the bodies and request the model's "Graphics3D" so that you can get one body at a time as a Graphics3D, and proceed to do this with each individual body: enter image description here Then there is the possibility that the "Graphics3D" property does not work for your model, in which case, you may have to extract by hand the simulation results for the positions and alignments of the individual objects, generate Graphics3D objects from them, and them exporting them independently as you choose to.

POSTED BY: Sergio Vargas

In the past, we have occasionally resorted to DiscretizeGraphics or BoundaryDiscretizeGraphics to produce a region from a Graphics3D, that can then be exported. But, as you can see in the possible issues sections of their documentation pages, they don't have support for conversion with multiple volume primitives. I think your best chance may be indicating in your tech support request that you are now interested in this kind of conversion, so that you are redirected to the team in Graphics3D, which may be able to help you.

POSTED BY: Sergio Vargas
Posted 2 years ago

Thank you Sergio for the solution. I'll give it a try ASAP and post an update. The requirement is to export the full models, that you have shown in the result of the first cell, to a 3D CAD file that preserves the naming and hierarchy of the objects. If I cannot find a way to export the full model I will apply the workaround that you posted in the second cell.

Just in case, my tech support ticket ID is CASE:4953703

Best,

Bogdan

POSTED BY: Bogdan Udrea
Posted 2 years ago

I confirm that I can generate Graphics3D objects with the first option.

sim = SystemModelSimulate[ "Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum"] g3d = Table[sim["Graphics3D", t], {t, 0, 3, 1}]

However, I am stuck because I cannot export the Graphics3D objects. I have tried

dName = NotebookDirectory[]; Export[StringJoin[dName, "t1.lwo"], g3d[[1]]]

and got an error.

Graphics3D contains no data that can be exported to the LWO format.

I also tried 3ds, dxf, and dae and got the same error for the respective format.

After reading posts on various forums I have concluded that the Export[] does not support the Graphics3D object that comes out from the simulation. It seems that the problem is with the Translate part of the Graphics3D object. Here are some details of the StackTrace of the error.

Export["C:\\t1.lwo", Graphics3D[{Translate[ GeometricTransformation[{RGBColor[0., 0.494949494949495, 1.], Specularity[6., 40], ...

So is there a way to convert the Graphics3D object to something exportable? I have tried the solution here but it did not work.

Thank you,

B

POSTED BY: Bogdan Udrea
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract