×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Python script node coordinate tuple

Python script node coordinate tuple

Python script node coordinate tuple

(OP)
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.  

RE: Python script node coordinate tuple

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]))

RE: Python script node coordinate tuple

(OP)
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.

RE: Python script node coordinate tuple

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[i].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
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources