PDA

View Full Version : selection set problem wblock


parkerfeldman
2009-07-22, 05:25 PM
i have a lisp that has always worked for wblocking all blocks in a drawing to a folder i added a line for an implied selection set so that i could wblock what i wanted to by selecting before. It gives me a very strange error now when the wblock command is called it asks for an insertion point and then the lisp stops. I debugged it and the problem is definitely in the (command ".-WBLOCK" fname bname) call
thanks for any help


;;; WBLOCK all blocks to folder
;;;Parker Feldman July 2009
;;;
(defun c:WBA (/ ss bname fname path blkobj i LAY LAYER LAYS)
(setting)
(setq path
(vl-filename-directory
(getfiled "Select a file in the destination folder"
""
""
0
)
)
)
(if (ssget "_I")
(setq ss (ssget "_I"))
(setq ss
(ssget "X"
(list (cons 0 "INSERT"))
)
)
) ;_end if
(setq i (- 1))
(while (ssname ss (setq i (1+ i)))
(setq
blkobj
(vlax-ename->vla-object (ssname ss i))
)
(setq layer (vla-get-layer blkobj)
lays (vla-get-layers
(vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
lay (cond ((tblsearch "LAYER" layer)
(vla-item lays layer)
)
(t (vla-add lays layer))
)
)
(if
(and (/= (vla-get-freeze lay) :vlax-true)
(= (vla-get-layeron lay) :vlax-true)
)
(progn
(if (vlax-property-available-p blkobj 'EffectiveName)
(setq bname (vla-get-effectiveName blkobj))
(setq bname (vla-get-Name blkobj))
) ;_end if
(setq fname (strcat path "\\" bname ".DWG"))
(vl-file-delete fname)
(princ (strcat fname " - " bname))
(terpri)
(command ".-WBLOCK" fname bname)
) ;_end progn
) ;_end if
) ;_ end of repeat
(resetting)
(princ)
) ;_ end of defun

parkerfeldman
2009-07-22, 07:04 PM
okay i figured it out. it had to do with the blocks still being selected when it went to the wblock so instead of asking for the name it asks for an insertion point for the block to be wblocked. here is my revised lisp. very useful if you have a block library


;;; WBLOCK all blocks or preselected blocks to folder
;;; Parker Feldman
;;; July 2009
;;;
(defun c:WBA (/ ss bname fname path blkobj i LAY LAYER LAYS IPT)
(setq path
(vl-filename-directory
(getfiled "Select a file in the destination folder"
""
""
0
)
)
)
(setq i (- 1))
(if (setq ss (ssget "_I"))
(progn
(while (ssname ss (setq i (1+ i)))
(setq blkobj (vlax-ename->vla-object (ssname ss i)))
(if (vlax-property-available-p blkobj 'EffectiveName)
(setq bname (vla-get-effectiveName blkobj))
(setq bname (vla-get-Name blkobj))
) ;_end if
(setq fname (strcat path "\\" bname ".DWG"))
(vl-file-delete fname)
(setq ipt (vlax-safearray->list
(vlax-variant-value
(vla-get-insertionpoint blkobj)
)
)
)
(command ".-WBLOCK" fname ipt)
(princ (strcat fname " - " bname))
(terpri)
) ;_ end of while
) ;_end progn
(progn
(setq ss
(ssget "X"
(list (cons 0 "INSERT"))
)
)
(while (ssname ss (setq i (1+ i)))
(setq blkobj (vlax-ename->vla-object (ssname ss i)))
(setq layer (vla-get-layer blkobj)
lays (vla-get-layers
(vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
lay (cond ((tblsearch "LAYER" layer)
(vla-item lays layer)
)
(t (vla-add lays layer))
)
)
(if
(and (/= (vla-get-freeze lay) :vlax-true)
(= (vla-get-layeron lay) :vlax-true)
)
(progn
(if (vlax-property-available-p blkobj 'EffectiveName)
(setq bname (vla-get-effectiveName blkobj))
(setq bname (vla-get-Name blkobj))
) ;_end if
(setq fname (strcat path "\\" bname ".DWG"))
(vl-file-delete fname)
(command ".-WBLOCK" fname bname)
(princ (strcat fname " - " bname))
(terpri)
) ;_end progn
) ;_end if
) ;_ end of while
) ;_end progn
) ;_end if
(princ)
) ;_ end of defun