Star-CCM+ Macro - Loop over just wall boundary conditions
I'm trying to loop over just the wall boundaries in my macro. I know I can use a Collection and getObjectsOf(ForceReport.class) to loop over just the force reports. But I think I'm missing something simple when it comes to automating this loop over getObjectsOf(WallBoundary.class).
I am not a Java programmer, so forgive me if this is a simple question. I boiled down the part I'm struggling with to the code below. As you can see I have it creating a collection of force reports then looping over those and just printing the name of the reports. It fails when trying to create the collection of wall boundaries. I'm running on: Red Hat Enterprise Linux Server release 6.8 And installed java version: java version "1.6.0_41" OpenJDK Runtime Environment (IcedTea6 1.13.13) (rhel-1.13.13.1.el6_8-x86_64) OpenJDK 64-Bit Server VM (build 23.41-b41, mixed mode) Code:
package macro; Here's the error I get: Code:
Playing macro testing.java Thank you for any help!! Jason |
Hello,
I got around this by creating an "if condition" : String compare = "Wall"; Collection<Boundary> MyBoundaries = region_0.getBoundaryManager().getBoundaries(); List<Boundary> MyFilteredBoundaries = new ArrayList(); for (Boundary WallTypeBoundaries : MyBoundaries) { if (WallTypeBoundaries.getBoundaryType().toString().c ontains(compare)) { MyFilteredBoundaries.add(WallTypeBoundaries); } } and then go on with your Macro, extracting / looping over MyFilteredBoundaries. |
First, I highly recommend to use an IDE like Netbeans. Makes it easier.
I don't know a way for not using an if condition, but you can use another way for your comparison, without using a String: for (Boundary currentBoundary: simulation_1.getRegionManager().getRegion("Region 1").getBoundaryManager().getBoundaries()) { if (currentBoundary.getBoundaryType() == simulation_1.get(ConditionTypeManager.class).get(W allBoundary.class)) {}simulation_1.println("Found Wall: " + currentBoundary.getPresentationName());} Quote:
|
You can trade the line:
if (currentBoundary.getBoundaryType() == simulation_1.get(ConditionTypeManager.class).get(W allBoundary.class)) { for: if (currentBoundary.getBoundaryType() instanceof WallBoundary) { |
Quote:
|
Thanks!
I apologize for not getting back sooner. All of these options work, so just wanted to thank everyone for the help! I've added this to my little macro library for future use.
Thanks again, Jason |
All times are GMT -4. The time now is 12:03. |