AutoCAD Architecture Customization
Welcome to Autodesk’s AutoCAD Architecture Customization Forums. Share your knowledge, ask questions, and explore popular AutoCAD Architecture Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Property Set Definition "if a number equals text"

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
alekzab
1095 Views, 6 Replies

Property Set Definition "if a number equals text"

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

6 REPLIES 6
Message 2 of 7
Keith.Brown
in reply to: alekzab

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.

Message 3 of 7
alekzab
in reply to: Keith.Brown

It worked! thanks a lot for your help!

 

AlexCat Very Happy

Message 4 of 7
Keith.Brown
in reply to: alekzab

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

Message 5 of 7
arctek
in reply to: Keith.Brown

Hi Keith, I was hoping you could help me with a similar situation. I apologize for posting here however I wasnt sure how to contact you directly. My situation is as follows: I would like to draw lines on specific layers and if found then multiply by the length(s) found on that layer by a specific value for example: Line on layer yellow is 10ft and if it exists it would multiple the length by 2. Layer green by 3, layer cyan by 4 etc. I am trying to use the formulas in the property set definitions but all i get is text in my schedule. I saw this post that is fairly similar to my idea however I still need help Thanks in advance Tony
Message 6 of 7
David_W_Koch
in reply to: arctek

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
EESignature

Message 7 of 7
arctek
in reply to: David_W_Koch

Hi David, Thanks for your quick reply. I only wanted to find the length of a line by layer and then if it resided on a particular then i would multiply by a factor. I followed the other example and I think I have it working 🙂 I kept on trying to use the IF function and I spent days on this but this example was much better 🙂 Thanks Tony

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost