I'm trying to get the normal of every face in a surface (EDIT: the surface is extracted from a solid, not a shell). I can't seem to get the face objects though. According to the scripting reference guide this should be the syntax:
mdb.models[name].rootAssembly.instances[name].surfaces[name].faces[i]
I tried this:
femur_instance.surfaces['IMPLANT_SHAFT'].faces[0]
but when trying to get the normal using pointOn[1]
attribute it gave me an attribute error. When I look at the attributes I get this:
['__class__', '__copy__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__getstate__', '__hash__', '__init__', '__lt__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_addToCache', '_cache', '_counter', '_id', '_p', '_scdId', 'getId', 'getText', 'name']
the type of the returned object is: 'symbolicConstant'
What am I doing wrong?
EDIT: femur_instance
was defined as, odb.rootAssembly.instances['FEMUR_SHAFT_1']
which caused the error, see answer.
You are referring to two different objects in your post and in your comment. One is a Face object in the mdb, the other is an OdbSet object in the odb. Although they are similarly named, they do not have the same meaning, attributes, or methods. This is the source of the error message you mention.
For example, in your original post you are referencing the geometric Face object in the mdb. For example:
`f = mdb.rootAssembly.instances[name].surfaces[name].faces[N]`
where N
references the specific Face object in the faces
array and we are assigning it to the variable f
. Now, f
has a handful of "members" or attributes. One of the them is f.pointOn
. See how to use this below.
However, in your comments, you refer to the OdbSet object. For example:
`g = odb.rootAssembly.instances[name].surfaces[name].faces[N]`
In this case, faces
is a tuple of symbolic constants that specify the element face on the geometric face. It seems you are trying to use g
, but you actually should be using the mdb Face object f
.
Using the mdb Face object: If your part is a solid (meshed using continuum elements such as CPS4 in 2D or C3D8 in 3D), then:
((x,y,z),) = f.pointOn
The pointOn
member is a tuple of tuples of floats. There is actually only one inner tuple, and it contains the coordinates of a point on the face.
If your part is a shell (meshed using shell elements such as S4), then you will instead get:
((x,y,z),(a,b,c)) = f.pointOn
which is again, a tuple of tuples of floats. There are two inner tuples. The first contains the coordinates of a point on the face, and the second contains the components of the normal to the face in the global coordinate system.
I have the feeling that your part is a solid, however, so this technique will not return the normal to the surface.