When using CCV2ChangeSizeButtonCM, how do you prevent your VBA from continuing?

When using CCV2ChangeSizeButtonCM, how do you prevent your VBA from continuing?

shastu
Advisor Advisor
925 Views
8 Replies
Message 1 of 9

When using CCV2ChangeSizeButtonCM, how do you prevent your VBA from continuing?

shastu
Advisor
Advisor

I am using the CCV2ChangeSizeButtonCM in one of my VBA routines and it seems to try and go past it before the dialog box comes up.  When this happens I get a content center message box "There was a problem encountered while communicating with the server.  Please check the network connection and server status."  but If I just put a message box after the CCV2ChangeSizeButtonCM then it works fine.  Notice I said "after" yet the msgbox comes up before the Change Size dialog box does.  So in other words, I want my VBA code to stop while they are picking there selections from the dialog box and then after they click on the OK, then I want my VBA code to continue on.  Currently, it is continuing on as the dialog box is trying to come up.

0 Likes
Accepted solutions (1)
926 Views
8 Replies
Replies (8)
Message 2 of 9

chandra.shekar.g
Autodesk Support
Autodesk Support

@shastu,

 

 

Can you please demonstrate on what is meant by "Selections from dialog box"?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 9

shastu
Advisor
Advisor

See attached.  When you use the CCV2ChangeSizeButtonCM to open the change size dialog box, the code does not stop as it is opening and while the user is making his selections that he wants changed.  I know this because I put a msgbox in my code after the call and it shows up before the dialog box does.  When I leave that in my code, I can make my selections in the dialog box, and then hit OK.  My code is stopped because of the dialog box and then once I hit the OK button on that, it continues with the rest of my code.  The problem is, I don't want to use a msgbox to stop my code.  Instead, I want the code to stop as it brings up the change size dialog box and not continue until I hit the OK button.

0 Likes
Message 4 of 9

YuhanZhang
Autodesk
Autodesk

When you call this Content Center addin command using ControlDefinition.Execute/Execute2 it does not run it synchronously, so you will see the code continues to run but not waits for user to deal with the dialog.  A possible workaround is just after you call the ControlDefinition.Execute you can start an event to monitor how user deals with the dialog, a recommended event you can use is OnAssemblyChange.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 5 of 9

shastu
Advisor
Advisor

I am not sure how the OnAssemblyChange would help in my scenario as it is only a part of my code where I want it to stop.  I think usually, you would use an OnAssemblyChnage when you want to run the entire thing.  In other words, I don't want to run the sub anytime an occurrence changes, but just at a particular point in my code.  Can you make a call to your OnAssemblyChange sub?  I tried, but couldn't get it to work.

0 Likes
Message 6 of 9

shastu
Advisor
Advisor
Accepted solution

I found my own solution.  After the CCV2ChangeSizeButtonCM I used ThisApplication.UserInterfaceManager.DoEvents

Message 7 of 9

Khoa_NguyenDang
Advocate
Advocate

Can you share your solution, i now also have the same problem

Thank you so much

0 Likes
Message 8 of 9

A.Acheson
Mentor
Mentor

This line is used to slow down the code for user interaction. 

 

ThisApplication.UserInterfaceManager.DoEvents

 I usually use it on it’s own without a loop but it can depend on your application. And here is a link to other use cases. 

https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/doevents-and-vb-net-selection/td-p/2006...

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 9 of 9

Khoa_NguyenDang
Advocate
Advocate

Thank you so much

0 Likes