Abrasive Posted August 6 Posted August 6 I'm not sure if it's possible but... I use 4 DIM styles almost exclusively. What I would like to do is start a command that activates a specific DIM style, (then measure distance) Press a key and change DIM style, activate "continue DIM" and use the new style for this function. Press a different key, change to a different DIM style then activate "continue DIM" again and use the new style for this function. Finally press a 4th key, change to a different DIM style and NOT activate "continue DIM" ( just activate specific DIM style ). One problem I had is when changing dim style and activating continue it uses the previous style instead of the new one. I tried a couple of things but made a mess of it...lol Any help would be appreciated. Thank you Quote
Steven P Posted August 6 Posted August 6 Let us have a look at what you have put together, you might be close with what you have. Quote
CyberAngel Posted August 6 Posted August 6 Are you using the same series of styles every time? For instance, the first dimension is always Style1, the second is Style2, and so on. That would make the function easier to write. If not, you could use a loop, get a style based on user input of a key, and use a cond statement to set the style based on the input. That way the style can change each time, and you can cycle through the loop as many times as you like. Another option is an association list containing dotted pairs, each with a key and a style name; each time the style changes, use the input to look up the name. Quote
Abrasive Posted August 6 Author Posted August 6 (edited) @CyberAngel I am using the same styles every time, and in the same order. @Steven P the routines I have only change the dimension style by running the routine. I tried to figure out how to use keys to activate them but couldn't find much... (defun c:CDS8EA ( ) (command "Layer" "M" "FINAL MEAS" "") (command "-dimstyle" "R" "8 ALN END ARROW") (command "_LINEARDIMENSION") ) Edited August 6 by Abrasive Quote
mhupp Posted August 6 Posted August 6 I Have a pan macro base on what number pad key I press affected what direction it would pan. very helpful for grid layouts I did. I'll post it later. Quote
pkenewell Posted August 6 Posted August 6 Maybe something like this? Change the Dimstyle names in the (cond) statement to match your dimension styles. You can also change the wording between the "[...]" in the getpoint prompt as long as you keep the "1-, 2-." etc. on the front of each option. You could also change the default option to "Exit" if you change the option in the "<...>" of the prompt and the code line (if (not p1)(setq p1 "1")) to "Exit" as well. ;;Written by PJK 8/6/2024 (defun C:LDIM (/ p1) (initget "1 2 3 4 Exit") (while (and (/= (type (setq p1 (getpoint "\nSelect first point for Linear Dimension or [1-Style1/2-Style2/3-Style3/4-Style4/Exit] <1-Style1>: "))) 'LIST) (/= p1 "Exit") ) (if (not p1)(setq p1 "1")) (cond ((= p1 "1")(command "._-dimstyle" "_r" "MyDimStyle1"));; Change Dim Style Names to Your preferences. ((= p1 "2")(command "._-dimstyle" "_r" "MyDimStyle2")) ((= p1 "3")(command "._-dimstyle" "_r" "MyDimStyle3")) ((= p1 "4")(command "._-dimstyle" "_r" "MyDimStyle4")) ) (initget "1 2 3 4 Exit") ) (if (= (type p1) 'LIST) (progn (command "._dimlinear" p1) (while (= (logand (getvar "cmdactive") 1) 1) (command pause) ) ) ) (princ) ) 1 Quote
BIGAL Posted August 6 Posted August 6 My $0.05 i would use defun names like S1 S2 etc very short to type, you can also have dim styles in a pop menu. Quote
mhupp Posted August 7 Posted August 7 So its pretty simple using grread to run sub commands allowing you to switch between the four different types. kinda follows the same principles of pkenewell's code. except its four smaller lisps called from one main lisp. if you wanted to use other buttons you would have to look them up. I think those are for the numpad keys. (defun c:CDS8EA () (entmake '((0 . "LAYER") (100 . "AcDbSymbolTableRecord") (100 . "AcDbLayerTableRecord") (2 . "FINAL MEAS") (70 . 0) (62 . 1) (290 . 0))) ;change 62 to the coler you want (setvar 'clayer "FINAL MEAS") (command "-dimstyle" "R" "8 ALN END ARROW") (while (setq pt (getpoint)) (command "_.LINEARDIMENSION" pt) (while (= (getvar "cmdactive") 1) (command pause) ) ) ) (defun C:MyDims (/ *error* P thisdrawing) (defun *error* () (vl-cmdf nil nil nil) ;clear (if (not (member *error* '("Console break" "Function cancelled" "quit / exit abort"))) (princ (strcat "\nError: " errmsg)) ) (setvar 'cmdecho 1) ) (setvar 'cmdecho 0) (setq P T) (setq thisdrawing (vla-get-activedocument (vlax-get-acad-object))) (prompt "\nUse Enter to Exit") (while P (while (/= (car (setq key (grread))) 2)) (setq key (cadr key)) (cond ((= key 49) ;#1 key (C:CDS8EA) ) ((= key 50) ;#2 key ) ((= key 51) ;#3 key ) ((= key 52) ;#4 key ) ((= key 53) ;#5 key ) ((= key 54) ;#6 key ) ((= key 55) ;#7 key ) ((= key 56) ;#8 key ) ((= key 57) ;#9 key ) ((= key 13) ;#Enter key (setq P nil) ) ) ) (setvar 'cmdecho 1) (princ) ) 2 Quote
Steven P Posted August 7 Posted August 7 Didn't have time for this one yesterday, but I'd have gone grread and perhaps see if the arrow keys would work Quote
Abrasive Posted August 7 Author Posted August 7 Thank you everyone! @mhupp I really like the use of grread, @pkenewell 's code worked well too. These will get me where I need. @BIGAL As always thank you. I am trying to avoid using DCL for this one, I'm getting lazy and just want to hit a key a few hundred time a day....lol Thanks Again. 1 1 Quote
mhupp Posted August 7 Posted August 7 4 hours ago, Steven P said: Didn't have time for this one yesterday, but I'd have gone grread and perhaps see if the arrow keys would work looks like arrow keys are 37-40 I only used the numpad with that command but according to this its 96-105 maybe grread defaults to both ? 1 Quote
BIGAL Posted August 7 Posted August 7 (edited) @Abrasive still think S1 s2 is about as simple as it gets, popping the dcl can be very fast I use my Multi radio buttons. The 1st time is a little slow as it loads but from then on is fast. It can be set to remember last used so just hit enter or pick. Try it. Easy to add more choices. (if (not AH:Butts)(load "Multi radio buttons.lsp")) ; loads the program if not loaded already (if (= defbut nil)(setq defbut 1)) ; this is needed to set default button (setq ans (ah:butts defbut "V" '("Choose Dim style " "Dim style A" "Dim style B" "Dim style C" "Dim style D" ))) ; ans holds the button picked value as a string (setq defbut but) Multi radio buttons.lsp Edited August 7 by BIGAL 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.