Java Examples
The following examples show several uses of responses to obtain specific information from query diagnostics.
As prerequisites, this section contains the required import paths and basic java code.
These examples are summarized below:
- Integer — Accessing a vertex ID
- Integer Vector —Accessing the number of faces that belong to a boundary
- Double — Accessing the total length of selected edges
- Double Vector — Accessing the X, Y, and Z coordinates of a vertex
- Client-Server Objects — Access the query units, query coordinate system, and the part surface or boundaries to which a face belongs.
Import Paths
To access and use query responses, add the following import parts to your macro:
import star.base.neo.*;
import star.common.*;
import star.meshing.*;
Prerequisites
To use these examples, add the following java to your macro:
Simulation simulation_0 = getActiveSimulation();
PartSurfaceMeshWidget partSurfaceMeshWidget_0 =
simulation_0.get(PartSurfaceMeshWidget.class);
SurfaceMeshWidgetQueryController
surfaceMeshWidgetQueryController_0 =
partSurfaceMeshWidget_0.getControllers()
.getController(
SurfaceMeshWidgetQueryController.class
);
Int Example
The following example illustrates the use of integers to access the ID of a selected vertex:
NeoProperty response =
surfaceMeshWidgetQueryController_0.queryVertexXYZ();
int vertId = response.getInt("VertexId");
simulation_0.println(
"Vertex ID: " + vertId
);
IntVector Example
The following example illustrates the use of integer vectors to access the number of selected faces that belong to a boundary:
NeoProperty response =
surfaceMeshWidgetQueryController_0
.queryFaceRegionBoundaryList();
IntVector faceCount =
response.getIntVector("SelectedBoundaryFaceCount");
simulation_0.println(
"Face count: " + faceCount.getComponent(0)
);
Double Example
The following example illustrates the use of doubles to access the total length of all selected edges:
NeoProperty response =
surfaceMeshWidgetQueryController_0.queryEdgeLength();
simulation_0.println(
"Total length: " + response.getDouble("TotalLength")
);
DoubleVector Example
The following example illustrates the use of double vectors to access the X, Y, and Z coordinates of the selected vertex:
NeoProperty response =
surfaceMeshWidgetQueryController_0.queryVertexXYZ();
DoubleVector labXYZ = response.getDoubleVector("LabXYZ");
simulation_0.println(
"Vertex Coordinates: " + labXYZ
);
simulation_0.println(
"Vertex X-Coordinate: " + labXYZ.toDoubleArray()[0]
);
ClientServerObject Examples
The following examples illustrate the use of client-server objects.
Units
This example accesses the preferred units for the query:
NeoProperty response =
surfaceMeshWidgetQueryController_0.queryVertexXYZ();
Units units =
response.<Units>getObject(
"LengthUnits",simulation_0.getObjectRegistry()
);
simulation_0.println(
"Units: " + units.getPresentationName()
);
Coordinate System
This example accesses the local coordinate system for the query:
NeoProperty response =
surfaceMeshWidgetQueryController_0.queryVertexXYZ();
CoordinateSystem csys =
response.<CoordinateSystem>getObject(
"LocalCoordinateSystem",simulation_0.getObjectRegistry()
);
simulation_0.println(
"Local CSys: " + csys.getPresentationName()
);
Part Surfaces or Boundaries
This example accesses the first part surface to which the selected faces belong:
NeoProperty response =
surfaceMeshWidgetQueryController_0.
queryFacePartSurfaceList();
Vector<PartSurface> partSurfaces =
response.<PartSurface>getObjectVector(
"SelectedPartSurfaces",simulation_0.getObjectRegistry()
);
simulation_0.println(
"First part surface: " + partSurfaces.get(0)
);
This example accesses the first boundary to which the selected faces belong:
NeoProperty response =
surfaceMeshWidgetQueryController_0
.queryFaceRegionBoundaryList();
Vector<Boundary> boundaries =
response.<Boundary>getObjectVector(
"SelectedBoundarySurfaces",
simulation_0.getObjectRegistry()
);
simulation_0.println(
"First boundary: " + boundaries.get(0)
);