Reply
Solved! Go to solution

Select part in tree

Hello,

 

So I have just installed ST10 and was using the new Open drawing command,

I have been using my own macro to open the drawing from a part or assembly file for some time.

In my macro if the draft is not found it automatically runs the create a new draft command to save a bit of effort.

 

I now also see that the new built in command uses the windows indexed links ( I think) so it fails to find the draft all of the time.  So going to continue to use my own.

However  the built in command does something I likeSmiley Happy , i can open the draft by just selecting the file in the tree... and not just the active document.

 

So I am trying to update my own!  

and here I run into an issue

 

If the part is in the top level assembly i can find it with:-

 

objApp.ActiveSelectSet.Item(1).OccurrenceFileName

 

but if its in a sub assembly i need to use :-

 

objApp.ActiveSelectSet.Item(1).Object.OccurrenceFileName

 

and using the wrong one fails so I cannot seem to test for isnothing.

 

Using the excellent spy i can see;

snip1.JPG

 

 

snip2.JPG

 

 a crude way of testing..  it runs if I comment out the wrong "test" line.

Snip3.JPG

 I was using the OccurrenceFileName for testing but will prefer to use the OccurrenceDocument reference

for .path and .Fullname etc

 

 The question is how should I be finding the filename / path from the selected item.

 

Sorry that seemed harder to explain than necessary.

 

Thanks for your help 

Regards Kevin

 

 

 

2 REPLIES
Solution
Solution
Accepted by topic author kevin_parker
2 weeks ago

Re: Select part in tree

if objApp.ActiveSelectSet.Item(1).Type = igReference then
objApp.ActiveSelectSet.Item(1).Object.OccurrenceFileName
.....
regards
Gerald

Re: Select part in tree

Thank you so much for your help Gerald , that worked a treat.

Regards Kevin