Author Topic: Xplode Control  (Read 2971 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2081
Xplode Control
« on: July 18, 2006, 02:49:06 PM »
I'm looking for ways to improve the following...

Code: [Select]
(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)
)

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Xplode Control
« Reply #1 on: July 18, 2006, 02:59:34 PM »
Combind the two codes to lock and unlock, with asking for an argument.
Code: [Select]
(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))
Then call it like
Code: [Select]
(defun C:XPL (/ tmp)
  (initget "Lock Unlock") 
  (if (/= (getkword "\n* Select Xplode Type:  <L>ock   Unlock * " ) "Unlock")
   (XpProp :vlax-false)
   (XpProp :vlax-true)
  )
  (princ)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Xplode Control
« Reply #2 on: July 18, 2006, 03:01:02 PM »
Tim

Thanks

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Xplode Control
« Reply #3 on: July 18, 2006, 03:04:14 PM »
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).
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: Xplode Control
« Reply #4 on: July 18, 2006, 03:05:44 PM »
Do you guys do not like the use of "[" .... "]" (context menu) for the getword function ?

Code: [Select]
(getkword "\nSelect Xplode Type [Lock/Unlock]:  " )

GDF

  • Water Moccasin
  • Posts: 2081
Re: Xplode Control
« Reply #5 on: July 18, 2006, 03:12:57 PM »
Do you guys do not like the use of "[" .... "]" (context menu) for the getword function ?

Code: [Select]
(getkword "\nSelect Xplode Type [Lock/Unlock]:  " )

Luis

Your right, I keep forgetting that. Bad doggy...

Tim

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).

Tim

Thanks again.

I replaced the error alert with:
(ARCH:MsgBox " Xplode Property Lock" 48 "This not a Block\nPlease try again.")
beginning message:
(ARCH:MsgBox " Xplode Property Lock" 64 "Please select a Block\to Lock the Xplode Property.")
or something similar.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Xplode Control
« Reply #6 on: July 18, 2006, 03:25:23 PM »
Do you guys do not like the use of "[" .... "]" (context menu) for the getword function ?

Code: [Select]
(getkword "\nSelect Xplode Type [Lock/Unlock]:  " )
I do.  It was just a quick fix for what Gary wanted.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Xplode Control
« Reply #7 on: July 18, 2006, 05:45:53 PM »
Another idea, untested.
Code: [Select]
(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))
« Last Edit: July 18, 2006, 05:53:40 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Xplode Control
« Reply #8 on: July 19, 2006, 11:31:50 AM »
Alan

Thanks

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64