Author Topic: Lisp to explode a block with dimensions keeping it as seen in block  (Read 2637 times)

0 Members and 1 Guest are viewing this topic.

pbelon

  • Mosquito
  • Posts: 7
Hello everybody,

I's my first time I write here. Sorry for my writing ...

I have a lot o blocks from diferent details with dimensions that I need to explode. When I explode it, the dimensions change getting diferent as seen with the block. żIs there any lisp that could read the block dimensions and aply an scale to allow see it as before?

Thanks

ChrisCarlson

  • Guest
Do you have a sample block?

pbelon

  • Mosquito
  • Posts: 7
I dont know how to show it....

pbelon

  • Mosquito
  • Posts: 7
BEFORE AND AFTER EXPLODING.

There is a lot of scale and dimensions types. So, it's a problem to be changing them each time I insert a detail.


pbelon

  • Mosquito
  • Posts: 7
after exploding....

ChrisCarlson

  • Guest
Meant can you attach a sample block (.dwg)

ahsattarian

  • Newt
  • Posts: 113
Re: Lisp to explode a block with dimensions keeping it as seen in block
« Reply #6 on: December 12, 2023, 05:08:47 AM »
Have a look at this   :



Code - Auto/Visual Lisp: [Select]
  1. (defun c:xx ()
  2.   (princ "\n Select Blocks to Scale-up Dimensions : ")
  3.   (setq ss (ssget ":l" '((0 . "INSERT"))))
  4.   (setq n (sslength ss))
  5.   (setq k -1)
  6.   (repeat n
  7.     (setq k (1+ k))
  8.     (setq s (ssname ss k))
  9.     (setq en (entget s '("*")))
  10.     (setq sc (cdr (assoc 41 en)))
  11.     (setq obj (vlax-ename->vla-object s))
  12.     (if (eq :vlax-true (vla-get-hasattributes obj))
  13.       (progn
  14.         (setq att 1)
  15.         (setq objattlist (vlax-safearray->list (vlax-variant-value (vla-getattributes obj))))
  16.         (setq attli nil)
  17.         (foreach a objattlist (setq tex (vla-get-textstring a)) (setq attli (append attli (list tex))))
  18.         (setq i -1)
  19.       )
  20.       (setq att 0)
  21.     )
  22.     (command "explode" s) ;|  #Explode  |;
  23.     (setq ss1 (ssget "p"))
  24.     (setq objli nil)
  25.     (setq n1 (sslength ss1))
  26.     (setq k1 -1)
  27.     (repeat n1
  28.       (setq k1 (1+ k1))
  29.       (setq s1 (ssname ss1 k1))
  30.       (setq obj1 (vlax-ename->vla-object s1))
  31.       (setq objli (append objli (list obj1)))
  32.     )
  33.     (foreach obj1 objli
  34.       (setq s1 (vlax-vla-object->ename obj1))
  35.       (setq en1 (entget s1 '("*")))
  36.       (setq typ1 (cdr (assoc 0 en1)))
  37.       ;;  LineType Scale  >>
  38.       (cond
  39.         ((vlax-property-available-p obj1 'linetypescale)
  40.          (setq sc1 (vlax-get-property obj1 'linetypescale))
  41.          (vlax-put-property obj1 'linetypescale (abs (* sc1 sc)))
  42.         )
  43.       )
  44.       ;;  Dim Scale Linear  >>
  45.       (cond
  46.         ((vlax-property-available-p obj1 'linearscalefactor)
  47.          (setq sc1 (vlax-get-property obj1 'linearscalefactor))
  48.          (vlax-put-property obj1 'linearscalefactor (abs (/ sc1 sc)))
  49.         )
  50.       )
  51.       ;;  Dim Scale Overall  >>
  52.       (cond
  53.         ((and (vlax-property-available-p obj1 'ScaleFactor) (member typ1 '("DIMENSION" "LEADER")))
  54.          (setq sc1 (vlax-get-property obj1 'ScaleFactor))
  55.          (vlax-put-property obj1 'ScaleFactor (abs (* sc1 sc)))
  56.         )
  57.       )
  58.       ;;  #Attribute 2 Text  >>
  59.       (cond
  60.         ((and (= att 1) (member typ1 '("ATTRIB" "ATTDEF")))
  61.          (setq i (1+ i))
  62.          (setq new '((0 . "TEXT")))
  63.          ;;(setq new (append new (list (cons 1 (cdr (assoc 2 en1))))))
  64.          (setq tex (nth i attli))
  65.          (setq new (append new (list (cons 1 tex))))
  66.          (setq dolst (list 7 8 10 11 39 40 41 50 51 62 71 72 73))
  67.          (foreach grp dolst
  68.            (setq addto (assoc grp en1))
  69.            (cond ((/= addto nil) (setq new (append new (list (assoc grp en1))))))
  70.          )
  71.          (setq addto (assoc 74 en1))
  72.          (cond ((/= addto nil) (setq new (subst (cons 73 (cdr (assoc 74 en1))) (assoc 73 new) new))))
  73.          (entdel s1)
  74.          (entmake new)
  75.         )
  76.       )
  77.     )
  78.   )
  79.   (princ)
  80. )