×
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

Open "Part in Position" using API

Open "Part in Position" using API

Open "Part in Position" using API

(OP)
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.

RE: Open "Part in Position" using API

(OP)
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

RE: Open "Part in Position" using API

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.

RE: Open "Part in Position" using API

(OP)
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.

RE: Open "Part in Position" using API

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).

RE: Open "Part in Position" using API

(OP)
Great, thank you very much! I appreciate your help.

RE: Open "Part in Position" using API

(OP)

Quote (Artemtat)


I am wondering how you obtained the variables

CODE --> vb

Const WM_COMMAND As Long = 273
Const OPEN_IN_POSITION_CMD As Long = 52056 

Do you have the list of command codes for Solidworks?

Thanks,

RE: Open "Part in Position" using API

No, this was handled using Win32 Windows APIs (Global Hooks). I just found which message was sent and which parameters.

RE: Open "Part in Position" using API

(OP)
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:



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

RE: Open "Part in Position" using API

WM_COMMAND is a message which is sent with the parameter 52056, WM_COMMAND = 273. If you convert 0111 from HEX to Decimal you will get 273

RE: Open "Part in Position" using API

(OP)
Got it, thank you very much!

RE: Open "Part in Position" using API

(OP)

Quote (ArtemTat)

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.

RE: Open "Part in Position" using API

(OP)
any comment?

RE: Open "Part in Position" using API

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).

RE: Open "Part in Position" using API

(OP)
Got it, thank you very much.

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