+ Reply to Thread
Results 1 to 8 of 8

Thread: Line Properties

  1. #1
    Super Member Bill Tillman's Avatar
    Using
    AutoCAD 2014
    Join Date
    Oct 2008
    Location
    Miami, FL
    Posts
    1,257

    Default Line Properties

    Registered forum members do not see this ad.

    I'm using some selected points to do some LISP programming. But I seem to keep running into inaccuracies with the code. If you check the attached drawing you'll see that the white line at the bottom will return (cadr pt1) and (cadr pt2) are equal. But if you check the blue line right below it (cadr pt1) and (cadr pt2) are not equal...even though AutoCAD is reporting they are.

    pt1 is the left endpoint of the lines and pt2 is the right endpoint of the lines. When I examine the variance between the points on the lowest (blue) line, it's very small, like -6.76792e-013.

    ???
    Attached Files
    It's deja vu, all over again.

  2. #2
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,727

    Default

    Interesting that other points are not exact when looking at the co-ords 24.4999999 not 24.50000000 its like a creeping error. How are you doing your polar angles are you using say (/ pi 2.0) v's a 1.57.......
    A man who never made mistakes never made anything

  3. #3
    Super Member Bill Tillman's Avatar
    Using
    AutoCAD 2014
    Join Date
    Oct 2008
    Location
    Miami, FL
    Posts
    1,257

    Default

    Hey BIGAL, nice to hear from you. This is one which I cannot pin down. I created the line as part of a template file I'm using for handrails. How I did it is not recalled as it happened several weeks ago but I'm willing to wager at least a few bucks that I just drew it using the mouse with ORTHO on. I have tested this several times using this same method as well as using "@12<0". The second method tends to be most accurate, but the ORTHO on method should also be just as accurate. What I am finding is that both methods create lines where about 99% of the time (= (cadr pt1) (cadr pt2)) is True. Which is what they should be. Every once in a while I get this creeping error. Since this is a LISP code that I will need to have users not bother with this creeping error I'm thinking I can check for the smallest of variance and take the needed action.

    Okay, now let me expand on that LISP code and see if that explains things more clearly. The client I've written this for builds handrails which sometimes are horizontal and sometimes on stairs where they are sloped. The code asks the user to click on two points, which are the intersection of the vertical posts with horizontal rails which support the pickets. Getting this correct with the minimum quantity of pickets evenly spaced along this length is the goal. So when I ask for the inputs I check to see of the 'Y' coordinates are the same. If they are, I execute the code for horizontal spacing. If they are not equal I execute the code for sloped spacing which uses a little trigonometry to work things out. So as you can see, when I compare (cadr pt1) with (cadr pt2) and there's a variance, even on a horizontal line, the wrong code executes.

    What I see is that sometimes the variance is less than 0, a negative number, and sometimes it's greater than zero, a positive number. But it's always a very small number which AutoCAD uses exponential format to represent, like -6.76792e-013. So if I just check if the difference is not equal to 0 will not suffice. And if I check if the difference is greater than 0 it could still choose the wrong code to execute. Same thing for less than 0. So I'm thinking maybe checking if (RTOS) is not "0" or contains anything but all "0"s.

    I should also note that when I set the UNITS precision for angles to 8 decimal places, the angle of these squeeky lines indicates 0.00000000, which is obviously not correct and what's making the problem not so easily resolvable.
    It's deja vu, all over again.

  4. #4
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,727

    Default

    Look at (abs 123.55) (abs -123.55) need only one check then when taking pt1 Y - pt2 Y thats its less than 0.0000001 etc
    A man who never made mistakes never made anything

  5. #5
    Super Member CyberAngel's Avatar
    Computer Details
    CyberAngel's Computer Details
    Operating System:
    Windows 10
    Discipline
    Architectural
    CyberAngel's Discipline Details
    Occupation
    Civil Drafter
    Discipline
    Architectural
    Details
    Roofing and Waterproofing
    Using
    AutoCAD 2014
    Join Date
    Jul 2006
    Location
    Anywhere Else
    Posts
    1,120

    Default

    I'd say this falls under the programming category of validating input. The code as written depends on the user drawing perfectly horizontal lines, which (as you've found) doesn't always happen. You could round off the Y coordinate of both points, or you could find the angle and round that off. Using fix(0.5 + Y) gives you the nearest integer. Getting more-precise answers is left as an exercise for the reader.
    breaking AutoCAD on a regular basis since 1991

  6. #6
    Senior Member lrm's Avatar
    Computer Details
    lrm's Computer Details
    Operating System:
    Windows 7 64-bit
    RAM:
    16 GB
    Discipline
    Education
    lrm's Discipline Details
    Occupation
    Teacher, AEC and mechanical
    Discipline
    Education
    Details
    Civil and Mechanical
    Using
    AutoCAD 2014
    Join Date
    Jan 2010
    Location
    Massachusetts, USA
    Posts
    341

    Default

    Quote Originally Posted by BIGAL View Post
    Look at (abs 123.55) (abs -123.55) need only one check then when taking pt1 Y - pt2 Y thats its less than 0.0000001 etc
    Rather than use an absolute number for the error tolerance I suggest using a percent. E.g., abs((pt1 Y - pt2 Y)/pt1 Y) < 0.001 Using an absolute difference can run into problems for drawings of large extents where the line being evaluated is far from 0,0,0 WCS.

    Also, note that 0.1, 0.01, etc, are irrational numbers in binary which can cause a problem if you are looking to do an exact comparison.

  7. #7
    Super Member Patrick Hughes's Avatar
    Computer Details
    Patrick Hughes's Computer Details
    Operating System:
    Win 7 x64
    Computer:
    Dell Precision T7610
    CPU:
    Intel Xeon E5-2630 v2 (six core)
    RAM:
    32 Gb
    Graphics:
    3 Gb Nvidia Quadro K4000
    Primary Storage:
    1 TB
    Monitor:
    2x 1920x1080 Dell Ultrasharp U2312HM
    Discipline
    Mechanical
    Patrick Hughes's Discipline Details
    Occupation
    Self unemployed - Machine Design
    Discipline
    Mechanical
    Details
    Machine Design
    Using
    AutoCAD 2015
    Join Date
    May 2008
    Location
    Rockford, Illinois
    Posts
    763

    Default

    Rather than using the "=" conditional look into using "EQUAL" which allows you to pass in an accuracy parameter" (if (equal x1 x2 0.00001))
    www.cadtempo.com
    Time tracking for AutoCAD, Inventor, Revit and other CAD programs

  8. #8
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,727

    Default

    Registered forum members do not see this ad.

    The other option may be to take the line work and round up the end points then update the line co-ords. Do a global over all the dwg or an area.
    A man who never made mistakes never made anything

Similar Threads

  1. help on exprting line properties to excel
    By ktbjx in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 18th Aug 2016, 02:50 pm
  2. line length in properties box
    By Rudbeckia in forum AutoCAD Beginners' Area
    Replies: 2
    Last Post: 5th Mar 2015, 04:55 am
  3. Line Colour Properties change
    By chewie in forum AutoCAD Bugs, Error Messages & Quirks
    Replies: 1
    Last Post: 17th Jan 2011, 06:40 pm
  4. Line Properties in Properties Palette
    By kimkat_tkl in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 3
    Last Post: 6th Feb 2009, 04:11 pm
  5. Line properties
    By cadam in forum AutoCAD Drawing Management & Output
    Replies: 6
    Last Post: 5th Jul 2007, 03:43 pm

Bookmarks

Posting Permissions

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