×
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

modify the coordinates of some nodes

modify the coordinates of some nodes

modify the coordinates of some nodes

(OP)
Hi;
I want to modify the coordinates of some nodes, so I wrote the following program on python. The program runs but I display no result on Abaqus.

mesh_nodes=mdb.models['Model-1'].rootAssembly.instances['Part-1-1'].nodes
tolerance = 1.0e-6

for node in mesh_nodes:
x = node.coordinates[0]
y= node.coordinates[1]
z = node.coordinates[2]
if node.coordinates[2]-(zmin+0.1) < tolerance:
x=node.label
mdb.models['Model-1'] . rootAssembly . editNode ( nodes=mesh_nodes [ x ] ,
coordinate1=node.coordinates[0] , coordinate2=node.coordinates[1] ,coordinate3=node.coordinates[2]+random.random()*0.1 , projectToGeometry=ON)
Can you help me please me to find a solution for this program and display modification of the coordinates of the nodes?

RE: modify the coordinates of some nodes

projectToGeometry should be set to OFF I suspect

RE: modify the coordinates of some nodes

(OP)
i modified projectToGeometry by OFF but no display modification

RE: modify the coordinates of some nodes

Are you using dependent or independent meshes?
Also check you script. Run the for loop but store the before and after coordinates in an array/list and compare them.

RE: modify the coordinates of some nodes

OK so you have defined x for 2 completely different things!

x = node.coordinates[0]

and

x=node.label

That's some bad practice right there! You have to very careful with variable assignments in Python as the following is possible,

x = node.coordinates[0]
x = node.label


therefore...

node.coordinate[0] = node.label

Consider renaming the 2nd instance of x to something like nodeLabel

Anyway if that turns out not to be the problem, I suspect that it is with

nodes=mesh_nodes [ nodeLabel ]

try,

nodes=mesh_nodes [ nodeLabel-1:nodeLabel ]

Abaqus CAE does some strange things with indexing that just dont follow the Python standards.


RE: modify the coordinates of some nodes

(OP)
cooken : i used depend mesh
DrBwts : i do like you tell me but it didn't work

RE: modify the coordinates of some nodes

@chourouk
Create a simple model and your script so far. Attach the files and write clearly what you want the script to do.


> Abaqus CAE does some strange things with indexing that just dont follow the Python standards.

Python starts a list at index 0. A node or element label starts with 1. That's the reason for the offset.

RE: modify the coordinates of some nodes

Thanks again Mustaine thats been bugging me.

Chourouk for what its worth here is the code that I use to scale parts in CAE. It works fine for me.

CODE --> Python

modelName = 'myModel'
partName = 'myPart'
xScale = 10.0
yScale = 10.0
zScale = 10.0

for coord in mdb.models[modelName].parts[partName].nodes:

    x = coord.coordinates[0] * xScale
    y = coord.coordinates[1] * yScale
    z = coord.coordinates[2] * zScale
    nLabel = coord.label
	
    mdb.models[modelName].parts[partName].editNode(coordinate1=x, coordinate2=y, coordinate3=z, nodes=mdb.models[modelName].parts[partName].nodes[nLabel-1:nLabel]) 

RE: modify the coordinates of some nodes

If you're using a dependent mesh then you should be editing the nodes in the part not the assembly, unless I misunderstand what its doing..
Use this instead:
mdb.models['Model-1'].parts['Part-1'].editNode()

RE: modify the coordinates of some nodes

(OP)
@DrBwts:i do like you tell me but no result!!

RE: modify the coordinates of some nodes

Again, have you checked that your script to produce the new coordinates is working properly? I assume you actually imported random?
For example, do the following or something similar like putting the labels that pass this check into a list and checking the list afterward. It is possible that your script is not actually finding any nodes that meet the criteria.

if node.coordinates[2]-(zmin+0.1) < tolerance:
nLabel=node.label
print n

RE: modify the coordinates of some nodes

(OP)
I check that the vector is not empty, but still no result

RE: modify the coordinates of some nodes

(OP)
this my script but still no result !!
mesh_nodes=mdb.models['Model-1'].parts['Part-1'].nodes
tolerance = 1.0e-6

for node in mesh_nodes:
if node.coordinates[2]-(zmin+0.1) < tolerance:
x = node.coordinates[0]- random.random()*0.1
y= node.coordinates[1]-random.random()*0.1
z = node.coordinates[2]- random.random()*0.1

nodelabel=node.label
mdb.models['Model-1'].parts['Part-1']. editNode ( nodes=mesh_nodes [nodelabel-1:nodelabel ] ,coordinate1=x , coordinate2=y ,coordinate3=z , projectToGeometry=ON)

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