Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Python Script: Sorted Sets

Status
Not open for further replies.

PeterP1

Materials
Mar 27, 2009
9
Hello!

Currently I'm working on a Python script and I'd like to know whether it is possible to create sets with entries sorted by a particular criterion?

In my case I need a node set with nodes arranged by their y-coordinates. Is it possible, for example, to generate a list of node labels, to rearrange the entries of the list and to create a set from that list afterwards?

Thanks a lot!
 
Replies continue below

Recommended for you

Hi PeterP1,

Look for unsorted node sets in the manual.

Once you have sorted your node list as needed, you can create a so called "unsorted node set" out of it ("unsorted" because it is not sorted by node label). As unsorted node sets are not supported by /CAE, you'll probably have to use the keyword editor in some way in your script to add the set to your input file.

Hope this helps,

potf
 
I know about unsorted sets but this works with keywords only. Using the keyword editor in a script is possible but it makes things more complicated. Therefore I'd like to avoid it. If there is no other possibility your solution is the best one, I guess.

Thank you potf!
 
Hi to all Pyoneers!
PeterP1, you can check this pack:
Or code your own iterator using heaps:
Right now python hasnt its own built-in implementations of sorted collections.
Also, if you are using JPython, you can use those java built-ins:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor