Best way to select all region objects in java
Dear Experts,
Sorry to bother another pretty dump questions... I'm writing a simple java script to automate a series of "constrained plane" for the geometry in order to calculate the mass flow for each channels. it works well when the model only have one region. now the geometry getting more complex and the channels now split into different regions. and the code won't work well. I can still make it work by manually changing the name in the code to match the region I'm working on. but I'm looking for more generalize solution. is there any clean way to do something like "select-all-regions"? with simple example would be really really appreciated... since I'm still new to CCM... Many thanks for the great help. Regards, -Showerlin |
u can use collector concept.
|
Hi
You can use a bit of code like Simulation sim = getActiveSimulation(); Collection<Region> allReg = sim.getRegionManager().getRegions(); Units units_0 = ((Units) sim.getUnitsManager().getObject("m")); ConstrainedPlaneSection constrainedPlaneSection_0 = (ConstrainedPlaneSection) sim.getPartManager().createConstrainedPlaneImplici tPart(new NeoObjectVector(new Object[] {}), new DoubleVector(new double[] {}), units_0); constrainedPlaneSection_0.getInputParts().setObjec ts(allReg); You need to be careful if you have deleted regions in your model. If so then you need to make an empty entity and fill it with the appropriate regions eg. ArrayList<Region> allRegList= new ArrayList<Region>(); for(Region r: sim.getRegionManager().getRegions()){ if(!r.getPresentationName().contains("dele")){ allRegList.add(r); } } constrainedPlaneSection_0.getInputParts().setObjec ts(allRegList); |
All times are GMT -4. The time now is 03:47. |