08-25-2020
08:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
08-25-2020
08:25 AM
Here's some quickie code using 'NamedEntities', you may find useful in this situation. It's likely much easier to use the 'NamedEntities' than it is to search through all the Attributes to find the right one.
'oDoc can be either the active document,
'or the Document of a ComponentOccurrence in an assembly,
'or the oRefDoc of the assembly's AllReferencedDocuments.
Dim oNEntities As NamedEntities = iLogicVb.Automation.GetNamedEntities(oDoc)
Dim oMap As NameValueMap = oNEntities.Entities
'You can define these objects as whatever type of object they really are instead of just Object
Dim oObj1 As Object
Try
oObj1 = oNEntities.FindEntity("Name")
Catch
MsgBox("Coundn't find an entity in that document with that name.")
End Try
Dim oName As String = oNEntities.GetName(oEntity)
If oNEntities.NameExists("Name") Then
MsgBox("That names exists.")
End If
oNEntities.SetName(oEntity, "Name")
'This is the same as FindEntity, but can return Nothing instead of an Exception.
Dim oObj2 As Object = oNEntities.TryGetEntity("Name")
Wesley Crihfield
(Not an Autodesk Employee)