clicking on VBA form button in inventor through AutoCAD VBA sub

clicking on VBA form button in inventor through AutoCAD VBA sub

floccipier
Advocate Advocate
1,131 Views
9 Replies
Message 1 of 10

clicking on VBA form button in inventor through AutoCAD VBA sub

floccipier
Advocate
Advocate

Hi,

 

I have been able to execute different subs and show the forms in inventor VBA though AutoCAD VBA but I am struggling to find a way to click a button after form is initiated in Inventor. Any help or guidance please. 

 

regards, 

flo

0 Likes
Accepted solutions (1)
1,132 Views
9 Replies
Replies (9)
Message 2 of 10

Ed__Jobe
Mentor
Mentor

I don't think you can get vba to do that. VBA is designed to work within one process. You can use COM to 'talk' to other COM enabled apps, but only using the api, not forms. If you need to use a form in IV, then have it be the controller.

 

Can you give a better explanation of what you are trying to do (what, not how)?

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 3 of 10

floccipier
Advocate
Advocate

thanks @Ed__Jobe here is is what I am trying to do. 

 

I am running vba in ACAD which which

  • exports some data from the my drawing blocks to Excel> done
  • runs inventor and runs VBA that shows up a message> done
  • runs inventor and runs VBA that shows up a vba form> done
  • on VBA form in Inventor I need to click a button to do further actions but I don't know how to click.

so its fourth step which I don't know how I can do that. Let me know please if I need to sketch it to explain as I might not be using right terminology for certain things. 

0 Likes
Message 4 of 10

Ed__Jobe
Mentor
Mentor

That's HOW you are accomplishing your tasks. I asked for WHAT. What information do you need that requires the user to click on a form in another app? If you describe What, maybe we can help you find another way other than how you've tried so far.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 5 of 10

floccipier
Advocate
Advocate

oh ok, my apology for not understanding correctly. 

 

clicking that button would read an excel file and depending on values of fields set values of combo and text boxes which are on same form this button is located. 

 

TIA.

0 Likes
Message 6 of 10

Ed__Jobe
Mentor
Mentor

That's still more related to how, not what. You can read an xls from AutoCAD. Why does it have to be done from Inventor? What process are you trying to accomplish that require using Inventor? Although, you might be able to open a form in Inventor, AutoCAD VBA can't pass control over to the other app. It's like it doesn't have a visa to enter another country. All you can do is stand at the border and ask the other app to do it for you, and some things it can't do. Describe what you need. For example, "I need to use data from xl to modify a part's iProperties". Then we can tell you how to do it.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 7 of 10

floccipier
Advocate
Advocate
We have elaborate configurators in Autdodesk Inventor that would "create assemblies" (This is what is required) as per selected options on forms. As of now we have been looking at AutoCad layouts and entering those values manually. I devised a way to export those values (from autocad) to excel and then press button and Inventor reads that information from excel and fills in forms. What I am trying to do is keep the Inventor VBA forms (and code linked with it ) same so that if someone still need to do it manually they would be able to it. I hope I have been able to explain what of my problem.

So going back to your explanation of other app and handing over control doesn't make sense to me because my rule is running few subs and then it fires up the VBA form. Also I have noticed that if I need to run any sub from AutoCAD I can do that in Inventor. But you sound like a person who knows his stuff so I would take it as that we can run VBA subs in Inventor from AutoCAD but can't perform click function?
0 Likes
Message 8 of 10

Ed__Jobe
Mentor
Mentor
Accepted solution

Well, that complicates the problem. You've invested in a process that has limitations.

 

Going back to the visa example, I can ask the border agent to deliver messages (run sub) for me, but he won't let me deliver the message in person (wait for mouse click) and I don't have time to wait. You see, each application has it's own process which uses threads and memory. VBA runs within an app's process and it can't control another app's resources, i.e. memory, events except for what the other app makes public. COM (the Microsoft technology/api for controlling apps programmatically that VBA uses) apps don't give up control of their process to another app. In VBA, it can show a form in it's own process and wait for the user to control it by responding to form events. But you don't have access to those events in another app's process. They're not public. COM is not designed to work this way.

 

In order to reuse the form you've made in Inventor, you have to think of a way to start/run it from Inventor and add the tasks that you're trying to run from AutoCAD. Since Inventor can open a dwg, can you do that and access the dwg layouts from Inventor?

 

You can also start the process in AutoCAD, save data in the dwg, an external file or the registry, and then ask the user switch to Inventor and pick up where AutoCAD left off, by reading in the data left by AutoCAD. Kind of sloppy, but it should work.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 9 of 10

floccipier
Advocate
Advocate
Thanks for explaining this to me. I have marked this as solution as I realise I had impossible riddle to solve anyway which brings me to point where I have to rethink about overall workflow. really appreciate your help and patience.
0 Likes
Message 10 of 10

Ed__Jobe
Mentor
Mentor

No problem. Come back if you have more questions.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes