+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Full Member
    Using
    AutoCAD 2012
    Join Date
    Sep 2011
    Location
    Sweden
    Posts
    37

    Default Find exact insertion point

    Registered forum members do not see this ad.

    Hi!

    Does anyone know how to find the exact insertion point of a block with autolisp?
    And with "exact" I mean with all decimals.

    If a block is inserted with snap and then moved 0.0000001 to the left. Is it then possible to find that block with autolisp?

    Thanks in advance
    / Thomas

  2. #2
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,642

    Default

    contrary to what other people think, when you retrieve the insertion point of a block , it WILL give you the exact coordinate. You may not "see" it, but i tell you now. IT IS.

    Try inserting a block at 0,0 coordinates. and move that block 0.0000001 then use
    Code:
     (Cdr (assoc 10 (entget (Car (entsel)))))
    You will get something like (1.0e-007 0.0 0.0)

  3. #3
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,973

    Default

    The code below will allow you to see the available number of decimals:
    Code:
    (if (setq itemBlock (ssget ":S" '((0 . "INSERT"))))
     (progn
      (setq pointIns (cdr (assoc 10 (entget (ssname itemBlock 0)))))
      (prompt (strcat "\Insertion point:"
                      "\n   X = " (rtos (car   pointIns) 2 18)
                      "\n   Y = " (rtos (cadr  pointIns) 2 18)
                      "\n   Z = " (rtos (caddr pointIns) 2 18)))
     )
    )
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  4. #4
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,738

    Default

    @pBe: While the example shows correctly, I think it might be unclear about rounding off errors. If the insertion point is somewhere away from 0,0,0 and also ever so slightly off a full number (integer) then you might find that the display of the insertion point omits the decimals (this is due to the LUPREC setting).

    @ripuz: Even if you set the precision as high as possible, it might still not display all the decimals. The returned value (as pBe's shown) is still the "exact" point though, it might just be difficult to display to absolute accuracy. All calculations on such point uses the double precision floating point value returned with entget, not the value you see on the command line in the list command. It's not "perfect" accuracy, but it's as good as it gets, since acad itself only uses double precision floating points internally. There are some small errors (called floating point errors), which might crop up - but they're generally to 16 decimal digits or less. http://en.wikipedia.org/wiki/Floating_point
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  5. #5
    Full Member
    Using
    AutoCAD 2012
    Join Date
    Sep 2011
    Location
    Sweden
    Posts
    37

    Default

    Quote Originally Posted by pBe View Post
    contrary to what other people think, when you retrieve the insertion point of a block , it WILL give you the exact coordinate. You may not "see" it, but i tell you now. IT IS.

    Try inserting a block at 0,0 coordinates. and move that block 0.0000001 then use
    Code:
     (Cdr (assoc 10 (entget (Car (entsel)))))
    You will get something like (1.0e-007 0.0 0.0)
    Okey, I see... I did as you said and i got the same answer as you but only when x are close to zero.
    If the block is located at 99.999999, 100 the answer will be (100.0 100.0 0.0).

    I got your point though... That the coordinates is the right coordinates, it´s just not displayed exactly.
    And to show it:
    Code:
    (rtos (Cadr (assoc 10 (entget (Car (entsel))))) 2 8)
    Thanks for you quick reply pBe!

  6. #6
    Full Member
    Using
    AutoCAD 2012
    Join Date
    Sep 2011
    Location
    Sweden
    Posts
    37

    Default

    Quote Originally Posted by irneb View Post
    @pBe: While the example shows correctly, I think it might be unclear about rounding off errors. If the insertion point is somewhere away from 0,0,0 and also ever so slightly off a full number (integer) then you might find that the display of the insertion point omits the decimals (this is due to the LUPREC setting).

    @ripuz: Even if you set the precision as high as possible, it might still not display all the decimals. The returned value (as pBe's shown) is still the "exact" point though, it might just be difficult to display to absolute accuracy. All calculations on such point uses the double precision floating point value returned with entget, not the value you see on the command line in the list command. It's not "perfect" accuracy, but it's as good as it gets, since acad itself only uses double precision floating points internally. There are some small errors (called floating point errors), which might crop up - but they're generally to 16 decimal digits or less. http://en.wikipedia.org/wiki/Floating_point
    Thanks irneb, now I´ll understand.

  7. #7
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,973

    Default

    Also keep in mind that the precision is inverse proportional with the "size" of the number:
    Code:
    (rtos 12.345678901234567 2 18)
    ;Return> "12.34567890123457"
     
    (rtos 1234567.8901234567 2 18)
    ;Return> "1234567.890123457"
     
    (rtos 12345678901234.567 2 18)
    ;Return> "12345678901234.57"
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  8. #8
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,738

    Default

    Yes, the ~16 digits means 16 in total. Not 16 after the decimal point. So as Mircea's shown the rounding / floating point error becomes worse the further you are away from 0,0,0. For this reason I prefer drawing as close as possible to 0,0,0 and using UCS's for stuff like coordinate references.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  9. #9
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,642

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by ripuz View Post
    I got your point though... That the coordinates is the right coordinates, it´s just not displayed exactly.
    Thanks for you quick reply pBe!
    Good for you

    @Msasu/Irné
    All bases covered

Similar Threads

  1. MOVING THE BASE POINT/ INSERTION POINT
    By nwmjdp in forum AutoCAD Beginners' Area
    Replies: 6
    Last Post: 13th May 2012, 06:44 am
  2. In 3D sketch bending from exact point
    By Arnc in forum Autodesk Inventor
    Replies: 7
    Last Post: 24th Dec 2011, 10:49 am
  3. Point Insertion Lisp
    By jaylo23 in forum AutoLISP, Visual LISP & DCL
    Replies: 20
    Last Post: 18th Nov 2008, 02:37 pm
  4. find border insertion point
    By dbroada in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 25th Mar 2008, 07:19 pm
  5. Insertion Point
    By GIB39 in forum AutoCAD Beginners' Area
    Replies: 6
    Last Post: 12th Oct 2007, 07:47 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