Multiple windows when calling iLogicForm.Show() from external iLogic rule

Multiple windows when calling iLogicForm.Show() from external iLogic rule

fsdolphin
Collaborator Collaborator
1,270 Views
7 Replies
Message 1 of 8

Multiple windows when calling iLogicForm.Show() from external iLogic rule

fsdolphin
Collaborator
Collaborator

I have a local-form with four required text Fields for the user to enter. This form is called when a new document is created, if any of the four fields is empty the form shows up and it doesn't go away until all fields are filled in. This works fine if the form is called form a local iLogic rule but if I called the form from an external iLogic rule it kind of works but it behaves different. Let me explain it.

 

When the form is called from a local rule and all four fields are empty but the user only fills one of the fields and click Done, the form reappears which is exactly what I want. On the other hand, if the form is called from an external rule and all four fields are empty but the user only fills one and clicks Done, instead of reappearing the same window it creates a second window, and if the second time the user fills only one field again, a third window appears and so on, I know in a perfect world the user should fill in all of the fields and NOT click the Done button until then, but I need to account for all possible scenarios.

 

Any idea why just by moving my code to an external rule recreates the window?

 

Here is my iLogic Code:

 

SyntaxEditor Code Snippet

Sub Main
     checkFields()
End Sub

Private partNumber As String
Private description As String
Private project As String
Private designer As String

Function checkFields

    partNumber = iProperties.Value("Project", "Part Number")    
    description = iProperties.Value("Project", "Description")
    project = iProperties.Value("Project", "Project")
    designer = iProperties.Value("Project", "Designer")    
    
    Do Until String.IsNullOrWhiteSpace(partNumber) = False
        showForm()
        partNumber = iProperties.Value("Project", "Part Number")
        checkFields()
    Loop
    
    Do Until String.IsNullOrWhiteSpace(description) = False
        showForm()
        description = iProperties.Value("Project", "Description")
        checkFields()
    Loop
    
    Do Until String.IsNullOrWhiteSpace(project) = False
        showForm()
        project = iProperties.Value("Project", "Project")
        checkFields()
    Loop
    
    Do Until String.IsNullOrWhiteSpace(designer) = False
        showForm()
        designer = iProperties.Value("Project", "Designer")
        checkFields()
    Loop
    
End Function

Function showForm
    iLogicForm.Show("Required Fields Form", FormMode.Modal)
End Function

From

ValidationForm.png

 

 

Multiple Windows when Using External Rule

 

Inventor Forms.png

 

 

FYI -  The form is local.

 

 

0 Likes
Accepted solutions (1)
1,271 Views
7 Replies
Replies (7)
Message 2 of 8

Curtis_Waguespack
Consultant
Consultant

Hi fsdolphin,

 

I'm not sure why it's behaving that way, but I would suggest creating the form as a Global Form (external form), rather than a form that resides in the file. I'm not certain that doing so would resolve the issue, but it would be something to try, and seems appropriate for the type of task.

 

Note too that you can just copy the form from the internal forms pane and paste it to the Global Forms pane.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

Message 3 of 8

fsdolphin
Collaborator
Collaborator

@Curtis_Waguespack

 

EDIT: 

No, changing to a Global from didn't work. It looks like the rule needs to be local in order for it to properly work. I'm wondering if by calling my external rule form a local rule would fix the issue.

 

0 Likes
Message 4 of 8

fsdolphin
Collaborator
Collaborator
Accepted solution

Calling the external rule from a local rule did the trick. 

 

iLogicVb.RunExternalRule("myExternalRule")

 

 

@Curtis_Waguespack  Thanks a lot for your time 

0 Likes
Message 5 of 8

MechMachineMan
Advisor
Advisor

Here would be a slightly more explicit way to write the rule.

 

Also, there comes to be issues with using the iLogic iProperties("Project", "Project") call ( and similiar ones) because it defaults to pulling the iProperties from the file in which the rule is ran.

 

This can cause issues when running things as external rules, or as part of a rule just depending on what specific triggers you have set. Using ThisDoc.Document mimics that functionality, by explicitly grabbing the same document that the implicit iLogic calls would.

 

Sub Main
	oDoc = ThisDoc.Document
	
	Do Until FieldsAreCompleted = True
		iLogicForm.Show("Required Fields Form", FormMode.Modal)
	Loop
End Sub

Private oDoc As Document

Function FieldsAreCompleted()
	Dim oDTP As PropertySet
	oDTP = oDoc.PropertySets("Design Tracking Properties")
	
	If String.IsNullOrWhiteSpace(oDTP.Item("Part Number").Value) = True Or _
			String.IsNullOrWhiteSpace(oDTP.Item("Description").Value) = True Or _
			String.IsNullOrWhiteSpace(oDTP.Item("Project").Value) = True Or _
			String.IsNullOrWhiteSpace(oDTP.Item("Designer").Value) = True Then
		Return False
	Else
		Return True
	End If
End Function

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 6 of 8

fsdolphin
Collaborator
Collaborator

@MechMachineMan 

 

Interesting code, I will give it a try.

 

Questions...

 

Also, there comes to be issues with using the iLogic iProperties("Project", "Project") call ( and similiar ones) because it defaults to pulling the iProperties from the file in which the rule is ran.

 

 

1. If I understand your statement correctly it's not recommend to call iProperties.Value("Project", "Project") from an external rule, correct? I'm assuming this is fine when calling from local rules, correct?

 

2. It's calling Item().value the recommend way when working with external rules?

 

3. Where can I find more information on how PropertySets work? I see that a new PropertySet with the name of "Design Tracking Properties" was created but the name was never used so I'm interested in learning more bout it.

 

Thanks a lot

 

 

 

 

0 Likes
Message 7 of 8

MechMachineMan
Advisor
Advisor

Responses:

 

1. If I understand your statement correctly it's not recommend to call iProperties.Value("Project", "Project") from an external rule, correct? I'm assuming this is fine when calling from local rules, correct?

 

- The reason I recommend against using iProperties.Value is because I have gotten burned before by it.
- Imagine you have written a ton of nice rules that do a bunch of file editting, and this works fine when you run the rule in the document directly. One day, you decide you want to implement a bunch of these changes over a bunch of drawings... So you write a rule to iterate through a bunch of documents and run these rules.

- Now in the case that you weren't very particular about explicitly stating all of your document references in your "sub-rules", the results will be wonky because the original document the rule was run from is the the document that appears on your screen, and possibly not the one you actually want changed.

 

- Thinking back.... I think my issue with iProperties was that I would always use ActiveDoc and that would cause issues when trying to batch run rules in many documents.

- the iLogic calls should be fine... except for when you move on to using ApprenticeServer through excel to modify things, or even vba. You would have to import the iLogic Addin API/Objects to be able to use the calls.

 

 

2. It's calling Item().value the recommend way when working with external rules?

 

- The Item.Value is just how iProperties like to be called off to get the value. You can find the documentation in the Inventor API Documentation, which is now available online! 

 

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-B800F2A6-D427-4E2A-A711-6B69BA6BFA98

 

- *This api help is also found through:

 

- "C:\Users\Public\Documents\Autodesk\Inventor 2017\Local Help\admapi_21_0.chm" or similiar for your system/installs.

 

3. Where can I find more information on how PropertySets work? I see that a new PropertySet with the name of "Design Tracking Properties" was created but the name was never used so I'm interested in learning more bout it.

 

- Various blogs, google-fu, and the Inventor Documentation.

 

- http://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html

 

 

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 8 of 8

fsdolphin
Collaborator
Collaborator

Thanks a lot.

0 Likes