Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open "Part in Position" using API 1

Status
Not open for further replies.

neshom

Mechanical
Feb 7, 2016
43
0
0
AU
I'd like to open a part similar to "Open in Position" using API. I am able to open a part, but the view is not the same at it is in assembly.

Do you know how I can do this?

Thanks in advance.
 
Replies continue below

Recommended for you

Thank you for your comment.

So it is not possible to do it withou using Windows API? I'd like to know if there is a way to do it with only Solidworks APIs?

Thanks
 
No, I'm afraid the API is missing. One alternative way to do this is to get the transformation of the component (IComponent2::Transform2) and current view transformation (IModelView::Transform) and compose new transform to apply to the opened part's view.
 
This is exactly what I was hoping to do, but I am new with Solidworks API and not sure how to implement it especially the last part when I need to apply the transformation to the opened part.
I appreciate if you can post an example or link for this.
 
I have update the original example to link to the snippet which shows how to do this using the transforms (scroll down to the bottom to see the link).
 
Thanks, may I ask what tool you used to find the parameters?
I am using Spy++ and this is the code that I am getting for "Open in Position" command:

<006733> 0000000000070C14 P WM_COMMAND wNotifyCode:0 (sent from a menu) wID:52056

when I select property, it shows this windows:

spy_obmnfv.jpg


From the code I can get the OPEN_IN_POSITION_CMD=52056, but I don't know what is WM_COMMAND. I tried 111, but it only highlights the whole part.

Please let me know.

Thanks
 
ArtemTat said:
I have update the original example to link to the snippet which shows how to do this using the transforms (scroll down to the bottom to see the link).

I was trying the code you kindly shared here that changes the view of the opened part to the view of the assembly. It works, but it firsts opens the part that is in another view and then changes the view. So basically you see the changes of the views. I am wondering if there is any way to open the part and update the view and then show/activate it?

Thank you again.
 
I think you cannot preset the orientation because IModelView only available for visible documents. But you can freeze the view so user won't see the view change (take a look at ModelView::EnableGraphicsUpdate).
 
Status
Not open for further replies.
Back
Top