Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get name of current assembly, when editing sub-assemblies

1 REPLY 1
SOLVED
Reply
Message 1 of 2
pball
383 Views, 1 Reply

Get name of current assembly, when editing sub-assemblies

I have a script which currently references ThisApplication.ActiveDocument which is fine if you are in the top level assembly. But when I go into a sub-assembly to edit it, I would like the script to get the name of the sub-assembly.

 

So is there a simple way to get the name of the sub-assembly you are currently editing?

1 REPLY 1
Message 2 of 2
AlbertoTorres
in reply to: pball

This scriptlet will give the name of the object you are currently editing.

1. - Checks if the current document is an assembly. If it is given a message and exits.

2. - Displays the name of the document currently being edited
A Sub-assembly o Part that is being edited) If you're not editing anything,
gives the name of the parent assembly.

** You should now catch the type of document being edited to make other functions on it, for example.

Public Sub DameNombre()
    If ThisApplication.ActiveDocumentType <> kAssemblyDocumentObject Then
        MsgBox ("Macro only for Assembly")
        End
    End If
      
    If ThisApplication.ActiveEditDocument.DocumentType = kAssemblyDocumentObject Then
        MsgBox ("Sub-Assembly name = " & ThisApplication.ActiveEditDocument.DisplayName)
    Else
        MsgBox ("Part name = " & ThisApplication.ActiveEditDocument.DisplayName)
    End If
End Sub

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report