I'm re-opening the post because I'm having a small problem with the macro in question which is used to open the selected part in the graphic area.
This is because the macro only works if the part is set to resolved.
Do you know if it would be possible to integrate this into the macro, i.e.: selecting the coin in the graphic area (face or other), launching the macro: solving the coin and then opening it.
I'll give you the code of the macro below:
'******************************************************************************
' ASSEMBLYOPEN. SWB by Ted Griebling
' This macro will open the owning part or subassebly (if selected from the
' feature scrambler) of anything selected in an assembly.
' ******************************************************************************
Dim swApp As Object
Dim activeDocument As Object
Dim selEntity As Object
Dim selType As Long
Dim SelMgr As Object
Dim owningComponent As Object
Dim componentName As String
Dim part As Object
Dim componentpath As String
Const swDocPART = 1
Const swDocASSEMBLY = 2
Const swDocDRAWING = 3
Sub main()
Set swApp = CreateObject("SldWorks.Application")
Set activeDocument = swApp.ActiveDoc
' Make sure this is not a part.
If (activeDocument.GetType = swDocPART) Then
Exit Sub
End If
' Do something else for drawings?
If (activeDocument.GetType = swDocDRAWING) Then
Exit Sub
End If
' Get the SelectionMgr interface
Set SelMgr = activeDocument.SelectionManager
' Obtain the selected Entity object
Set selEntity = SelMgr.GetSelectedObject3(1)
selType = SelMgr.GetSelectedObjectType2(1)
'MsgBox selType
' Types that make later parts barf
If (selType = 0) Or (selType = 42) Or (selType = 69) Then
Exit Sub
End If
' This works grand for components selected from the feature scrambler
If (SelMgr.GetSelectedObjectType2(1) = 20) Then
' yes!
activeDocument.OpenCompFile
Exit Sub
End If
'extract the path name from the entity selected.
If (activeDocument.GetType = swDocASSEMBLY) Then
' Get the owning Component object
Set owningComponent = selEntity.GetComponent
' Get the Component Path Name
componentpath = owningComponent.GetPathName
' MsgBox componentpath
' Open the part in it's own window yes!
Set part = swApp.ActivateDoc(componentpath)
Exit Sub
End If
End Sub
Thank you in advance for your answers.
Kind regards