Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Close iLogic Form with VBA or iLogic Rule

6 REPLIES 6
Reply
Message 1 of 7
ccoomes
2831 Views, 6 Replies

Close iLogic Form with VBA or iLogic Rule

Sorry if this has been answered, but I cannot find the topic or an answer I can understand how to get it to work.

 

I have recently asked the same question on this topic, but I realised the topic title was not very good so I have re-posted the same quesiton but with a better title to hopefully get some more answers.

 

Could someone please tell me how can I close an iLogic Form from either an iLogic Rule, or a VBA Rule (VBA is the Preferred method)?

 

Can you please give me the full code text required to close a form called "Mr Form" it would be greatly apprecitated.

 

Many Thanks.

6 REPLIES 6
Message 2 of 7
MegaJerk
in reply to: ccoomes

Out of curiosity, why would you want to close an iLogic form from anything other than the form? Is it that you simply want to get some values from the user before moving on? If so, why isn't it acceptable for them to simply hit the 'Apply' button on the forum once they are done entering the data into the form? 

It would be rather helpful if you could better describe the workflow that you are attempting to achieve. 




If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 3 of 7
ccoomes
in reply to: ccoomes

The reason I need to close a Modal form from VBA is as follows:

 

There is a Global Form that is opened in the Modal State so you cannot modify the drawing you are working on.

 

Within the Drawing there are a couple of Assembly Files that may need to be modified and have custom iProperties added.

 

We need a button that will close the Modal Form and open the files that need the custom iProperties added from an iLogic Rule.  I have the iLogic Rule to open the files, but Inventor crashes if you try to open another File from a Modal Form.

 

Yes, the user can manually close the Modal Form, then manually open the files, but the Idea of iLogic and VBA is to make it automated and thus reduce operator errors.

 

The Modal form CANNOT be opened in Non-Modal state due to the Short comings for Forms being linked to the file they were opened from, and NOT the Active Drawing you are looking at the time you press a button.

 

Hope this work flow makes sense...

 

Message 4 of 7
xiaodong_liang
in reply to: ccoomes

Hi ccoomes,

 

Your scenario is still strange to me. When I tested with a global form, it is Modeless. I have not found an option to pop out it as Modal. I also add one rule to the form. The rule opens one document. I ran the form, click the button which executes the rule, all works fine.

 

Could you provide a small demo file to let us better understand your question?

 

 

Message 5 of 7
MegaJerk
in reply to: xiaodong_liang

A modal form can be forced using the snippet of :

iLogicForm.ShowGlobal("Form 2", FormMode.Modal)

 

My guess is that the problem he's running into probably revolves around the way Inventor updates the parameters (that have been changed from a form) after the form is closed by the user, if the form has been opened from an iLogic Rule.

So as an example, say that we have two parameters - TestP1 and TestP2,  TestP1 for the user to enter a number and TestP2 = TestP1 * 2 

The following code would not show the correct updates to the parameters after they had been changed by the user from the form

iLogicForm.ShowGlobal("Form 2", FormMode.Modal)

MessageBox.Show(TestP1 & " -- " & TestP2)

 
After the user hit 'Done' on the user form, a message box with the values before the form was opened would be displayed.

However, there is a work around to this.

Opening a new rule has the effect of exposing those parameter updates to your newly opened rule.

iLogicForm.ShowGlobal("Form 2", FormMode.Modal)

iLogicVb.RunRule("Rule3")

 
RULE 3 : (Suppress This Rule!!!!)

MessageBox.Show(TestP1 & " -- " & TestP2)

 

I suspect that ccoomes could use that work around to expose any changes that have been made to the form, by the user, and of course open up any documents (as objects) that need to be changed based off of logic (now contained in a new rule), so that it doesn’t conflict with his drawing. This would also allow the user to use the ‘Done’ button provided by the iLogic Form.

At least I suspect that could be the case 😉



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 6 of 7
xiaodong_liang
in reply to: ccoomes

Hi ccoomes,

 

could you check if the comment  shared answered your question? 

Message 7 of 7
Anonymous
in reply to: xiaodong_liang

Hi

When using i logic to select title block it leaves the form open after selection. You normally expect it to close on selection...elegance...:)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report