cancel
Showing results for 
Search instead for 
Did you mean: 

Selecting nodes/elements using Python in NX Advanced Simulation

Experimenter
Experimenter

Hi guys,

 

Iam relatively new to Python and NX Open programming, so I was hoping you guys could help me out Smiley Happy I am currently working on a script which requires a node OR a selection of nodes as input to the script.

 

Lets say, I want to read out all stress components from the results file at a particular node/element. What I am working on is the following:

 

1. Execute the journal/script in NX (Play Journal)

2. Interactively pick a node/ selection of nodes  as input.

3. Output the stress components for the selection to the listing window.

 

I know that Node/Element Information does this easily. Also, using the result variables and probes is an option. But I want to loop through all the loadcases and read out all the stresses per load case per selected node.

 

I have more or less got the script working to read out the stresses for a particular node. i.e. I have manually given the index in the script . But at this point, I do not know how to interactively pick a node OR get a node label interactively using the script.

 

Can someone guide me in the right direction? What is the best approach to this? Iam using NX 10.

 

I hope my question is clear. Looking forward to some replies.

 

Best regards,

Mrinal

5 REPLIES

Re: Selecting nodes/elements using Python in NX Advanced Simulation

Siemens Phenom Siemens Phenom
Siemens Phenom

 

Check the online examples for a program called "

edit selected CAE nodes labels

 

You can also just search for the article by its title, nx_api3993.

 

This is a Visual Basic program, and you are working in Python, so to get an approximate translation, do this:  Be sure your Preferences -> User Interface -> Journal setting is Python.

 

Start recording a Journal in Python.  While doing that, Play the VB journal, and select at least a couple of nodes. 

 

Stop recording.  Edit your new Python Journal.

 

This will not be a perfect translation, but it will probably be enough to demonstrate how to set the mask and perform selection of nodes in Python.

 

(Python is the newest addition to the Common API NXOpen automation kits, so we have not had much time to create examples yet.)

 

Re: Selecting nodes/elements using Python in NX Advanced Simulation

Siemens Phenom Siemens Phenom
Siemens Phenom

If you have a Block Styler license, there are dedicated Node and Element selection blocks that can be used. These are identical to OOTB functionality and let you select graphically and/or by keying in a label.

 

If you want to select graphically without the block styler, use the example Steve provided.

 

If you want the user to key in a label, you could prompt for an integer input using Tk.

Re: Selecting nodes/elements using Python in NX Advanced Simulation

Experimenter
Experimenter

Hi Steve,

 

Thanks for the reply. Where can I find the online examples? Can you share the link perhaps?

 

Regards

Mrinal

Re: Selecting nodes/elements using Python in NX Advanced Simulation

Experimenter
Experimenter

Hey Jim,

 

Thanks for the reply. Unfortunately I don't have a Block Styler license. I will have a look into the example Steve provided once I find it Smiley Happy

 

Regarding the third option, prompting for an integer input using Tk. How do I go about doing that? Is there a short example that I can find somewhere? Or some documentation?

 

Regards

Mrinal

Re: Selecting nodes/elements using Python in NX Advanced Simulation

Siemens Phenom Siemens Phenom
Siemens Phenom

 

Try this link:

 

https://solutions.industrysoftware.automation.siemens.com/

 

You will be prompted to login with your Webkey.  We have hundreds of examples out there.

 

Search for

 

   nxopen sample

 

and keywords related to whatever you are searching for.  AFTER the initial search, filter the results by clicking on "nx_api" under Document Type, to see only example programs or functions.

 

This link might work to get you straight to the example mentioned:

 

https://solutions.industrysoftware.automation.siemens.com/result.php?sort=desc&p=1&q=nx_api3993