Results 1 to 7 of 7

Thread: Formula Help

  1. #1
    ACA/AMEP Community Chair stelthorst's Avatar
    Join Date
    2003-10
    Location
    San Francisco CA
    Posts
    1,190
    Login to Give a bone
    0

    Default Formula Help

    Hi All,

    I've been driving myself crazy with this one. (I know not a very long drive)

    Let's say I have 3 strings

    AABBBBCC
    AABBBBCCC
    AABBBBCCCC

    What I want is a PSD that subtracts the AABBBB from each string and returns the results:

    CC
    CCC
    CCCC

    I can do a Left function and isolate the AABBBB but I can't figure out how to subtract this result from the string.

    What I want to do is something like:

    MyString - Left(MyString,6) but this doesn't work.

    Any suggestions?
    Scott Telthorst
    Quality Control Manager
    Helix Electric, Inc.
    www.helixelectric.com

    Some see the glass as half full, others as half empty. As an engineer I see the glass as twice as big as it needs to be. ~Unknown~

  2. #2
    Super Moderator dkoch's Avatar
    Join Date
    2003-03
    Location
    Philadelphia, PA
    Posts
    2,392
    Login to Give a bone
    0

    Default Re: Formula Help

    If you "know" the string you want to "subtract" or at least know you want to get rid of the first six characters (as opposed to taking three strings and trying to find a substring that all three have in common), you could use the Replace function, and replace the known string with an empty string.

    Replace( MyString, Left( MyString, 6 ), "") should work in your case.

    If all you want to do is delete the first six characters of a string of variable length, then

    Right ( MyString, Len( MyString ) - 6 )

    should also work.

  3. #3
    ACA/AMEP Community Chair stelthorst's Avatar
    Join Date
    2003-10
    Location
    San Francisco CA
    Posts
    1,190
    Login to Give a bone
    0

    Default Re: Formula Help

    Quote Originally Posted by dkoch View Post
    If you "know" the string you want to "subtract" or at least know you want to get rid of the first six characters (as opposed to taking three strings and trying to find a substring that all three have in common), you could use the Replace function, and replace the known string with an empty string.

    Replace( MyString, Left( MyString, 6 ), "") should work in your case.

    If all you want to do is delete the first six characters of a string of variable length, then

    Right ( MyString, Len( MyString ) - 6 )

    should also work.
    Hi David,

    Thanks for the help. Unfortunately I can't get it to work. I have problems with nested formulas.

    I can get Len(MyString) - 6 to work and I can get Right(MyString,4)* to work but as soon as I try to nest the Len function into the Right function it will not work.

    *4 is an example number I can use any number and it will work

    I've had little (OK No) luck getting nested or compound formulas to work.

    I tried the other formula you suggested with similar results. I believe the second formula you provided better suits my needs I just need to figure out what I'm doing wrong.

    Any suggestions? Anyone? Anyone? Bueller? Bueller?
    Scott Telthorst
    Quality Control Manager
    Helix Electric, Inc.
    www.helixelectric.com

    Some see the glass as half full, others as half empty. As an engineer I see the glass as twice as big as it needs to be. ~Unknown~

  4. #4
    Super Moderator dkoch's Avatar
    Join Date
    2003-03
    Location
    Philadelphia, PA
    Posts
    2,392
    Login to Give a bone
    0

    Default Re: Formula Help

    Quote Originally Posted by stelthorst View Post
    Hi David,

    Thanks for the help. Unfortunately I can't get it to work. I have problems with nested formulas.

    I can get Len(MyString) - 6 to work and I can get Right(MyString,4)* to work but as soon as I try to nest the Len function into the Right function it will not work.

    *4 is an example number I can use any number and it will work

    I've had little (OK No) luck getting nested or compound formulas to work.

    I tried the other formula you suggested with similar results. I believe the second formula you provided better suits my needs I just need to figure out what I'm doing wrong.

    Any suggestions? Anyone? Anyone? Bueller? Bueller?
    I was able to get both of the formulas to work, in the ADT2004 sample file in the attached ZIP file. I also threw in some variants that used the length of a target string to determine the number of characters to replace/strip from the front of the text string. Were you enclosing all property references in the formula property with double quotes? My post was written with the assumption that variables had been set to text values, rather than MyString being a direct property reference.

    I also added another option, which is not bases simply on a number but which requires that the target text string actually be present in the text string to be truncated. This formula will replace the first instance of the target string found in the text string with an empty string. Note, however, that while the search starts at the first character, the replacement could occur after that if the target string is not found starting at the first character, but is found later on in the text string.

    The sample file has a Property Set Definition called LineObjects (I had to hang the Property Set on some object type; lines seemed as good as any, and easy to draw to boot). There are two manual properties, TextString, which represents the string to be truncated, and TargetString, which, in the formulas in which it is referenced, is either the string that gets replaced or deternines the number of characters to replace.

    The ReplaceTargetOnceFromStart formula looks like this:

    Replace( "[TextString]", "[TargetString]", "", 1, 1, 1)

    The Replace function will take the value in the TextString property and replace an occurence of the value of TargetString (if found) with an empty string. The ones at the end mean, in order, start with the first character of TextString, replace only the first occurence found and make the comparison non-case sensitive. If the starting character is greater than 1, all characters up to the starting character get discarded, too. If the starting character position is greater than the length of TextString, then a null string is returned. To make the comparison case sensitive, change the last 1 to a 0.
    Attached Files Attached Files

  5. #5
    ACA/AMEP Community Chair stelthorst's Avatar
    Join Date
    2003-10
    Location
    San Francisco CA
    Posts
    1,190
    Login to Give a bone
    0

    Default Re: Formula Help

    Dang quotation marks

    I was able to add quotation marks to the formula and was able to make it work.

    Right("MyString",Len("MyString")-6)

    Thanks,

    How about this one. I want to do add up the values of If-Then statements. Something like this.

    If "[Connector1]" = "No" Then
    RESULT = 0
    Else
    RESULT = 1
    End If
    +
    If "[Connector2]" = "No" Then
    RESULT = 0
    Else
    RESULT = 1
    End If

    What's wrong with this picture? Both If-then statements work independently but I can't get them to add. I even tried to add CInt in front of each If-Then statement with no success.
    Scott Telthorst
    Quality Control Manager
    Helix Electric, Inc.
    www.helixelectric.com

    Some see the glass as half full, others as half empty. As an engineer I see the glass as twice as big as it needs to be. ~Unknown~

  6. #6
    Super Moderator dkoch's Avatar
    Join Date
    2003-03
    Location
    Philadelphia, PA
    Posts
    2,392
    Login to Give a bone
    0

    Default Re: Formula Help

    Quote Originally Posted by stelthorst View Post
    Dang quotation marks

    I was able to add quotation marks to the formula and was able to make it work.

    Right("MyString",Len("MyString")-6)

    Thanks,

    How about this one. I want to do add up the values of If-Then statements. Something like this.

    If "[Connector1]" = "No" Then
    RESULT = 0
    Else
    RESULT = 1
    End If
    +
    If "[Connector2]" = "No" Then
    RESULT = 0
    Else
    RESULT = 1
    End If

    What's wrong with this picture? Both If-then statements work independently but I can't get them to add. I even tried to add CInt in front of each If-Then statement with no success.
    Multi-line formula properties do not work that way. In essence, a multi-line formula property is treated like a single function, whose return value is given by the value to which RESULT is set. You can have multiple RESULTs in a formula, but the last one evaluated wins. You also can not add two If statements together as you have it shown, but you can achieve that result by creating a variable to store intermediate results. The following should work:

    countConnectors = 0
    If "[Connector1]" <> "No" Then
    countConnectors = countConnectors + 1
    End If
    If "[Connector2]" <> "No" Then
    countConnectors = countConnectors + 1
    End If
    RESULT = countConnectors

    The <> symbol means "not equal"; if a particular connector property is set to "No", then countConnectors will not be incremented.

  7. #7
    ACA/AMEP Community Chair stelthorst's Avatar
    Join Date
    2003-10
    Location
    San Francisco CA
    Posts
    1,190
    Login to Give a bone
    0

    Default Re: Formula Help

    You're pobably tired of hearing this but...

    YOU DA MAN !!!!!

    Thanks for the help that worked perfectly.
    Scott Telthorst
    Quality Control Manager
    Helix Electric, Inc.
    www.helixelectric.com

    Some see the glass as half full, others as half empty. As an engineer I see the glass as twice as big as it needs to be. ~Unknown~

Similar Threads

  1. 2013: Help Formula(s) for one but not the other.
    By awinkler514194 in forum Revit Architecture - Families
    Replies: 25
    Last Post: 2013-05-29, 09:31 PM
  2. 2013: How to use this Formula,"Formula That Returns Strings"?
    By mike99 in forum Revit Architecture - General
    Replies: 4
    Last Post: 2013-01-09, 06:28 AM
  3. Yes/No Formula
    By lonewolfjustin in forum Revit MEP - Families
    Replies: 1
    Last Post: 2009-06-05, 12:21 AM
  4. Formula Use
    By jkrager in forum Revit Architecture - Tips & Tricks
    Replies: 0
    Last Post: 2006-01-20, 06:57 PM
  5. = a formula
    By GuyR in forum Revit Architecture - General
    Replies: 35
    Last Post: 2005-03-11, 08:24 AM

Posting Permissions

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