Hi All,
I having problems trying to resolve a formula in the property definitions. I have a field that has USAGENO 060, 050 that the user inputs. But I would like to auto populate another field ROOMNAME with its corresponding text, to reduce input and avoid user error. The number always equals a room name as shown below.
060=Office
050=Lobby
I tried on the ROOMNAME field this but its not working, anyone know what is wrong. My field is set to formula.
=IF[USAGENO]=060,"Office",IF[USAGENO]=050,"Lobby"))
Thank you.
alex
Solved! Go to Solution.
Solved by Keith.Brown. Go to Solution.
This is how i would do it.
Select Case "[USAGENO]"
Case "060"
RESULT = "Office"
Case "050"
RESULT = "Lobby"
End Select
Notice the quotes around [USAGENO]. This will cast it to a string. Also the quotes in the Case statement. This also casts the values to a string. I prefer case statements as it allows for easy upgrades in the future if you need to add more room names.
Hope this helps.
I forgot to add this portion of it. I always put an else statement in my select case statement as shown. you could leave the quotes empty if you don't want to output a message but I always find it good coding practice to have in it there at least.
Select Case "[USAGENO]"
Case "060"
RESULT = "Office"
Case "050"
RESULT = "Lobby"
Case Else
RESULT = "** ERROR - Usage Number Not Found! **"
End Select
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.