See the top rated post in this thread. Click here

Results 1 to 5 of 5

Thread: Even/Odd detection formula for use in families

  1. #1
    Member Adrian Esdaile's Avatar
    Join Date
    2006-03
    Location
    Sydney, Australia
    Posts
    20
    1 Did you find this post helpful? Yes

    Lightbulb Even/Odd detection formula for use in families

    Hi All,

    I don't know if this has been done or not, or indeed if anyone else has ever wanted such a thing...

    I have created a one-line formula that provides a boolean test (yes/no) of whether an input value is even or odd, for values greater than 1.

    Create two parameters - one is the value you want to test. This must be an integer, so use either the integer class or use round(x) on another value. Let's use a parameter type integer, and call it TEST.

    The second parameter is your boolean (yes/no) - call the parameter EVEN

    Insert this formula in the formula field for the EVEN parameter:

    Code:
    (rounddown(TEST / 2)) - (rounddown((TEST - 1) / 2)) > 0
    If the value of TEST is an even number, EVEN will be TRUE (ticked/yes); if TEST is an odd number, EVEN will be FALSE (unticked/no).

    Where this might be useful:

    I have used this in parametric door families for folder doors, to provide a boolean value to display the fixed leaf if an odd number of doors is used. I have also used it in shelving systems to allow a blank panel to appear when the shelves are odd. You might have some other uses for it.

    Note that this will produce erratic results if provided with negative numbers, 0 or 1 as an input. This can be avoided through use of clever IF statements, and is left as an exercise for the reader.

    How it works:

    The formula tests the difference between a given value X/2 and (X-1)/2, with both values rounded down before the difference is performed. For an example value of 3 the equation is thus:

    Code:
    Input values:  (3/2)  - (3-1/2) = (3/2)  -  (2/2)
    
    Result values:   (1.5)  -  (1)
    
    Rounded Down:   (1)  -  (1)  = 0 THEREFORE X is ODD where X=3

    For an example value of 42:

    Code:
    Input values:  (42/2)  - (42-1/2) = (42/2)  -  (41/2)
    
    Result values:   (21)  -  (20.5)
    
    Rounded Down:   (21)  -  (20)  = 1 THEREFORE X is EVEN where X=42
    Adrian Esdaile : Revit Systems Manager : Woolworths Limited


    Union Representative
    Amalgamated Union of Philosphers, Sages, Luminaries and Other Professional Thinking Persons.
    Sector ZZ9-Plural-Z-Alpha Chapter

  2. #2
    AUGI Addict
    Join Date
    2001-07
    Location
    Phoenix, AZ
    Posts
    1,003
    0 Did you find this post helpful? Yes

    Default Re: Even/Odd detection formula for use in families

    Clever! Have to keep this one around!

  3. #3
    I could stop if I wanted to Limbatus's Avatar
    Join Date
    2010-04
    Location
    Gamehendge
    Posts
    249
    0 Did you find this post helpful? Yes

    Default Re: Even/Odd detection formula for use in families

    i remember an AU webinar from c2009 called something like fuzzy math for revit that had another rounding solution. yours seems simpler though. nice work!

  4. #4
    I could stop if I wanted to Limbatus's Avatar
    Join Date
    2010-04
    Location
    Gamehendge
    Posts
    249
    0 Did you find this post helpful? Yes

    Default Re: Even/Odd detection formula for use in families

    http://aucache.autodesk.com/au2008/s...-1-Handout.pdf

    heres the course handout. I guess it was AU08. the video was pretty interesting.

  5. #5
    Member
    Join Date
    2010-06
    Posts
    16
    0 Did you find this post helpful? Yes

    Default Re: Even/Odd detection formula for use in families

    You made my folding door, odd-even panel number finally work in a simple way
    I wish I could buy you a drink as thank you.
    Just made my day (a sad life of a BIM manager when this stuff makes his day)

Similar Threads

  1. 2013: How to use this Formula,"Formula That Returns Strings"?
    By mike99 in forum Revit Architecture - General
    Replies: 4
    Last Post: 2013-01-09, 05:28 AM
  2. Collision Detection
    By stimmo520 in forum Revit - API
    Replies: 2
    Last Post: 2010-10-26, 01:03 PM
  3. Interference Detection 09
    By BigBadBIM in forum AMEP General
    Replies: 3
    Last Post: 2009-02-28, 05:53 AM
  4. Formula Parameters in Shared Families
    By phizzman in forum Revit Architecture - Families
    Replies: 9
    Last Post: 2008-03-24, 03:19 AM
  5. clash detection?
    By peter.rumpf in forum Revit Architecture - General
    Replies: 1
    Last Post: 2006-01-18, 04:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •