Results 1 to 4 of 4

Thread: Alignment Station Labels based on Time

  1. #1
    Member
    Join Date
    2012-06
    Posts
    20
    Login to Give a bone
    0

    Default Alignment Station Labels based on Time

    So, here's the deal:

    I programmed a series of expressions that will convert a station into a time stamp based on travel speed. It is very similar to a DEC->HMS system except it operates using a base scale factor for travel speed. I then made it calculate a tens digit and ones digit for both minutes and seconds to preserve digit offsets.

    The problem is, I think it's pooping bricks in the calculations and is finding infinitely small redundancies causing a round down during the truncates. I'll list my code first then post results.

    If your first answer is "ROUNDDOWN instead of TRUNC"... trust me, I've tried it. It just gags. First it spits out the parenthesis, then it spits out the R in ROUNDDOWN...

    The basic system, without making two-digit results

    TS Travel Speed
    - m/hr value constant to be adjusted case-by-case

    TS Hour Calc
    ({Station Value}/{TS Travel Speed})

    TS Hour Trunc
    TRUNC({Station Value}/{TS Travel Speed})

    TS Min Calc
    (({TS Hour Calc}-{TS Hour Trunc})*60)

    TS Min Trunc
    TRUNC(({TS Hour Calc}-{TS Hour Trunc})*60)

    TS Sec
    (({TS Min Calc}-{TS Min Trunc})*60)


    What this should do is subtract the trancated value from the whole value, leaving the decimal to be brought to whole value of the next segment. What I am finding is a less-than-zero redundancy in the truncated values on perfect numbers which is carrying through, producing unwanted results.

    For instance, 12'00" is coming out 11'60". I have then inserted each step into a label style to see their results. It is truncating the 12' as 11', then during the next stage it subtracts the truncated value leaving a 1 multiplied by 60.

    I have also allowed for finite decimals (3 places) and in one stage it showed 3 zeroes, in another stage it shows 3 nines, for instance 11.000'59.999"

    I personally think it's just pooping bricks on the formulas.


    The next segment then creates tens and ones digits


    TS Min Tens
    TRUNC({TS Min Calc}/10)

    TS Min Ones
    TRUNC({TS Min Calc}-({TS Min Tens}*10))

    TS Sec Tens
    TRUNC({TS Sec}/10)

    TS Sec Ones
    ({TS Sec}-({TS Sec Tens}*10))

    I leave the last one to rounding so it can show decimals if needed. I'm finding some weird results yet again. For instance, the seconds becomes 510" because there is a finite redundancy being carried through the truncating.


    Any help?

    -Sebastien

  2. #2
    Member
    Join Date
    2012-06
    Posts
    20
    Login to Give a bone
    0

    Default Re: Alignment Station Labels based on Time

    Also, I forgot to mention - the problem is nonsystematic. It only happens every so often.

    The redundancy in the seconds generally only becomes visible at the values that are more perfect in higher stages of the calculation, such as a perfect minute carrying into the seconds. The seconds errors can be hidden in the rounding, but still exist nonetheless.

  3. #3
    Member
    Join Date
    2012-06
    Posts
    20
    Login to Give a bone
    0

    Default Re: Alignment Station Labels based on Time

    I fixed the formulas by adding 0.001m just before the truncate. It basically rolls it just over the whole number forcing the truncate to recognize the number.

    TS Travel Speed
    - m/hr value constant to be adjusted case-by-case

    TS Hour Calc
    ({Station Value}/{TS Travel Speed})

    TS Hour Trunc
    TRUNC({Station Value}/{TS Travel Speed}+0.001)

    TS Min Calc
    (({TS Hour Calc}-{TS Hour Trunc})*60)

    TS Min Trunc
    TRUNC(({TS Hour Calc}-{TS Hour Trunc})*60+0.001)

    TS Sec
    (({TS Min Calc}-{TS Min Trunc})*60)

    The next segment then creates tens and ones digits

    TS Min Tens
    TRUNC({TS Min Calc}/10+0.001)

    TS Min Ones
    TRUNC({TS Min Calc}-({TS Min Tens}*10)+0.001)

    TS Sec Tens
    TRUNC({TS Sec}/10+0.001)

    TS Sec Ones
    ({TS Sec}-({TS Sec Tens}*10)+0.001)

  4. #4
    Member
    Join Date
    2015-02
    Posts
    8
    Login to Give a bone
    0

    Default Re: Alignment Station Labels based on Time

    I seem to remember having trouble with the TRUNC function a while ago, and switching to the FLOOR function fixed it.
    But I'm not totally sure on that. It was a while ago...!

Similar Threads

  1. Add alignment station offset labels
    By krkeec763189 in forum Dot Net API
    Replies: 0
    Last Post: 2013-10-07, 09:54 AM
  2. Alignment and station labels
    By tim_newsome in forum AutoCAD Civil 3D - Alignments
    Replies: 1
    Last Post: 2012-11-13, 12:27 AM
  3. Alignment Station label that is perpendicular to alignment
    By corboto in forum AutoCAD Civil 3D - Alignments
    Replies: 4
    Last Post: 2010-05-20, 10:43 PM
  4. Apply Alignment Labels to Specified Station Ranges
    By civil3d.wishlist1941 in forum Civil 3D Wish List
    Replies: 0
    Last Post: 2008-11-07, 08:04 PM
  5. Alignment based labels
    By rdomke69 in forum AutoCAD Civil 3D - General
    Replies: 1
    Last Post: 2007-11-29, 08:23 AM

Tags for this Thread

Posting Permissions

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