AutoLISP: Improved MLINE (Multiline)

For those of you who like to use the MLINE command, this is for you. For those who don’t know what the MLINE command is – It lets you create 2 parallel lines and you get to specify the distance between the 2 lines. And for anyone who doesn’t have the full version of AutoCAD and uses AutoCAD LT the DLINE does essentially the same thing. But to be honest, I really don’t like the MLINE command because it is hard to edit.

The featured LISP routine was made by LEE-Mac and acts like the MLINE command and even lets you use an existing MLINE style if you have one set up. But the great thing about this version of the MLINE command is that it creates two parallel Poly Lines. This makes it so much easier to edit than trying to edit an MLINE.

Here’s how:

  • ML2 <enter> to start
  • S <enter>  to set the “Scale” (width) of the new MLINE.
  • or
  • J <enter> to specify the “Justification” of the new MLINE.
  • Place your New & Improved MLINE

~enjoy

; Works like MLINE but it draws PLines instead

; way better than MLINE

; by LEE-MAC found at CADTutor.net

(defun c:ML2 ( / *error* vl ov LastEntity ent ss )

;; © Lee Mac ~ 19.06.10

(defun *error* ( msg )

(mapcar 'setvar vl ov)

(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")

(princ (strcat "\n** Error: " msg " **")))

(princ)

)

(setq vl '("CMDECHO" "PEDITACCEPT" "QAFLAGS")

ov (mapcar 'getvar vl))

(setq LastEntity (entlast))

(command "_.mline")

(while (= 1 (logand 1 (getvar 'CMDACTIVE)))

(command pause)

)

(if (not (equal LastEntity (setq ent (entlast))))

(progn

(mapcar 'setvar vl '(0 1 5))

(vl-cmdf "_.explode" ent "")

(setq ss (ssadd))

(mapcar '(lambda ( e ) (ssadd e ss)) (LM:EntnexttoEnd ent))

(vl-cmdf "_.pedit" "_M" ss "" "_J" "" "")

)

)

(mapcar 'setvar vl ov)

(princ)

)

(defun LM:EntnexttoEnd ( e )

(if (setq e (entnext e))

(cons e (LM:EntnexttoEnd e))

)

)
Advertisements

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, TIPS. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s