2011/05/22

MLINE for Control Channel Routing

After installing AutoCAD 2012 today I came across the MLINE command. It is an easy way to draw a set of parallel lines that follow a path.  Steps:

  1. MLINE at the command prompt
  2. Enter J to choose justification - Zero seems most appropriate: centers the path taken between the lines drawn.
  3. Default scale is 1, which is 1:1 with the current drawing units.  Set this to be the width of your control channel.
  4. Start tracing a path point by point.
  5. When finished hit ESC.
Voila! A neatly drawn channel without "rectangle madness".  So that it will print you'll need to convert the MLINE to a PLINE.  For that you can:
  1. EXPLODE the MLINE you've just drawn
  2. Use PEDIT to Join all the resultant line segments
This could get quite laborious for a long channel with multiple turns.  So instead you can use a great AutoLISP script created by Lee Mac over at CADTutor:

(defun c:m2p (/ vlst ovar ent ss elast)
  (setq vlst '("CMDECHO" "PEDITACCEPT")
    ovar (mapcar 'getvar vlst))
  (if (and (setq ent (car (entsel "\nSelect Multi-Line...")))
       (eq "MLINE" (cdadr (entget ent))))
    (progn
      (mapcar 'setvar vlst '(0 1))
      (command "_explode" ent) (setq ss (ssadd))
      (mapcar '(lambda (x) (ssadd x ss)) (Ent_List_to_End ent))
      (setq elast (entlast))
      (command "_pedit" "_M" ent ss elast "" "_J" "" ""))
    (princ "\n No Multi-Line Selected "))
  (mapcar 'setvar vlst ovar)
  (princ))

(defun Ent_List_to_End(ent / a)
  (reverse
    (if(setq a(entnext ent))
       (cons ent(Ent_List_to_End a)))))

No comments:

Post a Comment