python scripting accessing a Datum in a feature
python scripting accessing a Datum in a feature
(OP)
I'm trying to write a script that applies a load to a surface to a couple of instances.
This is the script:
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
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.
This is the script:
CODE --> 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].datums[2]
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
Models(1)
- Model-1
- Parts(1)
- mybolt
- Features(4)
+ Solid extrude-1
- Datum plane-1
- Partition cell-1
- myaxis
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.





RE: python scripting accessing a Datum in a feature
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]
RE: python scripting accessing a Datum in a feature
I was already at that id while poking around when I did:
mdb.models['Model-1'].rootAssembly.instances['mybolt-1']
CODE --> 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)})({'normal': (-0.0, -0.0, -1.0), 'pointOn': (0.0, 200.0, 20.0)})
Now the result of your suggestion:
CODE --> 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
RE: python scripting accessing a Datum in a feature
Wanted to say ..gets highlightet when applying the load.
And the first code box should lokk like:
CODE --> 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)})RE: python scripting accessing a Datum in a feature
RE: python scripting accessing a Datum in a feature
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
RE: python scripting accessing a Datum in a feature
Thnx,
Christoph