×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Macro help - How to open a part from an assy?

Macro help - How to open a part from an assy?

Macro help - How to open a part from an assy?

(OP)
Does anyone know the code to open a part from an assembly by selecting the part under the assembly tree. This is the code I have now and it doesn't work.  I have this similar code to open the part by selecting a face, edge or vertex and it works for those selected items.



If (selType = swSelCOMPONENTS) Then
        Set selComp = swSelMgr.GetSelectedObjectsComponent2(1)
        Set owningComponent = selComp.GetComponent
        strmodel = owningComponent.GetPathName
        Set swModel = swApp.ActivateDoc2(strmodel, True, 0)
        strModelName = owningComponent.Name
End If

RE: Macro help - How to open a part from an assy?

I can only assume you are not using 2004.
If you are then all you have to do is RMB click on the part, in the tree or in the graphics area doesn't matter.  You should see a list of options and open part will be one of them.

RE: Macro help - How to open a part from an assy?

(OP)
I'm very aware of the right click option....this macro will be doing much more than just opening the part.  There is a series of autoclicks, field entries, and if/then statements after opening the part.  Opening the part in this manner is a small part of the entire macro program.

RE: Macro help - How to open a part from an assy?

Try using OpenDoc6 instead of ActivateDoc2.

RE: Macro help - How to open a part from an assy?

(OP)
I'm crashing before the activateDoc2 statement.  I'm crashing on this line and get this error

Set owningComponent = selComp.GetComponent

Error Statement
Object doesn't support this property or method.

RE: Macro help - How to open a part from an assy?

>>Set selComp = swSelMgr.GetSelectedObjectsComponent2(1)

Assuming you dimmed "selComp" as a component or component2,
just use "GetSelectedObjects"- are you trying to the the component of a component ?


>> Set owningComponent = selComp.GetComponent
>> strmodel = owningComponent.GetPathName
>>Set swModel = swApp.ActivateDoc2(strmodel, True, 0)

If any of the instances of the component are NOT suppressed
in the assembly, and it is not loaded lightweight, then the model is already loaded.

Just use Component.GetModelDoc to get the Model Object
>>strModelName = owningComponent.Name

RE: Macro help - How to open a part from an assy?

(OP)
Thanks rocheey -

Here is what I ended up doing and it works.  I think I had this before but it wasn't working becuase my test part was lightweight.  Once I put the setsuppression(2)line in it worked fine every time.

Set selComp = swSelMgr.GetSelectedObjectsComponent2(1)
selComp.SetSuppression (2)         
strmodel = selComp.GetPathName
Set swModel = swApp.ActivateDoc2(strmodel, True, 0)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources