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

Parameter Formula Conditional Statements

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
claycalhoun
5874 Views, 10 Replies

Parameter Formula Conditional Statements

I created a generic model family breaker symbol to be used for a single line diagram. I have 3 common text parameters attached to labels. One is used to express a breaker size (a set value such as 100A). Another is used to express how many wires are conductors (3 or 4).  I want the final parameter to automatically populate a non-calculated value (such as 1, 2, 3...Etc.) based on what I enter for the breaker size and wire parameters. The purpose for this final parameter is to represent a number on a schedule of feeder sizes. I have tried familiarizing myself with conditional statements in Revit, but when I paste the code it comes back as an error saying "Improper use of boolean expressions." I have attached a txt. file with my formula. Any help would be appreciated!

10 REPLIES 10
Message 2 of 11
CoreyDaun
in reply to: claycalhoun

The missing component to your formula is the final ELSE statement (where I placed the "XXXX": right after the "34").

 

IF ( AND ( Breaker = 60A , Wires = 3 ) , 1 , 
IF ( AND ( Breaker = 60A , Wires = 4 ) , 2 , 
IF ( AND ( Breaker = 70A , Wires = 3 ) , 3 , 
IF ( AND ( Breaker = 70A , Wires = 4 ) , 4 , 
IF ( AND ( Breaker = 100A , Wires = 3 ) , 5 , 
IF ( AND ( Breaker = 100A , Wires = 4 ) , 6 , 
IF ( AND ( Breaker = 125A , Wires = 3 ) , 7 , 
IF ( AND ( Breaker = 125A , Wires = 4 ) , 8 , 
IF ( AND ( Breaker = 150A , Wires = 3 ) , 9 , 
IF ( AND ( Breaker = 150A , Wires = 4 ) , 10 , 
IF ( AND ( Breaker = 175A , Wires = 3 ) , 11 , 
IF ( AND ( Breaker = 175A , Wires = 4 ) , 12 , 
IF ( AND ( Breaker = 200A , Wires = 3 ) , 13 , 
IF ( AND ( Breaker = 200A , Wires = 4 ) , 14 , 
IF ( AND ( Breaker = 225A , Wires = 3 ) , 15 , 
IF ( AND ( Breaker = 225A , Wires = 4 ) , 16 , 
IF ( AND ( Breaker = 250A , Wires = 3 ) , 17 , 
IF ( AND ( Breaker = 250A , Wires = 4 ) , 18 , 
IF ( AND ( Breaker = 300A , Wires = 3 ) , 19 , 
IF ( AND ( Breaker = 300A , Wires = 4 ) , 20 , 
IF ( AND ( Breaker = 350A , Wires = 3 ) , 21 , 
IF ( AND ( Breaker = 350A , Wires = 4 ) , 22 , 
IF ( AND ( Breaker = 400A , Wires = 3 ) , 23 , 
IF ( AND ( Breaker = 400A , Wires = 4 ) , 24 , 
IF ( AND ( Breaker = 500A , Wires = 3 ) , 25 , 
IF ( AND ( Breaker = 500A , Wires = 4 ) , 26 , 
IF ( AND ( Breaker = 600A , Wires = 3 ) , 27 , 
IF ( AND ( Breaker = 600A , Wires = 4 ) , 28 , 
IF ( AND ( Breaker = 800A , Wires = 3 ) , 29 , 
IF ( AND ( Breaker = 800A , Wires = 4 ) , 30 , 
IF ( AND ( Breaker = 1000A , Wires = 3 ) , 31 , 
IF ( AND ( Breaker = 1000A , Wires = 4 ) , 32 , 
IF ( AND ( Breaker = 1200A , Wires = 3 ) , 33 , 
IF ( AND ( Breaker = 1200A , Wires = 4 ) , 34 , XXXX ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )

 

An important part of your scenario here is what do you want to happen if a user inputs an invalid value, such as 110A? Or maybe 5 Wires? The value "XXXX" above is what will be returned if the inputted values do not match any of the specified conditions.

Corey D.                                                                                                                  ADSK_Logo_EE_2013.png    AutoCAD 2014 User  Revit 2014 User
──────────────────────────────────────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate to further enhance these forums. Thank you!
Message 3 of 11
claycalhoun
in reply to: CoreyDaun

@

Message 4 of 11
CoreyDaun
in reply to: claycalhoun

Right - I assume that your parameter was an Integer Type, so "XXXX" is not a valid input. I was just using that as a placeholder because I think that there may be a better way to accomplish this. That's why I asked what you would like to happen if the user inputs an "invalid" value. Also, would there be any other possible entry for Wires, besides 3 or 4?

Corey D.                                                                                                                  ADSK_Logo_EE_2013.png    AutoCAD 2014 User  Revit 2014 User
──────────────────────────────────────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate to further enhance these forums. Thank you!
Message 5 of 11
claycalhoun
in reply to: CoreyDaun

@CADastohpe,

If the user enters an invalid entry I would like it to return "--", two simple dashes. And I am only needing there to be a 3 or 4 wire option here, nothing else.

Message 6 of 11
CoreyDaun
in reply to: claycalhoun

Since this parameter is an Integer Type, returning a text value is not possible. You'll receive the same error that you did when you copy/pasted the previous formula into Revit (with the "XXXX").

 

I think the better way to go here would be to restrict the user's input. This can be done for both options (provided that you would like the user to choose only from the provided list of breaker sizes as well). My recommendation regarding the Wires would be to instead use the following parameters:

Parameter   Name Type Formula
Wires 3 Yes/No  
Wires 4 Yes/No = not ( Wires 3 )

 

This will restrict the user to either enabling or disabling the "3 Wires" option, and will force the "Wires 4" option to always be the inverse value.

Corey D.                                                                                                                  ADSK_Logo_EE_2013.png    AutoCAD 2014 User  Revit 2014 User
──────────────────────────────────────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate to further enhance these forums. Thank you!
Message 7 of 11
claycalhoun
in reply to: CoreyDaun

Thank you for the tip on the wires, but I am still confused on how I can use this as a formula or even express the formula properly. Based on my breaker size and wires is there a valid formula I can use to return either text or an integer? I think what Revit is having trouble with is the use of multiple embedded AND statements, although I could be wrong.

Message 8 of 11
CoreyDaun
in reply to: claycalhoun

Regarding the Breaker, I would suggest setting up a pull-down selection method, in lieu of relying on a typed-in value. I'll walk though the process of setting this up:

 

1. Open a new Generic Annotations Family. Leave it blank, Purge Unused, and load it into the Host Family as-is.

 

2. In the Host Family, in the Project Browser, rename that Family and it's Type each to "60A". Repeat this process for each acceptable size. Note that the order of items on this pulldown will be determined by the order in while the Families were loaded into the host, and it cannot be changed without unloading and reloading all of the Families over again.

 

3. Open Family Types, and create a new Parameter. Name it something like "B60", leave it as a Type Parameter, and set its Type to "<Family Type...>". In the following dialog, select "Generic Annotations". Set its value to "60A" using the pulldown. Repeat this for each acceptable size. These parameters will act as a "Reference" Parameter, since you cannot directly reference <Family Type> values in a formula.

 

4. Create one more <Family Type...> Parameter for Breaker, which will act as the user input and will restrict the selection to those you have specified.

 

I'll show you how to create a formula for that Integer Parameter based off of the user inputs in a separate post...

Corey D.                                                                                                                  ADSK_Logo_EE_2013.png    AutoCAD 2014 User  Revit 2014 User
──────────────────────────────────────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate to further enhance these forums. Thank you!
Message 9 of 11
CoreyDaun
in reply to: claycalhoun


claycalhoun wrote:

"Thank you for the tip on the wires, but I am still confused on how I can use this as a formula or even express the formula properly. Based on my breaker size and wires is there a valid formula I can use to return either text or an integer? I think what Revit is having trouble with is the use of multiple embedded AND statements, although I could be wrong."


In general, Revit is not very powerful in terms of formulaic capabilities. There is no way for a Parameter to return different Types of Values. In order to comply with your original formula, your third parameter must be a Text Type parameter (in lieu of an Integer) to permit the "--" value.

 

Revit can handle virtually an unlimited number of nested functions, so the multitude of AND statements is not a problem.

Corey D.                                                                                                                  ADSK_Logo_EE_2013.png    AutoCAD 2014 User  Revit 2014 User
──────────────────────────────────────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate to further enhance these forums. Thank you!
Message 10 of 11
CoreyDaun
in reply to: claycalhoun

See the attached .rfa file (Revit 2013) as a demonstration of the setup that is achieved by the methods as described above. Load this into a Project and see what you think.

 

To work in conjunction with the checkbox method for Wires, I create a "Reporting Wires" Integer Parameter that checks the status of "Wires 3" and returns 3 if it is "YES" and 4 if it is "NO".

 

The "Reporting Integer" is calculated using the formula below, which first checks the selected Breaker Size and then checks the number of Wires with a nested IF/THEN/ELSE statement. The final line does not check for "1200A" because it is the final ELSE statement.

 

IF ( Breaker = B60 , IF ( Wires 3, 1, 2),
IF ( Breaker = B70 , IF ( Wires 3, 3, 4),
IF ( Breaker = B100 , IF ( Wires 3, 5, 6),
IF ( Breaker = B125 , IF ( Wires 3, 7, 8),
IF ( Breaker = B150 , IF ( Wires 3, 9, 10),
IF ( Breaker = B175 , IF ( Wires 3, 11, 12),
IF ( Breaker = B200 , IF ( Wires 3, 13, 14),
IF ( Breaker = B225 , IF ( Wires 3, 15, 16),
IF ( Breaker = B250 , IF ( Wires 3, 17, 18),
IF ( Breaker = B300 , IF ( Wires 3, 19, 20),
IF ( Breaker = B350 , IF ( Wires 3, 21, 22),
IF ( Breaker = B400 , IF ( Wires 3, 23, 24),
IF ( Breaker = B500 , IF ( Wires 3, 25, 26),
IF ( Breaker = B600 , IF ( Wires 3, 27, 28),
IF ( Breaker = B800 , IF ( Wires 3, 29, 30),
IF ( Breaker = B1000 , IF ( Wires 3, 31, 32),
IF ( Wires 3, 33, 34)))))))))))))))))

 

My apologies if I'm throwing too much out there at once...

Corey D.                                                                                                                  ADSK_Logo_EE_2013.png    AutoCAD 2014 User  Revit 2014 User
──────────────────────────────────────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate to further enhance these forums. Thank you!
Message 11 of 11
claycalhoun
in reply to: CoreyDaun


CADastrophe wrote:

See the attached .rfa file (Revit 2013) as a demonstration of the setup that is achieved by the methods as described above. Load this into a Project and see what you think.

 

To work in conjunction with the checkbox method for Wires, I create a "Reporting Wires" Integer Parameter that checks the status of "Wires 3" and returns 3 if it is "YES" and 4 if it is "NO".

 

The "Reporting Integer" is calculated using the formula below, which first checks the selected Breaker Size and then checks the number of Wires with a nested IF/THEN/ELSE statement. The final line does not check for "1200A" because it is the final ELSE statement.

 

IF ( Breaker = B60 , IF ( Wires 3, 1, 2),
IF ( Breaker = B70 , IF ( Wires 3, 3, 4),
IF ( Breaker = B100 , IF ( Wires 3, 5, 6),
IF ( Breaker = B125 , IF ( Wires 3, 7, 8),
IF ( Breaker = B150 , IF ( Wires 3, 9, 10),
IF ( Breaker = B175 , IF ( Wires 3, 11, 12),
IF ( Breaker = B200 , IF ( Wires 3, 13, 14),
IF ( Breaker = B225 , IF ( Wires 3, 15, 16),
IF ( Breaker = B250 , IF ( Wires 3, 17, 18),
IF ( Breaker = B300 , IF ( Wires 3, 19, 20),
IF ( Breaker = B350 , IF ( Wires 3, 21, 22),
IF ( Breaker = B400 , IF ( Wires 3, 23, 24),
IF ( Breaker = B500 , IF ( Wires 3, 25, 26),
IF ( Breaker = B600 , IF ( Wires 3, 27, 28),
IF ( Breaker = B800 , IF ( Wires 3, 29, 30),
IF ( Breaker = B1000 , IF ( Wires 3, 31, 32),
IF ( Wires 3, 33, 34)))))))))))))))))

 

 

My apologies if I'm throwing too much out there at once...


Excellent Solution! Thank you for the detailed explanation. I like to know what is happening inside the Revit process so this really helps me out with future family development! Your family was great as an example also.

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

Post to forums  

Rail Community


Autodesk Design & Make Report