diff --git a/Modelica/Mechanics/MultiBody/Visualizers/Advanced/package.order b/Modelica/Mechanics/MultiBody/Visualizers/Advanced/package.order index 1fc23e387d..5d5d5ec8bb 100644 --- a/Modelica/Mechanics/MultiBody/Visualizers/Advanced/package.order +++ b/Modelica/Mechanics/MultiBody/Visualizers/Advanced/package.order @@ -5,3 +5,4 @@ Shape Surface PipeWithScalarField SurfaceCharacteristics +selectMeshFile diff --git a/Modelica/Mechanics/MultiBody/Visualizers/Advanced/selectMeshFile.mo b/Modelica/Mechanics/MultiBody/Visualizers/Advanced/selectMeshFile.mo new file mode 100644 index 0000000000..712576cb48 --- /dev/null +++ b/Modelica/Mechanics/MultiBody/Visualizers/Advanced/selectMeshFile.mo @@ -0,0 +1,15 @@ +within Modelica.Mechanics.MultiBody.Visualizers.Advanced; +function selectMeshFile + "Return the file name of a mesh with an extension that is supported by the tool" + input String fileNameBase "Base part of a mesh file name (e.g. modelica://ModelicaTest/Resources/Data/Meshes/GlassHurricane_yUP)"; + input String extensions[:]={"glb","stl"} "Formats provided for the mesh"; + output String fileName "File name of the mesh, using the first extension supported by the tool"; +algorithm + for ext in extensions loop + if ModelicaServices.Animation.supportsMeshFormat(ext) then + fileName := fileNameBase + "." + ext; + return; + end if; + end for; + Modelica.Utilities.Streams.print("... Mesh \"" + fileNameBase + "\" is not visualized because\nthe tool does not support one of the provided mesh formats"); +end selectMeshFile; diff --git a/ModelicaServices/package.mo b/ModelicaServices/package.mo index 20dedbc736..0e1483a6e8 100644 --- a/ModelicaServices/package.mo +++ b/ModelicaServices/package.mo @@ -146,7 +146,7 @@ The interface of this model is defined at model Vector "Animation of a moveable vector-quantity (the length is not fixed in meters)" extends Modelica.Utilities.Internal.PartialModelicaServices.Animation.PartialVector; - annotation (Documentation(info=" + annotation (Documentation(info="
The interface of this model is documented at
Modelica.Mechanics.MultiBody.Visualizers.Advanced.Vector.
@@ -156,6 +156,12 @@ The interface of this model is defined at
"));
end Vector;
+
+ function supportsMeshFormat "Return true, if the provided mesh format is supported"
+ input String format "Extension of the mesh file name that shall be used, e.g., \"stl\", \"dxf\", \"glb\"";
+ output Boolean result = false "Return true, if the format is supported by the tool";
+ end supportsMeshFormat;
+
end Animation;
package ExternalReferences "Library of functions to access external resources"
diff --git a/ModelicaTest/MultiBody.mo b/ModelicaTest/MultiBody.mo
index 405579669d..3fd42e35c3 100644
--- a/ModelicaTest/MultiBody.mo
+++ b/ModelicaTest/MultiBody.mo
@@ -10587,6 +10587,27 @@ This test model was proposed in ticket