Are you trying to change the length of the lines, or just looking to have a property attached to the lines that would show the actual line length multiplied by some number?
Is the multiplier value random, based on the layer name, or is the multiplier tied to the AutoCAD Color Index value of the color of the layer? Your example follows that pattern (yellow = 2, green = 3, cyan = 4), but perhaps that is not always the case. (For that matter, Layer "Yellow" need not be set to color 2.)
The formula below (and in the attached file), is based on the multiplier value being manually assigned to each layer.
Select Case "[Layer]"
Case "Yellow"
multiplier = 2
Case "Green"
multiplier = 3
Case "Cyan","Factor4"
multiplier = 4
Case Else
multiplier = 1
End Select
RESULT = CDbl( [Length] * multiplier )
[Layer] and [Length] are properly formatted references to automatic properties included in the same Property Set.
The Select Case statement allows you to have as many individual Cases inside as necessary; you would want one for each multiplier. If multiple layers have the same multiplier, you can include them in one Case, if desired, as shown in the third case ("Cyan","Factor4"). The CDbl function is applied in the RESULT line to force the multiplied value to be treated as a real number. If you are using metric units, you may not need to do this. But for imperial units, if you want to have feet and inches format for the result, you will need to have the result be a real number. If it is a whole number, it will be treated as an integer without the CDbl, and integers will not get the feet and inches formatting.
Also note (in the attached drawing) that in the formula definition, in the Sample Values area, the Length property has its Property Data Format set to Standard-8. This is a copy of the out-of-the-box Standard Property Data Format, with the decimal precision increased to eight decimal places. Again, for metric users that do not add any non-numeric prefix or suffix to length values, you may be able to use the Property Data Format you apply to the Length Property (unless you want a higher precision for the calculation). Imperial users that are using a feet and inches Property Data Format for the Length property (architectural or engineering) will need to change the Property Data Format in the Sample Values area to something that gives just the raw number, without any non-numeric characters, in order for the multiplication to work.
David Koch
AutoCAD Architecture and Revit User
Blog | LinkedIn
