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 node coordinate tuple

Status
Not open for further replies.

Nileo2005

Mechanical
Jul 10, 2008
83
Alright. This might be the stupidest thing I have ever asked, but I just can't seem to figure it out for the life of me. I'm writing an automation script that does all my repetitious preprocessing for me and outputs my input file. I'm currently trying to write a bit of code that would place any nodes with a y coordinate higher than a certain value in a set. I've already done it for faces via centroid locations; grouping and the such isn't the problem at all. What I can't figure out is how to read in the coordinates of a certain node... I think getCoordinate(...) is what I'm loooking for, as it should return my coordinates in a tuple, alas I've run out of ideas on how to even employ it. What kind of arguments do I need? I just wish I could see an example of this command being used; that would be so much easier than :
"5.1.8 getCoordinates(...)
This method returns the coordinates of specified point.
Required argument
entity
A Vertex, Datum point, MeshNode, or ReferencePoint specifying the entity to query.
Optional arguments
None.
Return value
A tuple of three Floats representing the coordinates of the specified point.
Exceptions
None.
 
Replies continue below

Recommended for you

Nileo2005,

Here is a code snippet from something that I wrote to write nodal data to a file. One difference is that I am getting the information from the ODB, but I am not sure if that really matters. Anyway this should get you on the right path.

HTH,
Dan

...
upperNodes=theInstance.nodeSets['TOPSET']
...

for curNode in lowerNodes.nodes:
outputFile.write('%s,%g,%g,%g\n' % (curNode.label, curNode.coordinates[0], curNode.coordinates[1], curNode.coordinates[2]))
 
Hey DanStro,
Thanks for the code, but I don't think it'll do much for me. I'm trying to write my code to sutomate my pre-processing, so I don't even have ab odb yet.
 
Hello!

Maybe you've figured it out already but if not this should help you. In this script the y-coordinates of the nodes on a specific edge are stored in a tuple.

c1=mdb.models[MODELL].rootAssembly
c1.Set(edges=c2.edges.findAt(((0,-1,0),),),name='Edge')
#By "findAt" you get access to the edge.
Coordinates=[]
#This initialises a tuple (maybe a list works as well).
Coordinates.append(c1.sets['Edge'].nodes.coordinates[1])
#This command adds the y-coordinate of node i on the edge to the tuple.

I hope you can make use of it.

Now one question for you: Do you just need a set with the particular nodes or do you need the set to be sorted? In my case I need two sorted node sets (sorted by y-coordinates) for my boundary conditions. Do you know how this could be done? Maybe it works by creating a list with sorted node labels and defining a set from that list?

Kind regards!
Peter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor