Context: I am trying to make a script in Abaqus that will automatically create partitions between vertices for all faces. The partitioning won't be perfect, but the users will be able to delete the extra partitioning easily.
Problem:
v1 looks like a dictionary
({'featureName': 'Solid extrude-1', 'index': 1, 'instanceName': None, 'isReferenceRep': False, 'pointOn': ((10.0, -10.0, 20.0),)})
so I tried to sort it by its indices (line 5)
How do I get the indices i.e. 'index':1 of a vertex type object in ABAQUS?
>>> p = mdb.models[myString].parts[myPart]
>>> f = p.faces
>>> pickedFaces = f[:]
>>> v1, e1, d1 = p.vertices, p.edges, p.datums
>>> pickedFaces_r=sorted(pickedFaces, key = lambda k:k['index'], reverse=True)
#reverse picked faces due to additional faces and nodes problem
TypeError: 'Face' object has no attribute '__getitem__'
My attempt at debugging
>>> print(v1[1])
({'featureName': 'Solid extrude-1', 'index': 1, 'instanceName': None, 'isReferenceRep':
False, 'pointOn': ((10.0, -10.0, 20.0),)})
#It looks like a dictionary so I thought it was one.
>>> print(v1[1].get['index'])
**AttributeError: 'Vertex' object has no attribute 'get'**
>>> a=v1[1]
>>> print(a.get['index'])
**AttributeError: 'Vertex' object has no attribute 'get'**
>>> print(a.values())
**AttributeError: 'Vertex' object has no attribute 'values'**
>>> print(type(a))
<type 'Vertex'>
All Abaqus' internal objects are specially developed classes, which could be similar (in some way) to standard Python types. For example, as you've discovered if you try to print some of them, you could have a dictionary-like representation, which doesn't mean that it is a dictionary.
The two best ways to find out what you can do with an object are:
dir()
method from the standard python library.So, in your particular case you can do:
pickedFaces_r=sorted(pickedFaces, key=lambda k: k.index, reverse=True)
Also, this line is unnecessary:
pickedFaces = f[:]