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

Macro to loop over derived parts

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By kguntur

Reply
 
LinkBack Thread Tools Display Modes
Old   September 2, 2014, 04:22
Question Macro to loop over derived parts
  #1
New Member
 
Join Date: Sep 2014
Posts: 4
Rep Power: 2
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, 05:38
Default
  #2
Member
 
kris
Join Date: May 2014
Posts: 62
Rep Power: 3
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, 08:04
Default
  #3
New Member
 
Join Date: Sep 2014
Posts: 4
Rep Power: 2
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, 08:14
Default
  #4
Member
 
kris
Join Date: May 2014
Posts: 62
Rep Power: 3
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

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Gmsh nishant_hull Open Source Meshers: Gmsh, Netgen, CGNS, ... 23 August 5, 2015 02: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 05:35
NACA0012 geometry/design software needed Franny Main CFD Forum 13 July 7, 2007 15:57
CFX TASCflow - while-endwhile loop ina macro Deepak Ganga CFX 0 September 6, 2003 22:21


All times are GMT -4. The time now is 04:17.