Allow exploding outside the block editor

Allow exploding outside the block editor

Anonymous
Not applicable
4,515 Views
10 Replies
Message 1 of 11

Allow exploding outside the block editor

Anonymous
Not applicable

i need to change the properties  (allow exploding "yes" "no") of block outside the block editor

0 Likes
Accepted solutions (2)
4,516 Views
10 Replies
Replies (10)
Message 2 of 11

_gile
Consultant
Consultant

Hi,

 

You can change the Explodable ActiveX property of the block definition:

 

(setq doc (vla-get-Activedocument (vlax-get-acad-object)))
(vla-put-Explodable (vla-Item (vla-get-Blocks doc) blockName) :vlax-true)

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 11

_gile
Consultant
Consultant

Another way using entmod (this one should also work with MAC)

 

(setq dxf (entget (cdr (assoc 330 (entget (tblobjname "block" blockName))))))
(entmod (subst '(280 . 1) (assoc 280 dxf) dxf))


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 4 of 11

Anonymous
Not applicable

IT IS WINDOWS

HOW IT WILL WORK

NO IDEA

ITS NOT LISP

0 Likes
Message 5 of 11

_gile
Consultant
Consultant

Both snippets I posted are LISP and both will work on Window.

Just replace 'blockName' with the block name.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 6 of 11

_gile
Consultant
Consultant
Accepted solution

I thought you were asking for help to write a routine by yourself.
Looks like you're hoping for a ready-made program instead.

 

(defun c:SETEXP (/ name blk btr expl opt)
  (while
    (not
      (and
        (setq name (getstring "\nEnter the block name: "))
        (setq blk (tblobjname "block" name))
      )
    )
     (prompt (strcat "\nBlock '" name "' not found"))
  )
  (setq btr  (entget (cdr (assoc 330 (entget blk))))
        expl (cdr (assoc 280 btr))
  )
  (initget "Yes No")
  (if (setq opt (getkword
                  (strcat "\nSet explodable [Yes/No] <"
                          (if (= 0 expl)
                            "No"
                            "Yes"
                          )
                          ">: "
                  )
                )
      )
    (if (= opt "Yes")
      (if (= 0 expl)
        (entmod (subst '(280 . 1) (assoc 280 btr) btr))
      )
      (if (= 1 expl)
        (entmod (subst '(280 . 0) (assoc 280 btr) btr))
      )
    )
  )
  (princ)
)


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 7 of 11

Anonymous
Not applicable

waw

its really i am asking

can you modify it-like select multiple block instead of asking the block name

0 Likes
Message 8 of 11

_gile
Consultant
Consultant
Accepted solution
(defun c:SETEXP (/ distinct setExplodable ss opt i lst)
  
  (defun distinct (l)
    (if l
      (cons (car l) (distinct (vl-remove (car l) l)))
    )
  )
  
  (defun setExplodable (name opt / btr)
    (setq btr (entget (cdr (assoc 330 (entget (tblobjname "block" name))))))
    (entmod (subst (cons 280 opt) (assoc 280 btr) btr))
  )
  
  (if (setq ss (ssget '((0 . "INSERT"))))
    (progn
      (initget 1 "Yes No")
      (setq opt (if (= (getkword "\nSet explodable [Yes/No]: ") "Yes")
                  1
                  0
                )
      )
      (repeat (setq i (sslength ss))
        (setq lst (cons (cdr (assoc 2 (entget (ssname ss (setq i (1- i)))))) lst))
      )
      (foreach n (distinct lst)
        (setExplodable n opt)
      )
    )
  )
  (princ)
)


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 9 of 11

Anonymous
Not applicable

Excellent, thank you!

0 Likes
Message 10 of 11

jzweygardt
Participant
Participant

That is brilliant! Thanks so much. This is going to help me A LOT. 🙂

0 Likes
Message 11 of 11

jzweygardt
Participant
Participant

Just curious, what would it take to modify this so it automatically selects all the blocks and makes them explodeable? 

0 Likes