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?
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
RE: modify the coordinates of some nodes
RE: modify the coordinates of some nodes
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
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
DrBwts : i do like you tell me but it didn't work
RE: modify the coordinates of some nodes
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
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
Use this instead:
mdb.models['Model-1'].parts['Part-1'].editNode()
RE: modify the coordinates of some nodes
RE: modify the coordinates of some nodes
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:
RE: modify the coordinates of some nodes
RE: modify the coordinates of some nodes
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)