TheSwamp

CAD Forums => CAD General => Topic started by: ROBBO on May 07, 2014, 05:53:48 AM

Title: How to keep short cuts with redefined commands
Post by: ROBBO on May 07, 2014, 05:53:48 AM
Is it possible to keep associated short cuts with redefined command?

For example if the Explode Command is redefined - 'x' no longer works. How can the 'x' short cut be added to the redefined command and operate even if the entity is picked first?

Many thanks in advance.
Title: Re: How to keep short cuts with redefined commands
Post by: DanB on May 08, 2014, 04:23:47 PM
Can you use something like this? Where "new_explode" is whatever the new command is.

Code: [Select]
  (defun c:X ()
   (command "new_explode")
   (princ)
  )
Title: Re: How to keep short cuts with redefined commands
Post by: ROBBO on May 09, 2014, 02:04:44 AM
Many thanks for your reply.

I used something similar including code to prevent certain title block objects from being exploded in my Redefine.lsp, which works to a degree, but falls down on Dynamic blocks when they have an Anonymous Name too.

I originally done this for the explode command which lost its 'X' shortcut key.

Code: [Select]
;;-------------------------------------------------------------------------------
;;EXPLODE
;;-------------------------------------------------------------------------------
(command "UNDEFINE" "EXPLODE")
(defun C:EXPLODE ( / lst1 en typ)
(setq lst1 (list "BLOCK_NAME_1" "BLOCK_NAME_2" "BLOCK_NAME_3"))
(setq en (car (entsel "\nSelect objects to explode")))
(setq typ (entget en))
(setq typ (cdr (assoc 2 typ)))
(if (member typ lst1)
(alert "\nThis block cannot be exploded.")

(progn
(command ^c^c)
(command ".EXPLODE" en)
)
)
(princ)
)
(princ)
;;-------------------------------------------------------------------------------
(defun c:x ()(c:explode))
;;-------------------------------------------------------------------------------

 
Title: Re: How to keep short cuts with redefined commands
Post by: Crank on May 10, 2014, 03:41:14 AM
1:
Code: [Select]
(defun c:x ()(c:explode))

2:
Why don't you just change the properties of your title block to unexplodable?
Title: Re: How to keep short cuts with redefined commands
Post by: ROBBO on May 11, 2014, 04:36:49 AM
Valid points Crank. With regard to point 2 - unfortunately the block creation is out of my control. Need to prevent some users exploding these blocks and use the attribute and field data asociated with them.
Many thanks,  Robbo.
Title: Re: How to keep short cuts with redefined commands
Post by: ROBBO on May 13, 2014, 03:33:17 AM
I have this routine to prevent tables from being exploded in AutoCAD. How can this be incorporated in to the redifined explode command in the above routine?

Many thanks in advance, Robbo.

Code: [Select]
(defun c:explode (/ oce ss)
(princ "\nSelect objects to explode")
(if
(setq ss (ssget (list (cons 0 "~ACAD_TABLE"))))
(progn
(sssetfirst ss ss)
(setq oce (getvar "cmdecho"))
(setvar "cmdecho" 0)
(command "_.explode")
(setvar "cmdecho" oce)
)
)
(princ)
)