Autolisp help

Autolisp help

Anonymous
Not applicable
401 Views
1 Reply
Message 1 of 2

Autolisp help

Anonymous
Not applicable

Hello,

I am composing my post again as i didn't include the necessary info the previous time.

 

I am very new to learning Autolisp but i have been handed a script at work that i have to modify. The command is ADDLINETEXTSIMPLE and its use is:

type the command >> select a line or pline >> type the meters

This way i can generate a line_text block that holds as attributes the layer, the meters in km, the linesegmentid and the line handle. Is there a way i can modify the lisp as to be able to select many lines at once and have the blocks generated for each line alltogether?

 

You will find the script and the dwg file attached.

 

Thank you

0 Likes
402 Views
1 Reply
Reply (1)
Message 2 of 2

john.uhden
Mentor
Mentor

Just copy your C:addlinetextsimple and change the copy to...

(without the c: prefix but with an input argument)

 

(defun addlinetextsimple (ename)
      (setq ent (entget ename))
      (setq ty (cdr (assoc 0 ent)))
      (if (OR (= ty "LWPOLYLINE") (= ty "LINE"))
        (progn    
          (setq newlength (rtos (getreal "\nΔώστε το μήκος σε μέτρα: ")))
          (addinfo sent newlength 0 0)
        )
        (progn
          (princ "\n\tΠρόβλημα: Το επιλεγμένο αντικείμενο δεν είναι LINE ή POLYLINE.")
          (princ)
        )  
      )
    )
)
;; Then you can take a selection set, as in
(setq ss (ssget))
;; and
(repeat (setq i (sslength ss))
  (addlinetextsimple (ssname ss (setq i (1- i))))
)

 

Of course you can add filtering to your ssget to prevent the selection of non-qualified entities.

OOPS.  I just noticed you used sent farther down in the code and I eliminated it because it seemed you wanted only the ename, but I trust you can figure out how to handle that.

BTW, you might want to replace getreal with getdist which can take a real or a distance between two picked points.

 

John F. Uhden

0 Likes