|
[Sponsors] |
October 20, 2019, 09:23 |
Retrieve composite Part name
|
#1 |
New Member
Dwayne
Join Date: Oct 2019
Posts: 3
Rep Power: 7 |
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 |
|
October 21, 2019, 11:35 |
|
#2 |
Senior Member
Sebastian Engel
Join Date: Jun 2011
Location: Germany
Posts: 567
Rep Power: 21 |
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"); } } } |
|
October 21, 2019, 11:46 |
Retrieve composite Part name
|
#3 |
New Member
Dwayne
Join Date: Oct 2019
Posts: 3
Rep Power: 7 |
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. |
|
|
|
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 |