- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
We model some parts that are purchased as 50mm thick rolls (insulation) and need to display the sq meter of the part. These parts vary in size and shape. To do this, we have used the parts volume and divided it by 50(the thickness of the insulation). The issue comes with setting this in the "Bill of Materials" tab under "Base Quantity".
The code is to create the parameters; however, we need to go into the parameter and change the units to "m" before we are able to select the parameter from the pull-down list under "Base Quantity". Once it is selected, close out of the Doc settings and go back to parameters and switch the units back to m^2. Then, back to "Base Quantity," verify the parameter is selected, then use the formula button to select the parameter again. This seems to be the only way to get this to work.
Disclosure:
I am not a coder, so I am sure there are several issues with the code below. Is there a better way to achieve the end goal?
Any suggestion would be greatly appreciated!
Two different codes to achieve this:(same issue with both)
1.
Parameter("VOL") = iProperties.Volume
Parameter("AREA_INS") = iProperties.Volume/50.0 mm
iProperties.Value("Custom","MATERIAL LIST DESCRIPTION") = "50mm BATTS"
2.
' Check if "VOL" exists
Dim found As Boolean = False
For Each param As Parameter In ThisDoc.Document.ComponentDefinition.Parameters.UserParameters
If param.Name = "VOL" Then
found = True
Exit For
End If
Next
' Create VOL if missing, using unit string instead of enum
If Not found Then
ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddByValue("VOL", 1, "m^3")
End If
' Assign volume to VOL
VOL = iProperties.Volume
' Check if "AREA_INS" exists
Dim found2 As Boolean = False
For Each param As Parameter In ThisDoc.Document.ComponentDefinition.Parameters.UserParameters
If param.Name = "AREA_INS" Then
found2 = True
Exit For
End If
Next
' Create AREA_INS if missing, using unit string instead of enum
If Not found2 Then
ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddByValue("AREA_INS", 1, "m^2")
End If
' Assign area to AREA_INS
AREA_INS = iProperties.Volume/50 mm
' Assign New Parameters
Parameter("VOL") = iProperties.Volume
Parameter("AREA_INS") = iProperties.Volume/50 mm
iProperties.Value("Custom","MATERIAL LIST DESCRIPTION") = "50mm BATTS"
Solved! Go to Solution.