Jump to content

Lisp routine to measure line and add length to existing text


Recommended Posts

Posted
Thanks.That works and one thing more.i wanna change the precision to 3 digits if possible?and a suffix (meter)?

 

Replace this .

 

(strcat (cdr (assoc 1 en))
       " = "
       (rtos l 2 2)
)

 

With this .

 

(strcat (cdr (assoc 1 en))
       " = "
       (rtos l 2 3) " Meter"
)

  • Replies 26
  • Created
  • Last Reply

Top Posters In This Topic

  • Tharwat

    8

  • emwhite

    5

  • Mohammed Elgamal

    3

  • folderdash

    3

Posted

Thats now exactly what i want.Thanks very much...

Posted
Thats now exactly what i want.Thanks very much...

 

You're welcome .

  • 2 years later...
Posted

Can this be lisp routine be modified to round the length up to the nearest inch and add 6"?

Posted
Can this be lisp routine be modified to round the length up to the nearest inch and add 6"?

 

could a prompt be added to add 6" instead of it automatically doing so?

Posted
could a prompt be added to add 6" instead of it automatically doing so?

 

Try the following:

(defun c:len2txt ( / ent idx sel str tot txt )
   (if
       (and
           (setq sel
               (ssget
                  '(   (0 . "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE")
                       (-4 . "<NOT")
                           (-4 . "<AND")
                               (0 . "POLYLINE") (-4 . "&") (70 . 80)
                           (-4 . "AND>")
                       (-4 . "NOT>")
                   )
               )
           )
           (setq txt (LM:selectifobject "\nSelect text: " "TEXT,MTEXT"))
       )
       (progn
           (setq tot (cond ((getreal "\nLength to add/subtract <0.0>: ")) (0.0))
                 txt (entget txt)
                 str (assoc 1 txt)
           )
           (repeat (setq idx (sslength sel))
               (setq ent (ssname sel (setq idx (1- idx)))
                     tot (+ tot (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)))
               )
           )
           (entmod (subst (cons 1 (strcat (cdr str) " = " (rtos tot 2 0))) str txt))
       )
   )
   (princ)
)

;; Select if Object  -  Lee Mac
;; Continuously prompts the user for a selection of a specific object type

(defun LM:selectifobject ( msg typ / ent )
   (while
       (progn (setvar 'errno 0) (setq ent (car (entsel msg)))
           (cond
               (   (= 7 (getvar 'errno))
                   (princ "\nMissed, try again.")
               )
               (   (null ent) nil)
               (   (not (wcmatch (cdr (assoc 0 (entget ent))) typ))
                   (princ "\nInvalid object selected.")
               )
           )
       )
   )
   ent
)

(vl-load-com) (princ)

Posted

Is it possible to replace the text with the length of the line and not add to what is already present.

 

Example:

If my text is X. Instead of getting X = 10'-0". Can it just say 10'-0"?

 

Is there any way to round up the fractions to a 1/16?

 

Thanks for your help on this.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...