Author Topic: Block property  (Read 1349 times)

0 Members and 1 Guest are viewing this topic.

mohan

  • Newt
  • Posts: 98
Block property
« on: January 10, 2022, 10:53:19 AM »
Help me to fix minor error . . .
Code: [Select]
(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))
"Save Energy"

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Block property
« Reply #1 on: January 11, 2022, 02:43:42 AM »
I assume:
Code: [Select]
(if (not (setq ss (ssget "_X" '((0 . "INSERT") (2 . "blockname") (410 . "Model")))))Should be:
Code: [Select]
(if (not (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 bName) '(410 . "Model")))))

mohan

  • Newt
  • Posts: 98
Re: Block property
« Reply #2 on: January 11, 2022, 03:19:48 AM »
; error: bad SSGET list value
"Save Energy"

mhupp

  • Bull Frog
  • Posts: 250
Re: Block property
« Reply #3 on: January 11, 2022, 12:48:29 PM »
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?

Code - Auto/Visual Lisp: [Select]
  1. (defun c:setblockpro (/ ss total cnt e bName)
  2.   (if (setq ss (ssget "_X" '((0 . "INSERT") (410 . "Model"))))  ;all blocks in model space
  3.     (progn
  4.       (foreach blk (mapcar 'cadr (ssnamex ss))
  5.         (entmod (append (entget blk) (mapcar 'cons '(41 42 43) '(50 50 1))))
  6.       )
  7.       (command "_.-PURGE" "LA" "*" "N")
  8.       (prompt (strcat "\nCBP Complete, " (itoa (sslength ss)) " blocks updated."))  ;just use sslength for count
  9.     )
  10.     (prompt "\nNo Blocks Found.")
  11.   )
  12.   (princ)
  13. )

updated code from ronjonp
« Last Edit: January 12, 2022, 03:27:57 PM by mhupp »

mohan

  • Newt
  • Posts: 98
Re: Block property
« Reply #4 on: January 16, 2022, 06:29:13 AM »
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:
« Last Edit: January 16, 2022, 06:32:26 AM by mohan »
"Save Energy"