Showing posts with label formulas. Show all posts
Showing posts with label formulas. Show all posts

Friday, April 29, 2016

Controlling a Solid Form with a Visible Parameter

Here's a video trip back to a basic family editing concept. It describes two solids, a cube and sphere. I assign parameters to their Visible parameter and then show how we can use a formula to toggle one of them on/off and using Family Types to manage them. This works fine for solids, voids are another matter...and the subject of a later video.


Friday, April 17, 2015

Revit MEP - Circuit Length Calculation

I received an email asking if I thought it would be possible to use a Line Based family to calculate wire length for circuiting purposes. It was prompted by reading an earlier post about using them for Egress Path calculation and documentation. I think it's a reasonable approach for Egress Paths because there is no such tool or concept already in Revit.

Electrical circuits on the other hand do calculate their length already, granted it does so simplistically. It combines the X/Y/Z distances of the devices from the panel (and each other) to arrive at a total circuit length.


A friend some years ago sent me a PDF that showed a bunch (a couple shown above) of different equipment and device layout schemes he did to better understand how Revit arrives at a value for Circuit Length. What it shows is that Revit does nothing to factor in obstacles which force the wiring to go up or down or around the things that are more than likely going to increase the total circuit length.

To be fair...how could it really? How detailed is the model? How long do we want the software to interrogate the model, the linked models to do a better job? It's a bit like requiring all conduit to be modelled, even 3/4" conduit feeding single gang boxes in a wall when there isn't a single stud in the model. Like with so many things in life, it's about context.

It's one thing to put a single gang box on a wall to indicate one is required here and another thing entirely to run conduit to all the way to it when you can't be sure it can really go there. Or like showing a pair of outlets back to back on a demising wall in a residential project where fire rating and sound attenuation would require them to be separated by a minimum distance.

Some things are still conceptual (schematic) in nature even in fairly detailed models. If we start modeling every stud then perhaps it becomes more reasonable to expect more system detail too. Then again if I have to create a run of (15) 3/4" conduits across a wall or ceiling I probably ought to model that situation because it's going to take up a lot of space and everyone else ought to be aware of it.

It's also been my observation that no matter how good software gets at a task there are always outliers that dismiss its results as still wrong. That written, it does matter and Revit should improve how it does calculations and how much say we have in the outcome because the length it calculates is also used internally to contribute to other calculations like wire sizing and voltage drop.

Setting aside how circuit length should be calculated (it might surprise you to know that engineers don't always agree on this), I'd consider this approach if my task was to determine how much wire was needed, a little closer to actual requirements than might show up in the circuit properties. I'd create a schedule focused on Electrical Circuits.


What you see above: I created a couple panels and added a bunch of duplex outlets. I assigned them to circuits. The schedule's second column is Revit's calculated length, no more effort on my part than placing devices, creating circuits and choosing a panel.

I sorted the schedule by Panel and then Circuit, provided a header for Panel and footer for totals. I added a parameter for Length Factor (a number) and then a Calculated Parameter for Total Estimate (a length) which uses a formula of Length Factor * Calculated (column 2).

Then I consider each circuit's circumstance and enter in a factor that increases or decreases Revit's own calculation according to how easy or hard the actual wire run or routing will be...or at least what I think it will be. A factor of 2 doubles the length etc. This calculation doesn't factor into load calculations like for Voltage Drop...but then neither would using a line based family.

This doesn't account for situations that might share a neutral (or ground) or runs that are comprised of individual conductors in conduit (like THHN or THWN) or a wiring combined into a common jacket like Cerro's NMB (a typical household wiring product).

That's the risk/difficulty of automatic calculations, the closer you examine situations the more outliers there are. It can be a bit like arguing about something being 99.6 percent correct. If it costs another $1000 to get to 99.9 or 100%...is that difference worth it?

Saturday, March 07, 2015

IF Formulas and Notepad

A good tip was shared (by Josephpeel) at RFO the other day. If you use a Tab or Line Break in Notepad to make it easier to understand a lengthy conditional formula they won't affect the formula when you paste it into Revit.


Just make sure you put the closing parenthesis on the last line, as shown in the image. Revit doesn't seem to understand the copy/paste formula properly if you put them on their own line (at least that's my finding).

Monday, December 01, 2014

Setting Yes No Parameters with Formulas

Peter boards a train in Philadelphia bound for NY. Joe boards a train in NY bound for Philadelphia. If both trains... oh I don't care when their trains pass one another. Next question?

I want Revit to automatically check a Yes/No parameter but only when two other parameters are checked already. I read a post at RFO asking how to accomplish this. That member's issue was Revit complaining about inconsistent units, as it does. I replied that Revit doesn't accept 1 or 0 as a valid true/false value. The formula was written like this for parameter C:

if (and (A,B), 1, 0)


Since Revit doesn't like the 1 or 0 used in that formula we can use this instead:

and(A,B)

Revit reads that as, "I (Revit) can only check C if both A and B are checked too". In the Family Types dialog it looks like this.


If I'd like the opposite to happen it looks like this instead:

not(and(A,B))

Revit now reads it as, "I (Revit) can only un-check C if A and B are both checked too." In the Family Types dialog it looks like this.


Greg replied (in the RFO thread) that the formula would accept valid math statements for the true or false result. That means that the formula could be written like this, using the original formula above.

if (and (A,B), 1=1, 0=1)

It looks like this in the Family Types Dialog.


Either approach provides the same end result. Programmers often compete to write the leanest code, complete a task or tasks with the fewest instructions, fewest lines of code. My formula is leaner code but not by much. Regardless, I think it does help to see different solutions to help us solve the problems we encounter later.

Thursday, October 16, 2014

Parameters with Math Characters

Kudos to GMcDowellJr at RevitForum.org for paying attention. I missed it entirely. We've been careful to warn people not to include math characters in their parameters names for so long that I just don't ever try to do it.

At some point in the recent past (my testing shows beginning with Revit 2014) Revit started reconciling the issue for us with these brackets [ ]. Just wrap your rogue parameter name using math characters with those brackets and Revit won't mind anymore.

Revit will even add them (the brackets) for us if we rename a parameter to include math symbol(s). For example, in the following image these parameters and the formula are fine.


Then I changed my parameter name and Revit put the brackets in the formula for me.


When I try this in Revit 2013 it doesn't mind changing a parameter name to include a math symbol if it didn't have one originally. If I try to create a new parameter with a math character and use it in a formula then I get the familiar warning. If I add the brackets myself, no difference. In 2014 and 2015 the brackets start working and get added to a formula for us, when necessary.


I don't recall The Factory ever taking credit for this change, a nice subtle compensation for parameter naming.

Saturday, April 19, 2014

Fun Formulas

Saw this via Twitter. Kirklyn provided an example of practical formulas with Revit. You may not need Revit to make this kind of decision for you but the logic can be applied to other decision making. Do you want a sandwich?

Saturday, December 15, 2012

Illegal Parameter Names

It is fairly well understood that we can, but should not, use characters in parameter names that compete with Revit's own calculations. These include the addition (+), subtraction (-), multiplication (*) and division (/) symbols to name a few.

We also need to be careful to not use the specific function names either such IF. IF is the same as iF or If as far as Revit is concerned, though normally it is case sensitive.

When creating parameters use names that are not going to confuse Revit's own mathematical and conditional functions.

Tuesday, November 27, 2012

Rounding Length Values

When you create formulas in the Family Editor or perhaps in a schedule you can use the relatively new Round, Roundup and Rounddown options. They are designed to be used for unitless values. How often do we use unitless values? Click if you want to read the info at Autodesk's WikiHelp.

The other night I wanted to divide a panel height but round off the result. Take a door panel that has 6 lites that are defined by equal height from the top of the panel for example. One approach would be to just make the spacing equal. In this case the last lite is where the "slop" is supposed to go by making the upper lites equal in size. This means that the last lite is a little different size but then the bottom rail can be changed regardless of the lite sizes, without altering them.

The formula ended up looking like this:


In plain English, I add the top and bottom rail height together, subtract that from the panel height, divide by the number of lites. The rounding is applied to that result and divided by the desired rounding unit (1") and finally to satisfy Revit's quirkiness multiply the result by 1" to redefine what the units are. A bit round about (pun intended) but got where I wanted to go in the end.

Quick tip: When you add a parameter, click Apply before trying to fill in a formula. Revit needs to "save" the parameter before you can start using a formula in it. You'll typically get a message: "Can't find solution for formulas for type", wrote about this back in 2009.

Wednesday, March 18, 2009

Dept. of Subtle - Family Editor Parameter and Formula

This is an "oldy" but "goody". When you add a new parameter in the Family Types dialog and then immediately attempt to use that parameter in a formula Revit generates this message.


To avoid this message just click APPLY or OK (which closes the Family Types dialog box) to commit the addition of the parameters to the family. Then return to the Family Types dialog and add your formula. You just need to let Revit get used to the new parameters first, then it will happily let you make the formulas you need.