Creating the Second Task: Converting the Parts to Regions
The second task takes the imported part from the first task and creates a region and boundaries for it. Every new task has its own separate Java class.
-
Add a new class to the Assistant package and name it
Task02CreateRegionFromPart.
-
Copy the following code into the new class:
package Assistant; import java.util.ArrayList; import java.util.Collection; import star.assistant.Task; import star.assistant.annotation.StarAssistantTask; import star.assistant.ui.FunctionTaskController; import star.common.GeometryPart; import star.meshing.CadPart; @StarAssistantTask(display = "Create Region from Part", contentPath = "XHTML/02_CreateRegionFromPart.xhtml", controller = Task02CreateRegionFromPart.RegionFromPartTaskController.class) public class Task02CreateRegionFromPart extends Task { public Task02CreateRegionFromPart() { } public class RegionFromPartTaskController extends FunctionTaskController { public void createRegion() { CadPart cadPart_1 = lookupObject(CadPart.class); if (cadPart_1 != null) { Collection<GeometryPart> list = new ArrayList<GeometryPart>(); list.add(cadPart_1); getSimulation().getRegionManager().newRegionsFromParts(list, "OneRegionPerPart", null, "OneBoundaryPerPartSurface", null, true); } } } }
- Save the file.