Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Invoking command while still in DIM subcommand

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
johnw
636 Views, 9 Replies

Invoking command while still in DIM subcommand

I use the following lisp routine to dimension horizontally. Once finished running a dimension, I remain the DIM subcommand incase I wish to "cont" dimensioning, etc. However while at the DIM subcommand prompt, I cannot enter the DH command again because i get a " ** That command may not be invoked transparently **" message. Is there any way to add code to this routine that checks to see if I'm in the "Dim" subcommand prompt and if so exit out and then re-enter the DH command, and if not, just work as regular?

 

(DEFUN C:DH(/ a b )
(setvar "cmdecho" 0)
(setvar "SNAPMODE" 1)
(SETQ a (GETVAR "CLAYER"))
(IF (NOT ( = A "ELEC"))
(COMMAND "_LAYER" "S" "DIMEN" "")
)
(setq b ( rtos (getvar "dimscale") 2 1))
(prompt "\nThe DIMSCALE is currently...")(prompt b)
(COMMAND "DIM" "HORIZ")
(setvar "cmdecho" 1)
(PRIN1)
)

 

Thanks in advance!

 

John W.

9 REPLIES 9
Message 2 of 10
BlackBox_
in reply to: johnw

Methinks you'll find the CMDACTIVE system variable to be informative.

 

[Edit] - However, you're most likely not going to be able to invoke your custom command, whilst the DIM Command is active. If you prefer to re-invoke your custom commmand, simply terminate the DIM command, either within your custom command, or via esc, etc.

 

Cheers



"How we think determines what we do, and what we do determines what we get."

Message 3 of 10
johnw
in reply to: BlackBox_

Thanks for that tidbit of info! How would you use it in my routine?
Message 4 of 10
dbroad
in reply to: johnw

This a really low-tech answer:  Change the name of your routine to C:HOR and change "layer' "s" to "layer" "m" if you're not going to check whether it exists.

 

 

(DEFUN C:HOR(/ a b )
(setvar "cmdecho" 0)
(setvar "SNAPMODE" 1)
(SETQ a (GETVAR "CLAYER"))
(IF (NOT ( = A "ELEC"))
(COMMAND "_LAYER" "M"" DIMEN" "")
)
(setq b ( rtos (getvar "dimscale") 2 1))
(prompt "\nThe DIMSCALE is currently...")(prompt b)
(COMMAND "DIM" "HORIZ")
(setvar "cmdecho" 1)
(PRIN1)
)

Architect, Registered NC, VA, SC, & GA.
Message 5 of 10
smaher12
in reply to: johnw

Why not use dimlinear command?

 

(defun C:DH (/ cmde sm cl ds )
  (setq cmde (getvar 'cmdecho))
  (setq sm (getvar 'snapmode))
  (setq cl (getvar 'clayer))
  (setvar 'cmdecho 0)
  (setvar 'snapmode 1)

   (if (not (tblsearch "LAYER" "DIMEN"))
     (command "-LAYER" "N" "DIMEN" "C" "7" "DIMEN" "S" "DIMEN" "")
   )
   (setvar 'CLAYER "DIMEN")

  (setq ds ( rtos (getvar 'dimscale) 2 1))
  (prompt (strcat "\nDimscale is currently... " ds ))(princ)
  
  (command "_.dimlinear" )
  (setvar 'cmdecho cmde)
  (setvar 'snapmode sm)
  (setvar 'clayer cl)
 (princ)
)

 

Message 6 of 10
johnw
in reply to: smaher12

That works and takes you out of the dim subcommand but now I cannot type "co" for continue since I'm out of the dim subcommand. Not sure what is the lesser of the two evils.
Thanks for taking time to do this!

 

John

Message 7 of 10
BlackBox_
in reply to: johnw


@Johnw wrote:

 

... Not sure what is the lesser of the two evils.


Right Click trumps typing <C> <O> <Enter> any day, methinks.



"How we think determines what we do, and what we do determines what we get."

Message 8 of 10
scot-65
in reply to: johnw

We use a DM routine from way back before DIMLINEAR. R12 to be exact.

I will give you the answer - you will have to wrap your function around it...

 

 

  (setq PTS (getpoint " Select all points: "))
  (setq PLST (list PTS))
  (while (setq PTS (getpoint PTS)) (setq PLST (append PLST (list PTS))) );while
  (if (and PLST (setq DLPT (getpoint "\n Select dimension line location: ")))
   (progn
    (setq osm (getvar "OSMODE")) (setvar "OSMODE" 0)
    (setq PTX (car PLST)) (setq PLST (cdr PLST))
    (foreach X PLST
     (command ".dim" "HOR" PTX X DLPT "" "exit")
     (setq PTX X)
    );foreach
    (setvar "OSMODE" osm)
   );progn
  );if

 

What this essentially does is allow the user to pick a series of points for the dimension extensions.

You can pick as many points as needed to "Get 'Er Done".

After a right-click of the mouse or [Enter] on the keyboard, specify the dimension line location.

You will notice this behaves as a DIM1 type command that has been daisy-chained to act like DIMCONTINUE.

Also notice that there is no user interaction when the command is active.

 

Good Luck.

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 9 of 10
smaher12
in reply to: johnw

Why limit youself to horizontal dim's?

 

(defun C:DH (/ cmde sm cl ds cd )
  (setq cmde (getvar 'cmdecho))
  (setq sm (getvar 'snapmode))
  (setq cl (getvar 'clayer))
  (setvar 'cmdecho 0)
  (setvar 'snapmode 1)

   (if (not (tblsearch "LAYER" "DIMEN"))
     (command "-LAYER" "N" "DIMEN" "C" "7" "DIMEN" "S" "DIMEN" "")
   )
   (setvar 'clayer "DIMEN")

  (setq ds (rtos (getvar 'dimscale) 2 1))
    (princ (strcat "\nDimscale is currently... " ds ))
      (princ "\nSpecify first extension line origin:" )
  
  (command "_.dimlinear" pause pause pause)
 
  (initget "Y N")
    (setq cd (getkword "\nContinue dimension [Yes/No] <Exit>: "))
  
  (if (= cd "Y")
    (command "_.dimcontinue")
  )
  (setvar 'cmdecho cmde)
  (setvar 'snapmode sm)
  (setvar 'clayer cl)
 (princ)
)

 

 

 

Message 10 of 10
johnw
in reply to: smaher12

Thanks for all the input! I appreciate the help for sure!

 

John

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost