|
[Sponsors] |
September 2, 2014, 05:22 |
Macro to loop over derived parts
|
#1 |
New Member
Join Date: Sep 2014
Posts: 4
Rep Power: 12 |
Hi,
Does anyone know how to loop over a specific type of derived parts (e.g. plane sections, line probes, etc) using a Java macro? |
|
September 2, 2014, 06:38 |
|
#2 |
Member
kris
Join Date: May 2014
Posts: 73
Rep Power: 12 |
you could loop over all the parts and then use an if statement to check the class of each part. Use only the ones you want.
|
|
September 2, 2014, 09:04 |
|
#3 |
New Member
Join Date: Sep 2014
Posts: 4
Rep Power: 12 |
Thanks kguntur, this works fine.
For reference, here is my understanding of your suggestion: Code:
Simulation simulation_0 = getActiveSimulation(); Collection<Part> myParts = simulation_0.getPartManager().getObjects(); for (Part part : myParts) { String partName = part.getPresentationName(); simulation_0.println(" %%% Part " + partName + " ."); // Use if statement to segregate types of parts and perform further operations on part } |
|
September 2, 2014, 09:14 |
|
#4 |
Member
kris
Join Date: May 2014
Posts: 73
Rep Power: 12 |
You are right. the if statement would look something like this.
String compare = "PlaneSection"; if (part.getClass().toString().contains(compare)){ //do something with the part } you can just print the class for all the parts to get your "compare" variable. |
|
Tags |
derived parts, java, loop, macros |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Gmsh] Problem with Gmsh | nishant_hull | OpenFOAM Meshing & Mesh Conversion | 23 | August 5, 2015 03:09 |
Stop in macro loop ? | binbinhfr | STAR-CCM+ | 7 | February 18, 2013 16:31 |
Creating 100 derived parts / Splitting derived parts for mass flux calculation | xamo | STAR-CCM+ | 8 | September 29, 2009 06:35 |
NACA0012 geometry/design software needed | Franny | Main CFD Forum | 13 | July 7, 2007 16:57 |
CFX TASCflow - while-endwhile loop ina macro | Deepak Ganga | CFX | 0 | September 6, 2003 23:21 |