Author Topic: How to keep short cuts with redefined commands  (Read 2331 times)

0 Members and 1 Guest are viewing this topic.

ROBBO

  • Bull Frog
  • Posts: 217
How to keep short cuts with redefined commands
« 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.
The only thing to do with good advice is to pass it on.
It is never of any use to oneself.

Oscar Wilde
(1854-1900, Irish playwright, poet and writer)

DanB

  • Bull Frog
  • Posts: 367
Re: How to keep short cuts with redefined commands
« Reply #1 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)
  )

ROBBO

  • Bull Frog
  • Posts: 217
Re: How to keep short cuts with redefined commands
« Reply #2 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))
;;-------------------------------------------------------------------------------

 
« Last Edit: May 13, 2014, 03:25:06 AM by ROBBO »
The only thing to do with good advice is to pass it on.
It is never of any use to oneself.

Oscar Wilde
(1854-1900, Irish playwright, poet and writer)

Crank

  • Water Moccasin
  • Posts: 1503
Re: How to keep short cuts with redefined commands
« Reply #3 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?
Vault Professional 2023     +     AEC Collection

ROBBO

  • Bull Frog
  • Posts: 217
Re: How to keep short cuts with redefined commands
« Reply #4 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.
The only thing to do with good advice is to pass it on.
It is never of any use to oneself.

Oscar Wilde
(1854-1900, Irish playwright, poet and writer)

ROBBO

  • Bull Frog
  • Posts: 217
Re: How to keep short cuts with redefined commands
« Reply #5 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)
)
The only thing to do with good advice is to pass it on.
It is never of any use to oneself.

Oscar Wilde
(1854-1900, Irish playwright, poet and writer)