- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am attempting to open a document (chosen by the user) to then modifying using another iLogic rule. Documents open as expected, rules run as expected, however I am having an issue with what is treated as "active" for certain lines of code/rules.
For example:
MessageBox.Show(ThisApplication.ActiveDocument.FullDocumentName)
Will return the drawing that is active in Inventor, however:
customParameter = customParameters.AddByValue("DrawingType", "", UnitsTypeEnum.kTextUnits)
Modifies the drawing that was open when the initial rule was run. Additionally, this line will always fail with an error of "Error on line 14 in rule: CreateParams, in document: Drawing2 MultiValue: Could not find a parameter named: "DrawingType"" (In this Drawing2 was the document that was open when the rule was run)
'Rule "CreateParams"
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim customParameters As UserParameters = oDoc.Parameters.UserParameters
Try
dummyVariable = Parameter("DrawingType")
Catch
customParameter = customParameters.AddByValue("DrawingType", "", UnitsTypeEnum.kTextUnits)
'Parameter("DrawingType") = "Janus Drawing"
'set the list
MultiValue.SetList("DrawingType", "ValueA", "ValueB", "ValueC", "Test Doc")
End Try
When run in the drawing itself this works fine, however, when the drawing is opened by iLogic and then changed I encounter errors.
doc = ThisApplication.Documents.Open(item, True)
doc.Activate()
MessageBox.Show(ThisApplication.ActiveDocument.FullDocumentName)
iLogicVb.RunExternalRule(“CreateParams”)
Correctly identifies the drawing intended to be modified, however the parameter changes are seemingly applied to the wrong drawing.
I have tried:
-pausing before making the document active
-pausing after making the document active
-pausing before creating the parameter
-pausing after creating the parameter
-Removing all references to "this.doc" ( i read that this references the document running the rule) and replaced with "ThisApplication.Activedocument"
These pieces work individually, but now are having issues.
Edit: "ThisApplication.Activedocument" with "ThisDrawing.Document" addressed the customParam error
Solved! Go to Solution.