def _get_name_attr(self): label = self.TDF_Label h_a = TDataStd.Handle_TDataStd_Name() gid = TDataStd.TDataStd_Name().ID() if label.FindAttribute(gid, h_a): a = h_a.GetObject() name = TCollection.TCollection_AsciiString(a.Get()) return name.ToCString() else: return "no name"
def get_id(c): try: return GID2Tuple(c().GetObject().GetID()), c except AttributeError: return None idList = (get_id(c) for c in attrList) filtered = (a for a in idList if a is not None) return dict(filtered) AttributeMap = get_AttributeMap() print "map" #print AttributeMap shape_gid = TDataStd.TDataStd_Shape().ID() class Attribute(HasTraits): TDF_Attribute = Instance(TDF.TDF_Attribute) attr_cls = Property(depends_on="TDF_Attribute") cls_name = Property(Str, depends_on="TDF_Attribute") name = Property(Str, depends_on="attr_cls") def _get_attr_cls(self): ID = self.TDF_Attribute.ID() try: return AttributeMap[GID2Tuple(ID)] except KeyError: return None