- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So I am trying to create some code that will allow me to assign custom iProperties and Parameters to components that have been exported from a Solid Body Model and put into an Assembly. The code I have found elsewhere on here and modified slightly measures the RangeBox in the X, Y, and Z directions and then assigns them to the appropriate Parameters. Then I have a long list of 'If' statements that assigns a custom iProperty if the thickness matches. This works for 90% of my parts but one specifically that will not work is the thickness of 0.8348. The code successfully applies the thickness to the parameter but when trying to assign the custom iProperty it does not recognize that as the thickness. I have pasted some code below to show how it works. Any suggestions for improvement or help on why only specific materials aren't working i would greatly appreciate it.
Beginning Code To Set Parameters:
oAdoc = ThisApplication.ActiveDocument oAcompdef = oAdoc.ComponentDefinition 'conversion factor cm to in oCF = 2.54 For Each oOcc In oAcompdef.Occurrences Dim custParamSet As Parameters custParamSet=oOcc.Definition.Document.ComponentDefinition.Parameters ' Set access to Custom and Default iProperties Dim customPropSet As PropertySet oX = Math.Abs(oOcc.definition.RangeBox.MaxPoint.X _ - oOcc.definition.RangeBox.MinPoint.X)/oCF oY = Math.Abs(oOcc.definition.RangeBox.MaxPoint.Y _ - oOcc.definition.RangeBox.MinPoint.Y)/oCF oZ = Math.Abs(oOcc.definition.RangeBox.MaxPoint.Z _ -oOcc.definition.RangeBox.MinPoint.Z)/oCF 'get middle number If oX > oY And oX < oZ Or oX > oZ And oX < oY Then oMiddle = oX GoTo Set_Width End If If oY > oX And oY < oZ Or oY > oZ And oY < oX Then oMiddle = oY GoTo Set_Width End If If oZ > oX And oZ < oY Or oZ > oY And oZ < oX Then oMiddle = oZ GoTo Set_Width End If Set_Width : Parameter(oOcc.Name,"WD") = Round(oMiddle,4) 'set length Parameter(oOcc.Name,"LG") = Round(MaxOfMany(oX, oY, oZ),4) 'set Thickness Parameter(oOcc.Name, "THK") = Round(MinOfMany(oX, oY, oZ), 4) MsgBox(String.Format("{0:N6} x {1:N6} x {2:N6} [in]", Parameter(oOcc.Name,"LG"), Parameter(oOcc.Name,"WD"), Parameter(oOcc.Name, "THK")))
If Then Statement that works
If Parameter(oOcc.Name, "THK") = 0.2363 Then iProperties.Value(oOcc.Name, "Custom", "RM_Properties") = "CELTEC 6 MM WHITE" End If
If Then Statement that does not work
If Parameter(oOcc.Name, "THK") = 0.8348 Then iProperties.Value(oOcc.Name, "Custom", "RM_Properties") = "PARTICLE BOARD 3/4 L/L" End If
Solved! Go to Solution.