TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: mohan on January 10, 2022, 10:53:19 AM
-
Help me to fix minor error . . .
(defun c:setblockpro ( / ss cnt e bName)
(if (not (setq ss (ssget "_X" '((0 . "INSERT") (2 . "blockname") (410 . "Model")))))
(progn (prompt "\n...No blocks found.") (exit)))
(setq total 0)
(repeat (setq cnt (sslength ss))
(setq e (ssname ss (setq cnt (1- cnt)))
bName (strcase (getpropertyvalue e "BlockTableRecord/Name")))
(foreach i e
(if (eq bName (strcase (car i)))
(progn
(setpropertyvalue e "ScaleFactors/X" 50)
(setpropertyvalue e "ScaleFactors/Y" 50)
(setpropertyvalue e "ScaleFactors/Z" 1)
(setq total (1+ total))))))
(command "_.-PURGE" "LA" "*" "N")
(prompt (strcat "\nCBP Complete, " (itoa total) " blocks updated."))
(princ))
-
I assume:
(if (not (setq ss (ssget "_X" '((0 . "INSERT") (2 . "blockname") (410 . "Model")))))
Should be:
(if (not (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 bName) '(410 . "Model")))))
-
; error: bad SSGET list value
-
Need a little more info.
What is it you want your lisp to do.
What is the error your getting.
like roy_043 said your ssget is looking for a block by the name of blockname is that intended? is this suppose to run on all blocks?
(defun c:setblockpro
(/ ss total cnt e bName
) (if (setq ss
(ssget "_X" '
((0 .
"INSERT") (410 .
"Model")))) ;all blocks in model space )
)
)
)
updated code from ronjonp
-
updated code from ronjonp
:-o ooh my God ! This code looks totally different, ooh you have updated
Please kindly place the previous code below, because I didn't do copy before, it is for my learning purpose.
It is wonderful to know there were many ways to write program for same goal.
thanks a lot . . . :smitten: