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.
Solved! Go to Solution.
Solved by smaher12. Go to Solution.
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."
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)
)
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) )
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
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.
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) )