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

Retrieve composite Part name

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 20, 2019, 09:23
Default Retrieve composite Part name
  #1
New Member
 
Dwayne
Join Date: Oct 2019
Posts: 3
Rep Power: 7
DMalone is on a distinguished road
I would like to retrieve the name or list of names of my loaded composite part. I want to compare to a specified name.
I am writing a UI to load in a user specified part. I am loading in a Catia part for reference. I can not guarantee that the file name and part name will be the same from the user. Currently I am using the saved file name in my in my script but it errors out as composite part not found.


code snipet.png
Attached Images
File Type: png code snipet.png (7.9 KB, 17 views)
DMalone is offline   Reply With Quote

Old   October 21, 2019, 11:35
Default
  #2
Senior Member
 
Sebastian Engel
Join Date: Jun 2011
Location: Germany
Posts: 567
Rep Power: 21
bluebase will become famous soon enough
Hi Dwayne,

so do you know the string name of the composite part when you load the cad file? Or does the user know?
With getObjects() or getObjectsOf() you can get a complete collection of all available objects in the respective domain.
Then you could loop through them to compare against a name, or prompt a list of names to the user which has to choose.

As a starting point try this script on your prepared simulation with loaded cad file.

best regards,
Sebastian

Code:
import java.util.*;
import javax.swing.JOptionPane;
import star.common.*;

public class compositeParts extends StarMacro {

    public void execute() {
        Simulation sim = getActiveSimulation();

        Vector<CompositePart> composites
                = sim.getGeometryPartManager()
                        .getObjectsOf(CompositePart.class);

        sim.println("Available CompositeParts:");

        composites.stream()
                .forEach(part -> sim.println(part.getPresentationName()));

        Object[] cpNames = composites.stream()
                .map(part -> part.getPresentationName())
                .toArray();

        try {
            Object selectedValue = JOptionPane
                    .showInputDialog(null, "Which CompositeParts?",
                            "Single Choice Dropdown",
                            JOptionPane.INFORMATION_MESSAGE,
                            null, cpNames, cpNames[0]);
            
            sim.println(selectedValue + " has been chosen.");
        } catch (Exception e) {
            sim.println("Cancelled");
        }

    }
}
bluebase is offline   Reply With Quote

Old   October 21, 2019, 11:46
Default Retrieve composite Part name
  #3
New Member
 
Dwayne
Join Date: Oct 2019
Posts: 3
Rep Power: 7
DMalone is on a distinguished road
Sebastian,

so do you know the string name of the composite part when you load the cad file? Or does the user know?
The string name could be different from the File Name so I don't think the
user would know this name exactly.

One problem I found during setting up my conditions is that naming is case sensitive. So the input file name and string name could be similar but the user may use lower case or upr case or a mix between the two. This combination would throw an error.

I like your suggestion. I think this could work.
I will try to apply this to my script.

Thank you very much.
DMalone is offline   Reply With Quote

Reply


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
Retrieve query point coordonate to create a plane passing through this point. potofus EnSight 2 April 6, 2016 08:26
replacing of shock tube high pressure part with a boundary condition for low pressure immortality Main CFD Forum 0 May 2, 2013 14:30
what boundary condition is proper for simulation of shock-tube low pressure part? immortality OpenFOAM Running, Solving & CFD 0 May 2, 2013 14:22
Algorithme choosing for solid part analysis of conjugate heat transfer Anna Tian Main CFD Forum 4 January 20, 2013 17:11
sketch retrieve patrick99 Main CFD Forum 0 December 30, 2010 07:06


All times are GMT -4. The time now is 19:52.