Message 1 of 3
Drawing rectangles in sequence each connected by a polyline
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Currently I'm using a modified version of Lee Mac's Multi-Polyline to draw a multiline which is then converted into a closed polyline and hatched
I am wondering where I would begin to have each converted multiline connected by a polyline (see image)
Essentially I am drawing a plan view of walls and headers, and want to make my workflow more efficient for adding in the headers automatically
Any help on a starting point would be much appreciated!
This is the code I'm working with so far;
;;------------------------=={ Multi-Polyline }==-----------------------;;
;; ;;
;; This program enables the user to create objects with the appearance ;;
;; of multilines, however, which are composed of standard polylines. ;;
;; ;;
;; The program will invoke the standard AutoCAD MLINE command, ;;
;; allowing the user to construct the object with the real-time ;;
;; dynamic preview afforded by the MLINE command, with the resulting ;;
;; multiline automatically exploded & joined to form standard 2D ;;
;; polylines. ;;
;;----------------------------------------------------------------------;;
;; Author: Lee Mac, Copyright � 2010 - www.lee-mac.com ;;
;;----------------------------------------------------------------------;;
;; Version 1.0 - 2010-06-19 ;;
;; ;;
;; First release. ;;
;;----------------------------------------------------------------------;;
;; Version 1.1 - 2015-09-12 ;;
;; ;;
;; Program rewritten. ;;
;;----------------------------------------------------------------------;;
(defun c:mplb ( / *error* ent sel val var dict mstyle )
(defun *error* ( msg )
(mapcar 'setvar var val)
(LM:endundo (LM:acdoc))
(if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")))
(princ (strcat "\nError: " msg))
)
(princ)
)
;; Open the MLINESTYLE dictionary
(setq dict (vla-item
(vla-get-dictionaries
(vla-get-activedocument (vlax-get-acad-object))
)
"ACAD_MLINESTYLE"
)
)
;; Check if the "BEARINGWALL" style exists
(if (vl-catch-all-error-p
(setq mstyle (vl-catch-all-apply 'vla-item (list dict "BEARINGWALL")))
)
(progn
(alert "The multiline style 'BEARINGWALL' was not found in the drawing.")
(exit)
)
(setvar 'cmlstyle "BEARINGWALL")
)
;; Start Undo
(LM:startundo (LM:acdoc))
;; Set variables for hatch properties
(setvar 'hpname "solid")
(setvar 'hpscale 1)
(setvar 'clayer "S - BEARING WALLS")
(command "_.mline" "_J" "top" "")
(setq ent (entlast))
(vl-cmdf "_.mline")
(while (= 1 (logand 1 (getvar 'cmdactive)))
(vl-cmdf "\\")
)
;; Check if the multiline was exploded
(if (not (eq ent (setq ent (entlast))))
(progn
;; Save current variable values and set new values
(setq var '(cmdecho peditaccept qaflags)
val (mapcar 'getvar var)
sel (ssadd)
)
(mapcar 'setvar var '(0 1 0))
;; Explode the multiline
(vl-cmdf "_.explode" ent)
;; Add exploded entities to selection set
(while (setq ent (entnext ent)) (ssadd ent sel))
;; Join the exploded entities
(vl-cmdf "_.pedit" "_m" sel "" "_j" "" "")
;;; Create a new selection set for the joined polyline
(setq sel2 (entlast))
(setvar 'HPASSOC 1) ; make hatches associative
;; Add hatch to the joined polyline
(vl-cmdf "_.bhatch" "_s" sel2 "" "")
(setq hatchsel (entlast)) ; get the last created entity, which should be the hatch
(vl-cmdf "_.chprop" hatchsel "" "_la" "S - SHADE" "") ; change the layer of the hatch to "S - SHADE"
(vl-cmdf "_.DRAWORDER" hatchsel "" "_B" "")
)
)
(*error* nil)
(princ)
)
;; Start Undo - Lee Mac
;; Opens an Undo Group.
(defun LM:startundo ( doc )
(LM:endundo doc)
(vla-startundomark doc)
)
;; End Undo - Lee Mac
;; Closes an Undo Group.
(defun LM:endundo ( doc )
(while (= 8 (logand 8 (getvar 'undoctl)))
(vla-endundomark doc)
)
)
;; Active Document - Lee Mac
;; Returns the VLA Active Document Object
(defun LM:acdoc nil
(eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
(LM:acdoc)
)
(vl-load-com) (princ)
;;----------------------------------------------------------------------;;
;; End of File ;;
;;----------------------------------------------------------------------;;