Run rule through global form on shown document

Run rule through global form on shown document

jorrytDLRAV
Participant Participant
919 Views
4 Replies
Message 1 of 5

Run rule through global form on shown document

jorrytDLRAV
Participant
Participant

Hey all,

 

At my workplace we have created several rules and access these through the Global Forms.

This works almost flawless except for one minor issue.

 

When someone 'activates' a rule it is done via the pop-up. It will work along the lines like this:

-'click' Part and Assembly (Form with several rules opens)

-'click' create stp-file (rule is activated)

 

However when you want to create another stp-file from a different part (already opened) you need to close the pop-up. If you don't close the pop-up inventor will create another stp-file from the part the pop-up was activated from. 

 

Is there a way to solve above issue. I tried it with the following code but it does not work. 

 

	Filename = ThisDoc.PathAndFileName(False)
	oDoc = ThisApplication.ActiveDocument
	oDocToModify = ActiveDocument

 

Thanks in advance!

 

0 Likes
Accepted solutions (2)
920 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor
Accepted solution

Unfortunately, iLogic forms do operate that way.  Whichever document was open visibly and 'active' when the form was launched, that document will remain the focus of that Form until the Form is closed.  Are the target iLogic rules you are running from the global Form's 'local' rules (saved within the document(s)) or external rules?  Which terms you use to identify which document a rule is to target can make a big difference too.  Here is a link to one of my contribution posts that you may find helpful regarding the terms used to identify documents, and what they really point to.

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @jorrytDLRAV 

 

iLogic works on a document basis, so there's not a real good way to do this.

 

What I have done though, is to use something like this rule below, to create a parameter/list of all the open visible documents, then set up your form so that you can choose from the list and have your rule run on the selected document.

Curtis_W_0-1626179661524.png

 

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

 

Create/Refresh Open Files rule:

Dim oList As New ArrayList

oList.Clear
For Each oDoc In ThisApplication.Documents.VisibleDocuments
	If Not oDoc.DocumentType = _
		DocumentTypeEnum.kDrawingDocumentObject Then
		oList.Add(IO.Path.GetFileName(oDoc.fullfilename))
	End If
Next
oList.Sort

'check For Parameter And create If Not found
Try
	oTest = Parameter("OpenFiles")
Catch
	' Get the UserParameters collection
	Dim userParams As UserParameters
	userParams = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters
	oParam = userParams.AddByValue("OpenFiles", oList(0), UnitsTypeEnum.kTextUnits)
End Try

MultiValue.List("OpenFiles") = oList

 

add something like this to your STEP file rule, other rules you want to run on the selected list item:

Dim oDoc As Document
For Each oDoc In ThisApplication.Documents.VisibleDocuments
	oName = IO.Path.GetFileName(oDoc.FullFileName)
	If parameter("OpenFiles") = oName Then
		oDocToProcess = oDoc
		oSTEPname = IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName) & ".stp"
		Exit For
	End If
Next

If oDocToProcess Is Nothing Then Return 'exit rule if this is nothing

'the rest of your STEP file rule here
'using oDocToProcess & oSTEPname where needed.....

 

EESignature

0 Likes
Message 4 of 5

jorrytDLRAV
Participant
Participant

Thanks for your quick answer! 

I already had a feeling that it was just the way Inventor works.

The rules we activate are external rules stored on a server. 

 

Your contribution is very helpful, it adds a bit of clarity to all the different references. 

0 Likes
Message 5 of 5

jorrytDLRAV
Participant
Participant

Thanks! I'l have look and will try to implement it, in to the current workflow. 

0 Likes