×
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

Abaqus/Python - commands to find nearest node to a given point

Abaqus/Python - commands to find nearest node to a given point

Abaqus/Python - commands to find nearest node to a given point

(OP)
Hi,
I need to write a python comman code to find a node (in a given set), nearest to a given point.
The code now looks as follows:
import sys
sys.path.insert(10,
r'c:/SIMULIA/Abaqus/6.13-3/code/python/lib/abaqus_plugins/findNearestNode')
import nearestNodeModule
nearestNodeModule.hideTextAndArrow()
a = mdb.models['FibreModel'].rootAssembly
n1 = a.instances['Fibre0-1'].nodes
pickedSelectedNodes = n1[0:599]
g=nearestNodeModule.findNearestNode(xcoord=101, ycoord=106, zcoord=58, name='', selectedNodes=pickedSelectedNodes, instanceName="'Fibre2-1'")
ct=g[0]

And I get an error:
File "SMAPyaModules\SMAPyaPluginsPy.m\src\abaqus_plugin s\findNearestNode\nearestNodeModule.py", line 71, in findNearestNode
AttributeError: 'NoneType' object has no attribute 'instances'

Does anyone know what is wrong there?

Leon

RE: Abaqus/Python - commands to find nearest node to a given point

The name argument is empty. And the instanceName argument looks also strange.


I made a simple test and it worked with
nearestNodeModule.findNearestNode(xcoord=31, ycoord=0, zcoord=17, name='Job-1.odb')

and
nearestNodeModule.findNearestNode(xcoord=31, ycoord=0, zcoord=17, name='Job-1.odb', instanceName='block-1')

RE: Abaqus/Python - commands to find nearest node to a given point

(OP)
Thank you very much. Yes, it is probably correct - the problem might be with "name" argument. But this code is a part of a large code of CAE model generation. So, no ODB file exists when I run this PY file at Abaqus. What should I then place in name?

RE: Abaqus/Python - commands to find nearest node to a given point

This worked too in my example:
nearestNodeModule.findNearestNode(xcoord=31, ycoord=0, zcoord=17, name='')

Be sure to use two ' instead of one ".

RE: Abaqus/Python - commands to find nearest node to a given point

(OP)
Thank you very much. in fact, it is quite strange. Sometime, the code gives an error:
File "SMAPyaModules\SMAPyaPluginsPy.m\src\abaqus_plugins\findNearestNode\nearestNodeModule.py", line 71, in findNearestNode
AttributeError: 'NoneType' object has no attribute 'instances.

But sometimes it works.
The code is given below.
I tried both sinlge and double quota marks, it did not change much.

-----------------------------------------
import sys
sys.path.insert(30,
r'c:/SIMULIA/Abaqus/6.13-3/code/python/lib/abaqus_plugins/findNearestNode')
import nearestNodeModule
session.viewports['Viewport: 1'].assemblyDisplay.setValues(mesh=ON)
session.viewports['Viewport: 1'].assemblyDisplay.meshOptions.setValues(
meshTechnique=ON)
nearestNodeModule.hideTextAndArrow()
a = mdb.models['FibreModel'].rootAssembly
n1 = a.instances['Fibre0-1'].nodes
pickedSelectedNodes = n1[0:599]
g=nearestNodeModule.findNearestNode(xcoord=200, ycoord=220, zcoord=230, name='',
selectedNodes=pickedSelectedNodes, instanceName="'Fibre0-1'")
ct=g[0]
setName='Set-'+str(ct)
p = mdb.models['FibreModel']
setName='Set-'+str(ct)
p.rootAssembly.Set(name=setName, nodes=p.rootAssembly.instances['Fibre0-1'].nodes[ct-1:ct])
a = mdb.models['FibreModel'].rootAssembly
region1=a.sets['Sta1']
a = mdb.models['FibreModel'].rootAssembly
region2=a.sets['Set-281']
mdb.models['FibreModel'].Coupling(name='Constraint-18', controlPoint=region1,
surface=region2, influenceRadius=WHOLE_SURFACE, couplingType=KINEMATIC,
localCsys=None, u1=ON, u2=ON, u3=ON, ur1=OFF, ur2=OFF, ur3=OFF)

RE: Abaqus/Python - commands to find nearest node to a given point

(OP)
My purpose is to write a Fotran code which output is this Python comman file. However, while the code works sometime when I copy/paste it from text, the Fortran produced PY file gives always the error.

RE: Abaqus/Python - commands to find nearest node to a given point

I guess the problem is here:
instanceName="'Fibre0-1'"

Try
instanceName='Fibre0-1'

RE: Abaqus/Python - commands to find nearest node to a given point

(OP)
I tried, it didnt work. But when I add in the "name=" the ODB file, it works (although it is wrong file, and the command gives wrong results).
Can it be that this command works only with ODB files, and, thus can not help to build CAE file via Python code?

RE: Abaqus/Python - commands to find nearest node to a given point

I made a simple test: Just started /CAE, created a block, meshed it and created a instance. No odb opened. Still this worked:
nearestNodeModule.findNearestNode(xcoord=1, ycoord=0, zcoord=0, name='')

RE: Abaqus/Python - commands to find nearest node to a given point

(OP)
Thank you. Indeed, now my PY file runs also. I still dont understand why it did not run before, and started now. Anyway, thank you very much.

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