VBA Code to return Body Name from part within an assembly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
HI,
I am struggling with some code to initially return a Body name from a Part placed in an assembly... the code must run from the assembly file... if I run the code in the Part, it works fine and returns the selected body name. when I run it in the Assmbly it does not return the name, however it does not come up with an error either... I think I need to reference the selected part, and not the active application when selecting the body... hence the code I have added to select the part first... but I dont know how to do this... I can get it to print the parent name... i.e. Debug.Print Body.parent.name... but this doesn't help me unfortunately
Sub INSERT_D1()
'Make a ref to active doc
Dim doc As Document
Set doc = ThisApplication.ActiveDocument
Dim Structure As ComponentOccurrence
Dim Structuredoc As Document
Set Structure = ThisApplication.CommandManager.Pick(kAssemblyOccurrenceFilter, "Select the structure")
Set Structuredoc = Structure.Definition.Document
Dim body As SurfaceBody
Set body = ThisApplication.CommandManager.Pick(kPartBodyFilter, "Select wall to insert door on.")
Debug.Print body.Name
End Sub