Dalton Tan
Dalton Tan

Reputation: 485

Can't use custom 3D model for visualization

I'm using the Modelica.Mechanics.MultiBody.Visualizers.FixedShape to render custom 3D models. I tried using .dxf and .stl in ASCII format but none works. For .dxf I get no error but the model doesn't show up. For .stl I get an error saying there is no plugin for that file type.

Upvotes: 0

Views: 220

Answers (2)

Ben
Ben

Reputation: 105

This was probably broken when you attempted it but has been fixed in OMEdit 1.21+. The stl in this model did not animate in 1.20 but does in 1.21+:

model stlsFixed
  inner Modelica.Mechanics.MultiBody.World world annotation(    Placement(visible = true, transformation(origin = {-50, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Mechanics.MultiBody.Parts.BodyShape bodyShape(m = 10, r = {0.5, 0, 0}, r_CM = {0.25, 0, 0}, shapeType = "file://C:/absolute/path/to/stl.stl")  annotation(    Placement(visible = true, transformation(origin = {30, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Mechanics.MultiBody.Joints.FreeMotion freeMotion annotation(    Placement(visible = true, transformation(origin = {-10, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  connect(world.frame_b, freeMotion.frame_a) annotation(    Line(points = {{-40, 0}, {-20, 0}}));
  connect(freeMotion.frame_b, bodyShape.frame_a) annotation(    Line(points = {{0, 0}, {20, 0}}));
annotation(    Diagram(coordinateSystem(initialScale = 0.08)),    uses(Modelica(version = "4.0.0")));
end stlsFixed;

Upvotes: 0

Akhil Nandan
Akhil Nandan

Reputation: 348

enter image description here

Please see the highlighted portions in the above image. OpenModelica supports adding an external shape using the format shapeType=modelica://<Modelica-name>/<relative-path-file-name>. Preferably create a Resources folder in the same level under the library folder and add dxf files in them. The following animation shows the same. Hope this helps!

enter image description here

Upvotes: 0

Related Questions