CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > Siemens > STAR-CCM+

Macro to loop over derived parts

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By kguntur

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 2, 2014, 05:22
Question Macro to loop over derived parts
  #1
New Member
 
Join Date: Sep 2014
Posts: 4
Rep Power: 12
solsidan is on a distinguished road
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?
solsidan is offline   Reply With Quote

Old   September 2, 2014, 06:38
Default
  #2
Member
 
kris
Join Date: May 2014
Posts: 73
Rep Power: 12
kguntur is on a distinguished road
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.
kguntur is offline   Reply With Quote

Old   September 2, 2014, 09:04
Default
  #3
New Member
 
Join Date: Sep 2014
Posts: 4
Rep Power: 12
solsidan is on a distinguished road
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
        }
solsidan is offline   Reply With Quote

Old   September 2, 2014, 09:14
Default
  #4
Member
 
kris
Join Date: May 2014
Posts: 73
Rep Power: 12
kguntur is on a distinguished road
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.
solsidan likes this.
kguntur is offline   Reply With Quote

Reply

Tags
derived parts, java, loop, macros


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 01:47.