Dear Colleagues,
I have set up a workflow with the following steps.
Algorithmically generate a multibody Modelica model with Mathematica;
"Fine-tune” and debug the Modelica model in System Modeler;
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.
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:
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:
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
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.
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.