Hi.... 2 things..!
1. I have been trying to get iTrigger working, but so far without luck.
I have tried..:
trigger = iTrigger0
and
i = iTrigger0 (i saw this in another rule somewhere.)
both in the beginng of my rule, but doesn't seem to make any diffrence.
im not sure if theres something in the rule that is preventing the trigger from working, it´s copy-pasted from this forum.!
2. Also, i would like to set a trigger event for this rule, but would like to have all the dialog boxes removed, when the rule is activated. I want the choises to be preset in the rule.! it should just be like a background process when the event triggers
Heres the rule i want to trigger..: so 1. iTrigger is not working and 2. remove dialog boxes when the rule is activated
trigger = iTrigger0
question = MessageBox.Show("Are you sure you want to change the units of measure?", _
"iLogic",MessageBoxButtons.YesNo)
If question = vbNo Then
Return
Else
'get input from user
oUnit = InputRadioBox("Select a units of measure type", "Metric", "Imperial", True, "ilogic")
'create precision value list
oPrecisionArray = New String(){0, 1, 2, 3, 4, 5}
'get input from user
oPrecision = InputListBox("Select the number of decimal places to use for the units of length display.", _
oPrecisionArray, 1, "iLogic", "Decimal Places ")
'example UnitsTypeEnum Enumerators
'kCentimeterLengthUnits = 11268
'kMillimeterLengthUnits = 11269
'kInchLengthUnits = 11272
'kKilogramMassUnits = 11283
'kGramMassUnits = 11284
'kLbMassMassUnits = 11286
If oUnit = True Then
'set to millimeter
oUOM_1 = 11269
'set to kilogram
oUOM_2 = 11283
Else
'set to inch
oUOM_1 = 11272
'set to pounds mass
oUOM_2 = 11286
End If
'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document
'set length units for the top level assembly
openDoc.unitsofmeasure.LengthUnits = oUOM_1
'set mass units for the top level assembly
openDoc.unitsofmeasure.MassUnits = oUOM_2
'set precision
openDoc.unitsofmeasure.LengthDisplayPrecision = oPrecision
'Look at all of the files referenced in the open document
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments
'format file name
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1)
Dim docFName As String
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)
'set length units
docFile.unitsofmeasure.LengthUnits = oUOM_1
'set mass units
docFile.unitsofmeasure.MassUnits = oUOM_2
'set precision
docFile.unitsofmeasure.LengthDisplayPrecision = oPrecision
'rebuild to update the display
docFile.Rebuild
Next
End If
'update all
iLogicVb.UpdateWhenDone = True
Hi LSA-skan,
The trigger issue was the update when done line at the end:
'update all
iLogicVb.UpdateWhenDone = True
This prevented the trigger parameter from updating at the top of the rule as needed, and therefore the rule would not run. Changing the line to update InventorVb.DocumentUpdate() resolves this.
I've removed the input message boxes in the code as well.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
trigger = iTrigger0
'set to millimeter
oUOM_1 = 11269
'set to kilogram
oUOM_2 = 11283
'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document
'set length units for the top level assembly
openDoc.unitsofmeasure.LengthUnits = oUOM_1
'set mass units for the top level assembly
openDoc.unitsofmeasure.MassUnits = oUOM_2
'set precision
openDoc.unitsofmeasure.LengthDisplayPrecision = oPrecision
'Look at all of the files referenced in the open document
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments
'format file name
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1)
Dim docFName As String
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)
'set length units
docFile.unitsofmeasure.LengthUnits = oUOM_1
'set mass units
docFile.unitsofmeasure.MassUnits = oUOM_2
'set precision
docFile.unitsofmeasure.LengthDisplayPrecision = 3
'rebuild to update the display
docFile.Rebuild
Next
'update all
InventorVb.DocumentUpdate()
Hi Curtis
The boxes are now removed..! Nice 1 kudos for that.!
However the iTrigger is still not doing anything. Is it becuase i have the rule in External, instead of In Document?
Which leads me to another thing.. i would like the rule and iTrigger to work for all my documents, both old and new ones...! is that possible?
/LSA-skan
Hi Curtis
When i use the code you posted it always sets the Decimal to 1, even though it is set to 3??!what is wrong?
/LSA-Skan