- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Frist, I am not a programmer or even a designer in any way shape or form.
I have, like many, just copied and pasted after google searching to make various rules work for me. Currently I am trying to make a external rule that will have a button on the bar to activate it for either a part or sheet metal:
1. Create a custom parameter with a Multivalue text list of material types
2. Run a global form based on that parameter so the user selects the material type
3. Set that to the Parameters Value
4. Take the selected value and set it as the iProperty.Description field
After much searching and frankenstiening I have a code that is 90% there. It will create the parameter, run the form, update the parameter value based on the form selection...BUT it won't update it into the iproperty field. If it is run "Fresh" (no parameter listed) the iproperty field will end up being blank OR have the generic selection listed (depending on lines of code are active). If I run a second time, it will update with the selection from the first run and put it into the iproperty field.
I assume it is something simple I am missing. i have tried to make a 2nd rule that would activate the form and then grab the value with no success as well. Any help would be greatly appreciated.
'Sets rule to work in open part file
Dim oPDoc As PartDocument = ThisDoc.Document
Dim oUParams As UserParameters = oPDoc.ComponentDefinition.Parameters.UserParameters 'Sets up customer paramter
Dim oUParam As UserParameter 'defines user parameter
' Creates Custom Parameter if not done.
Try
oUParam = oUParams.Item("MaterialType")
oUParam.IsKey = True 'MARK KEY AS ACTIVE-OK
Catch
oUParam = oUParams.AddByValue("MaterialType", "", UnitsTypeEnum.kTextUnits)
oUParam.IsKey = True 'MARK KEY AS ACTIVE-OK
'MultiValue.SetValueOptions(True, DefaultIndex := 0)
MultiValue.SetList("MaterialType", "Generic", "Commercial Brass", "Commercial Brass & Fixtures", "Commercial Faucet", "Corrosive Waste")
MultiValue.UpdateAfterChange = True 'Update MultiValue List
End Try
Dim oMaterialType As String = oUParam.Value
'End of Paramter Setup
'Section to create custom iProperty removed as doesn't appear to be needed for rule to function correctly
iLogicForm.ShowGlobal("Material Selector")
oMaterialType = oUParam.Value
iProperties.Value("Project", "Description") = oMaterialType 'iProperties.Value("Custom", propertyName1)
RuleParametersOutput()
InventorVb.DocumentUpdate()
iLogicVb.UpdateWhenDone = True 'Update When Complete
Solved! Go to Solution.