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!

modify the coordinates of some nodes

Status
Not open for further replies.

chourouk

Mechanical
Sep 15, 2016
41
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?
 
Replies continue below

Recommended for you

projectToGeometry should be set to OFF I suspect
 
i modified projectToGeometry by OFF but no display modification
 
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.
 
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.


 
cooken : i used depend mesh
DrBwts : i do like you tell me but it didn't work
 
@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.
 
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.

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])
 
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()
 
@DrBwts:i do like you tell me but no result!!
 
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​
 
I check that the vector is not empty, but still no result
 
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)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor