Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

python scripting accessing a Datum in a feature

Status
Not open for further replies.

Krischu

Civil/Environmental
Mar 8, 2015
6
I'm trying to write a script that applies a load to a surface to a couple of instances.
This is the script:

Python:
from abaqus import *
from abaqusConstants import *
import displayGroupMdbToolset as dgm
import part
import material
import assembly
from abaqus import getInput
    
def apply_force(my,mn):
    i=1
    a = mdb.models[mn].rootAssembly
    inst = a.instances
    for key in inst.keys():
        if(key.startswith(myname)):
            print key
            region = a.instances[key].surfaces['mysurf']
            #leaf = dgm.LeafFromInstance(a.instances[key]) # leaf noch unbenutzt
            datumAxis= mdb.models[mn].rootAssembly.instances[key].[COLOR=#EF2929][b]datums[2][/b][/color]
            mdb.models[mn].BoltLoad(name='BL-'+str(i),             createStepName='PRE',region=region, magnitude=kraft,            boltMethod=APPLY_FORCE,datumAxis=datumAxis)
            i=i+1

viewportName = session.currentViewportName

mn = session.sessionState[viewportName]['modelName']

myname = getInput('Namen eingeben:')
kraft = float(getInput('Vorspannkraft:'))
apply_force(myname,mn)

The problem is to me that I don't know how to access the axis of the specific part.
In the Model it looks like
[pre]Models(1)
- Model-1
- Parts(1)
- mybolt
- Features(4)
+ Solid extrude-1
- Datum plane-1
- Partition cell-1
- myaxis[/pre]

At the moment datum[2] seems to be an arbitrary point in the surface. What I wish is to access the item 'myaxis'

How can I achieve this?

Thanks in advance for helping.






 
Replies continue below

Recommended for you

I could answer in german, but lets stay in english...

You have to ask for the feature id and use that id to access the datum object.

myaxis_id=mdb.models[mn].parts['Part-1'].features['myaxis'].id

mdb.models[mn].rootAssembly.instances['Part-1-1].datums[myaxis_id]
 
Thanks,

I was already at that id while poking around when I did:

mdb.models['Model-1'].rootAssembly.instances['mybolt-1']
Python:
k=inst['mybolt-1'].__members__
>>> print k
['analysisType', 'cells', 'datums', 'dependent', 'edges', 'elemEdges', 'elemFaces', 'elementEdges', 'elementFaces', 'elements', 'excludedFromSimulation', 'faces', 'geometryValidity', 'ignoredEdges', 'ignoredVertices', 'ips', 'name', 'nodes', 'part', 'partName', 'referencePoints', 'sets', 'skins', 'stringers', 'surfaces', 'vertices']
>>> k=inst['mybolt-1'].__members__
 print inst['mybolt-1'].datums
{2: 'DatumPlane object', 4: 'DatumAxis object'}
>>> print inst['mybolt-1'].datums[4]
({'direction': (0.0, 3.06161699786838e-17, -1.0), 'pointOn': (0.0, 200.0, 20.0)})
>>> print inst['mybolt-1'].datums[2]
({'normal': (-0.0, -0.0, -1.0), 'pointOn': (0.0, 200.0, 20.0)})

Now the result of your suggestion:

Python:
myaxis_id=mdb.models[mn].parts['mybolt'].features['myaxis'].id
print myaxis_id
4
print mdb.models[mn].rootAssembly.instances['mybolt-1'].datums[myaxis_id] 
({'direction': (0.0, 3.06161699786838e-17, -1.0), 'pointOn': (0.0, 200.0, 20.0)})

One can see that 'myaxis' is nealy identical to the 'normal'.

So it actually doesn't seem to matter whether I use myaxis or normal.

The only thing desireable would be that the axis (myaxis) also gets highlighted when applyinf the load.

How could I achieve that?

Thanks.

Christoph
 
Something got garbled in my post:

Wanted to say ..gets highlightet when applying the load.

And the first code box should lokk like:

Python:
k=inst['mybolt-1'].__members__
>>> print k
['analysisType', 'cells', 'datums', 'dependent', 'edges', 'elemEdges', 'elemFaces', 'elementEdges', 'elementFaces', 'elements', 'excludedFromSimulation', 'faces', 'geometryValidity', 'ignoredEdges', 'ignoredVertices', 'ips', 'name', 'nodes', 'part', 'partName', 'referencePoints', 'sets', 'skins', 'stringers', 'surfaces', 'vertices']
>>> k=inst['mybolt-1'].__members__
 print inst['mybolt-1'].datums
{2: 'DatumPlane object', 4: 'DatumAxis object'}
>>> print inst['mybolt-1'].datums[4]
[COLOR=#CC0000]({'direction': (0.0, 3.06161699786838e-17, -1.0), 'pointOn': (0.0, 200.0, 20.0)})[/color] 
>>> print inst['mybolt-1'].datums[2]
[COLOR=#CC0000]({'normal': (-0.0, -0.0, -1.0), 'pointOn': (0.0, 200.0, 20.0)})[/color]
 
What's the question? How you can highlight the axis that is used for a bolt load?
 
Yes, that's exactly what I'm looking for. I would like the axis ('myaxis' which is also the normal) to get highlighted (red for instance) too. At the moment I see three little arrows in
seemingly arbitrary points in the plane 'MYSURF'. These arrows also seem to disappear when a certain zoomlevel is exceeded.

I would prefer to see at one glance which items got the load applied.

Thanks,

Christoph
 
No idea? Anyone having a starting point for me?
Thnx,

Christoph
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor