Extract dynamic block from parent drawing, insert in new drawing

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a parent drawing with all the dynamic blocks we are using.
I have a lisp routine that will insert a toilet, and then after a few more clicks/answers, you are asked what the vent size is to be. Here you answer 1.5", 2", or 3". This determines the block name to insert. Ex. I type 1.5, it will insert "DWV Fittings-1.5" displaying the default visibility state.
What I need to do is, if the blocks do not exist in the drawing, the routine will go out and look for the "Dynamic Blocks.dwg" within my support search paths, then extract the correct dynamic block from this drawing.
Is this possible?
Below is the lisp routine (note this routine is associated with a tool palette command):
(defun WC (B / P1 P2 P3 P4 P5 P6 A1 A2 STYLE VENT)
(setq ERRORSAVE *ERROR*)
(setq OS (getvar "OSMODE"))
(command "undo" "mark")
(setvar "CMDECHO" 0)
(setq L (getvar "clayer"))
(setq doit 't)
(while doit
(setq p1 (getpoint "\nPick first point: "))
(setvar "osmode" 512)
(setq p5 (getpoint "\nPick direction of wall to insert along: "))
(setq a2 (angle p1 p5))
(setq Style (getstring "\nInsertion Point at: Wall or Vanity <W>"))
(if (= Style "")
(setq Style "W")
)
(cond ((or (= Style "W")(= Style "w"))
(setq p6 (polar p1 a2 15.5))
)
((or (= Style "V")(= Style "v"))
(setq p6 (polar p1 a2 16.5))
)
)
(setvar "lastpoint" p6)
(setvar "osmode" 128)
(setq P2 (getpoint p6 "\nPick opposite side of wall: "))
(setq a1 (angle p6 p2))
(setq Vent (getstring "\nVent size: 1.5 2 or 3 <1.5>"))
(setq p3 (polar p6 a1 (/ (distance p6 p2) 2)))
(setq p4 (polar p6 (+ a1 pi) 12))
(if (= L "0")
(setq La "1")
(setq La (substr L 1 1)))
(setq Ln (strcat La "SHELL"))
(cond ((= La "F")
(setvar "clayer" "FOUND")
)
((= La "B")
(setvar "clayer" "BSMT")
)
(T (setvar "clayer" Ln)
)
)
(if (= Vent "")
(setq Vent "1.5")
)
(setvar "OSMODE" 0)
(cond
((= B "bswc2")
(command "insert" B p6 1.0 1.0 (+ (R2D a1) 180))
)
)
(setq BV (strcat "DWV Fittings-" Vent))
(setq Ln (strcat La "FLRHH"))
(command "layer" "t" Ln "unlock" Ln "")
(setvar "clayer" Ln)
(command "insert" BV p3 1 1 0)
(command "insert" "DWV Fittings-3" p4 1 1 0)
(setq Ln (strcat La "PLUMBPU"))
(command "layer" "t" Ln "unlock" Ln "")
(setvar "clayer" Ln)
(command "insert" BV p3 1 1 0)
(command "insert" "DWV Fittings-3" p4 1 1 0)
(setq Ln (strcat La "CLGHH"))
(command "layer" "t" Ln "unlock" Ln "")
(setvar "clayer" ln)
(command "insert" BV p3 1 1 0)
(setq p3 nil)
(setq A1 nil)
(setq Ang nil)
(setq Ln nil)
(setq La nil)
(command "-layer" "s" L "")
(command "layerp")
(command "layerp")
(command "layerp")
(command "layerp")
(command "layerp")
(command "layerp")
(command "layerp")
(setvar "cmdecho" 1)
(setvar "OSMODE" os)
)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(DEFUN R2D (R)
(* (/ R PI) 180.0))
(DEFUN D2R (D)
(/ (* D PI) 180.0))
;;;; A little ERROR handling
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(DEFUN *ERROR* (msg)
(setvar "osmode" os)
(setvar "cmdecho" 1)
(setvar "clayer" L)
(setq *ERROR* ERRORSAVE)
)