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?
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