Jump to content

LISP to cut mline and re-draw that portion with new mline


Recommended Posts

Posted

At our company we primarily use mlines to draw 2d ductwork. Some prefer lines...I prefer mlines. I have created a lisp routine, as rough as it may be, that mostly works. Where ductwork crosses, it prompts for the two intersection points and then the mline to be cut. That portion is re-drawn using a different mlstyle as hidden. Is there a way to get it to draw in the same location as the original mline? I want it to be as user friendly as possible...right now it draws it from the two intersection points...but the justification is a sticking point, so it is hard to guarantee the output based on the user's intersection point selection. Another curiosity is that it seems to only cut a vertical mline, not a horizontal one?

 

It doesn't necessarily have to be an mline, I just thought it would cleaner and nicer...but I do want it to draw both lines at once.

 

Let me know if my goals are unclear. I appreciate any help or other ideas. Below is my code (I've commented out parts that were used previously and/or test devs):

; Type TDD at command line.
; To create white hidden lines when drawing duct.
; Prompts user to select intersection points of mulit-line
; Follow the prompts.
;nmulder@rwb.net


(defun c:TDD (/ pt1 pt2 obj duct_above)

 (acet-error-init
(list (list "cmdecho" 0
            "osmode" (getvar "osmode")
            "clayer" (getvar "clayer")
      );list
      T
);list
 );acet-error-init
 
 
 (setvar "osmode" 32)

 (setq pt1 (getpoint "\nSelect first intersection point:"))
 (setq pt2 (getpoint "\nSelect second intersection point:"))
 (while (null obj)(setq obj (entsel "\nSelect MLINE to break:")))
 (setq elist (entget (car obj)))
 (setq mline_width (cdr (assoc 40 elist)))
 (setq mline_layer (cdr (assoc 8 elist)))
 (setq mline_style (cdr (assoc 2 elist)))
;;;  (setq mline_just (cdr (assoc 70 elist)))

;;;  (setq pt1 (cadr obj))
  (setq objtype (cdr (assoc 0 elist)))
   (if (and (/= objtype "MLINE"))
   (progn
        (alert "Object must be a multi-line!")
   	 (exit)
   )
 )
;;;(setq pt2 (getpoint "\nSelect second intersection point:"))
 (command "_.MLEDIT" "CA" pt1 pt2 "")
 (command "_.LAYMCUR" obj)
;;;  (entmake '((0 . "MLINE") (2 . "WH") (8 . "MLINE_LAYER") (40 . MLINE_WIDTH) (70 . MLINE_JUST) (10 . PT1) (11 . PT2)))
 (setq duct_above (distance pt1 pt2));size of crossing duct above
 
;;;  (command "_.LINE" pt1 pt2 "")
;;;  (command ".insert" "Q:\Autocad\RWB\RWB_MLStyles.dwg" "0,0" "1" "1" "0")
;;;;;;  (entdel (entlast))
 (command "_.MLINE" "J" "B" "S" mline_width "ST" "WH" pt1 pt2 "")
 (command "_.MLINE" "J" "Z" "S" mline_width "ST" "RWB" "0,0" "1,1" "")
 (entdel (entlast))
 (acet-error-restore)
 (princ)
)

))

Posted

Just a suggestion I am sure I had something for conc beams they way it worked you drew a crossing window it works out the 4 points (two mlines) breaks and in your case would add a new line. Now I remember its not mlines its a multiline routine pick a pt next etc multiple lines drawn. You may find you have to explode the mlines then use "inters" in a lsp to find the intersecting points. This would be automatic and uses the size of the existing lines also angles are not a problem. this would mean a new routine to draw 2 parralel lines but theres lots of examples here and I am sure someone will have the auto break. I will try to find.

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...