- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Ok I was trying to set the description of an assembly based on the length and width of a linked parameter. Here is the the code I used and was able to get the desired result I've also included screen shots. Problem is I have no idea why it work. I just started picking at the code that pops up when you press the '.'
Also I understand why I had to multiply the parameter by 2.54 due to that centimeter conversion thing, but would I still have to do that if the parameter was already in 'ft' .
One more thing is there a better way to do this so that it rounds down to the nearest fraction and have the dkLenft and dkWidft variable end up with the ft on it. The uom variable string value is "15.083 ft" but I end up losing the ft when I have round it to fraction. I would like it if the uom variable string value is "00 x/xx ft" format.
'[extracts the linear value (in)from a parameter converts to ft and assigns variable
' to write to the description
'Grabs the length parameter and converts to ft * by 2.54
uom = ThisDoc.Document.UnitsOfMeasure.GetStringFromValue(DP_LEN * 2.54, "ft")
'grabs the value from the uom variable and converts to fraction rounding down
' to the nearest 1/4 fractional unit apply it to a string variable
dkLenft = RoundToFraction(Val(uom.ToString()), 1 / 4, RoundingMethod.RoundDown)
'Grabs the Width parameter and converts to ft * by 2.54
uom = ThisDoc.Document.UnitsOfMeasure.GetStringFromValue(DP_WID*2.54, "ft")
'Grabs the value from the uom variable and converts to fraction rounding down
' to the nearest 1/4 fractional unit apply it to a string variable
dkWidft = RoundToFraction(Val(uom.ToString()), 1/4, RoundingMethod.RoundDown)
'MessageBox.Show(dkLenft & "ft x " & dkWidft & "ft", "Title")
iProperties.Value("Project", "Description")= _
"PLATE, FLR DECK, DIAMOND, " & dkLenft & "ft x" & dkWidft _
& "ft x " & "1/4"" Thk"
'] ----End description code
Solved! Go to Solution.