创建第二个任务:将部件转换为区域
第二个任务从第一个任务中提取导入的部件,然后为其创建区域和边界。每个新任务都有自己单独的 Java 类。
-
将一个新类添加到助手程序包并命名为 Task02CreateRegionFromPart。
-
将以下代码复制到新类中:
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); } } } }
- 保存文件。