Inventor Customization

Reply
Mentor
pball
Posts: 225
Registered: ‎04-20-2012
Message 1 of 2 (164 Views)
Accepted Solution

Get name of current assembly, when editing sub-assemblies

164 Views, 1 Replies
09-25-2012 02:02 PM

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?

Valued Contributor
AlbertoTorres
Posts: 76
Registered: ‎10-18-2004
Message 2 of 2 (145 Views)

Re: Get name of current assembly, when editing sub-assemblies

09-27-2012 08:14 AM 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

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube