0 Members and 1 Guest are viewing this topic.
(defun XPL-IT (/ item vo itemname blkname) (if (and (setq item (car (entsel "\n* Select Block to Lock *"))) (setq vo (vlax-ename->vla-object item)) (null (vl-catch-all-error-p (setq itemname (vl-catch-all-apply 'vlax-get-property (list vo 'name)))))) (setq blkname itemname) (alert "Not a Block")) (setq blocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (setq blkdef (vla-item blocks blkname)) (vla-put-Explodable blkdef :vlax-false) (princ))(defun XPU-IT (/ item vo itemname blkname) (if (and (setq item (car (entsel "\n* Select Block to Lock *"))) (setq vo (vlax-ename->vla-object item)) (null (vl-catch-all-error-p (setq itemname (vl-catch-all-apply 'vlax-get-property (list vo 'name)))))) (setq blkname itemname) (alert "Not a Block")) (setq blocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (setq blkdef (vla-item blocks blkname)) (vla-put-Explodable blkdef :vlax-true) (princ));;;(defun C:XPL (/ tmp) (initget "L U") (setq tmp (getkword "\n* Select Xplode Type: <L>ock <U>nlock *" ) ) (initget 7) ;;disallow null,zero & negative (cond ((= tmp "L")(XPL-IT)) ((= tmp "U")(XPU-IT)) ) (princ))
(defun XpProp (PropSet / item vo itemname blkname) (if (and (setq item (car (entsel "\n* Select Block *"))) (setq vo (vlax-ename->vla-object item)) (null (vl-catch-all-error-p (setq itemname (vl-catch-all-apply 'vlax-get-property (list vo 'name)))))) (setq blkname itemname) (alert "Not a Block")) (setq blocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (setq blkdef (vla-item blocks blkname)) (vla-put-Explodable blkdef PropSet) (princ))
(defun C:XPL (/ tmp) (initget "Lock Unlock") (if (/= (getkword "\n* Select Xplode Type: <L>ock Unlock * " ) "Unlock") (XpProp :vlax-false) (XpProp :vlax-true) ) (princ))
(getkword "\nSelect Xplode Type [Lock/Unlock]: " )
Do you guys do not like the use of "[" .... "]" (context menu) for the getword function ?Code: [Select](getkword "\nSelect Xplode Type [Lock/Unlock]: " )
You're welcome. I would put it into one function, no need to have have two, IMO. If you wanted to, you could even have a prompt telling the user they are selecting a block to lock or unlock (I took that out).
(defun xpprop (propset / item vo itemname blkname typ) (setq typ (if (eq propset :vlax-false) "Lock" "Unlock")) (if (and (setq item (car (entsel "\n* Select Block to " typ " *"))) (setq vo (vlax-ename->vla-object item)) (null (vl-catch-all-error-p (setq itemname (vl-catch-all-apply 'vlax-get-property (list vo 'name))) ) ) ) (progn (setq blkname itemname) (setq blocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (setq blkdef (vla-item blocks blkname)) (vla-put-explodable blkdef propset) ) (alert "Not a Block") ) (princ))(defun c:xpl () (xpprop :vlax-false) (princ))(defun c:xpul () (xpprop :vlax-true) (princ))