Results 1 to 7 of 7

Thread: Autolisp for measuring the distance between two ponts and printing differece into mtext

  1. #1
    Member
    Join Date
    2017-05
    Posts
    6
    Login to Give a bone
    0

    Lightbulb Autolisp for measuring the distance between two ponts and printing differece into mtext

    I'm just starting to pick up autolisps and have been playing around qith creating one that will measure the distance between two points and then insert the value in mtext as at a selected location.

    Any help would be great,

    Thanks

  2. #2
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Autolisp for measuring the distance between two ponts and printing differece into mtext

    Hi,

    Try this.
    Code:
    (defun c:Test ( / p1 p2 p3)
      (and (setq p1 (getpoint "\nSpecify first point :"))
           (setq p2 (getpoint "\nNext point :" p1))
           (setq p3 (getpoint "\nSpecify text location :"))
           (entmakex (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") (cons 10 p3) (cons 1 (rtos (distance p1 p2) 2))))
           )
      (princ)
      )

  3. #3
    Member
    Join Date
    2017-05
    Posts
    6
    Login to Give a bone
    0

    Default Re: Autolisp for measuring the distance between two ponts and printing differece into mtext

    Thanks heaps,

    If I wanted to incorporate a naming function for the distances and an option for text rotation how would I go about that?

  4. #4
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Autolisp for measuring the distance between two ponts and printing differece into mtext

    Quote Originally Posted by Kdicksonabbott750429 View Post
    Thanks heaps,
    If I wanted to incorporate a naming function for the distances
    You are welcome.

    Sorry I didn't get your point.

    Quote Originally Posted by Kdicksonabbott750429 View Post
    .... and an option for text rotation how would I go about that?
    Just add the DXF codes as the following and the angle value supposed to be in radians.
    Code:
    (cons 50 (* pi 0.5)) ;; eg: 90 Degree
    Important link for Mtext dxf codes: HERE

  5. #5
    Member
    Join Date
    2017-05
    Posts
    6
    Login to Give a bone
    0

    Default Re: Autolisp for measuring the distance between two ponts and printing differece into mtext

    "incorporate a naming function for the distances"

    Sorry. I meant if I wanted to include the prefix "dtm" prior to the difference in distance. I'm not sure if I'm making much sense. Haha.

    Eg- "dtm 6.25"

  6. #6
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Autolisp for measuring the distance between two ponts and printing differece into mtext

    I see now ...

    Just add the following codes into the above posted codes like this.
    Code:
     (cons 1 (strcat "dtm " (rtos (distance p1 p2) 2)))

  7. #7
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    560
    Login to Give a bone
    0

    Default Re: Autolisp for measuring the distance between two ponts and printing differece into mtext

    If you want to auto the text angle use the angle of the two points it may draw upside down so you can also do a check for readability and use -90 instead. There will be some examples out there to check angle against current quadrant.

Similar Threads

  1. AutoLISP to count MTEXT against Polylines/Blocks
    By Maccabee1 in forum AutoLISP
    Replies: 1
    Last Post: 2016-12-24, 09:33 PM
  2. measuring a distance
    By sherflor in forum 3ds Max - General
    Replies: 3
    Last Post: 2009-07-13, 04:47 PM
  3. Text standards - mtext line space distance/factor
    By devilfrog in forum AutoCAD General
    Replies: 6
    Last Post: 2007-09-05, 11:08 AM
  4. Please help with Autolisp routine about Printing
    By Matt Mercer in forum AutoLISP
    Replies: 9
    Last Post: 2006-03-09, 03:27 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
  •