Boa Tarde pessoal,
Alguem poderia me ajudar a fazer uma pequena modificação neste lisp.
Bom, este lisp serve para trocar um determinado bloco por outro a sua escolha. Existem 2 opções de seleção do bloco a ser substituido: Single e Global.
EU gostaria de alterar a opção Single, nesta opção ela permite apenas uma seleção o nome já diz, "single". Queria mudar este modo de seleção, gostaria que eu selecionasse manualmente quantos blocos que eu quisesse, não apenas 1 mas vários.
Code:
(defun c:blkreplacer (/ answr ent idx newname obj ss)
(vl-load-com)
;;setup default on first run
(if (not jmm-replaceall)
(setq jmm-replaceall "Single")
)
(command ".undo" "be")
;;if the user selects something, inputs a ne block name AND it exists in the dwg...
(if (and (setq ss (ssget ":S" '((0 . "INSERT"))))
(progn
(initget "Single Global")
(if (setq answr (getkword "\nReplace just this block or Globally replace?[Single/Global]: "))
(setq jmm-replaceall answr)
(setq answr jmm-replaceall)
)
)
(setq newname (getstring "\nBlock name to replace with: "))
(tblobjname "BLOCK" newname)
)
(progn
(if (eq jmm-replaceall "Global");;get ALL occurances if it's Global, else use the original ss
(setq ss (ssget "x" (list '(0 . "INSERT") (assoc 2 (entget (ssname ss 0))))))
)
(setq idx -1)
(while (setq ent (ssname ss (setq idx (1+ idx))))
(setq obj (vlax-ename->vla-object ent))
(vla-put-name obj newname);;change the name
(vla-update obj)
)
)
)
(command ".undo" "end")
(princ (strcat "\nReplaced " (itoa idx) " blocks......"))
(princ)
)
Obrigado, pessoal!