Somewhat strange request - multiply an entered value by a constant when entering it...
Comments
-
Hi John,Your request is not strange. I have encountered requests like this from users.
Here are two small functions that you can call off the command line when a CAD command is in progress.
(fn val) will scale any real value multiplied by a factor and send it to the command in question.
(ptfn) will scale the X, Y and Z of a picked point multiplied by a factor and send it to the command in question.
You can modify the functions to apply any complex transformation, not just a simple multiplication arithmetic as shown here.
Hope thsi helps
- Rakesh Rao
http://rakeshrao.typepad.com[code]
; Function 'fn' will process any value and apply a multiplication factor
(defun fn ( val / fac )
(setq fac 1.1)
( * val fac)
); Function 'ptfn' will process any point input and apply a multiplication factor
(defun ptfn ( / pt fac )
(initget 1)
(setq
fac 1.1
pt (getpoint)
pt (list (* (car pt) fac) (* (cadr pt) fac) (* (caddr pt) fac))
)
pt
)
[/code]0 -
Thank you for this suggestion. As I understand it (and as I've tried this solution just now) it seems that to enter my value in the offset command, for instance, I would type:OFFSET(fn 6)and that would use 6x the constant defined in FN as my input.The downside of this is that is requires a lot of extra typing for each entry -- I have to type out the parenthesis, etc. each time. I'm entering a lot of numbers, so I was hoping to find a solution that did not use more keystrokes than the usual method of typing SPACE or ENTER to terminate the entry.Is there any way to accomplish this with a redefined command key or something? It would be nice if there were an Autocad system variable that applied a scale factor to all input like this, but I can't find such a thing.0
-
Try the code below and use a keyboard shortcut with the command 'SI (note the apostrophe). I am also attaching the code.
[code](defun c:SI ( / input scale)
(setq *ScaleInput*
(cond
(*ScaleInput*
)
(1.0
)
)
)
(while (not input)
(initget "Scale eXit")
(setq input (getdist (strcat "\nCurrent scale=" (rtos *ScaleInput*) ": Scale/eXit/<Input>: ")))
(if (= input "Scale")
(progn
(if (numberp (setq scale (getdist (strcat "\nCurrent scale=" (rtos *ScaleInput*) ": New scale: "))))
(setq *ScaleInput* scale)
)
(setq input nil)
)
)
)
(if (numberp input)
(* input *ScaleInput*)
)
)[/code]0 -
... Of course you have to enter the keyboard shortcut BEFORE entering the numerical value and then finish with enter or space. So ScaleInput minimizes extra keystrokes but does not do away with them.0
-
Hi John,
depending what you are trying to do, you could draw the complete object first and then apply the scaling afterwards, such as an component detailed in inches that you want to draw in a metric drawing.
Regards,Jason Bourhill
0 -
Roy,That helps! I'm very close now. One more question -- how do I assign a function key to something that is not already listed in the "keyboard" tab in the customize dialog box. I can assign this to something already there (like the Page Down key) but I don't see how to add a key that is not listed (such as the Right Arrow key) and then assign to that.Thanks.0
-
Roy,That helps! I'm very close now. One more question -- how do I assign a function key to something that is not already listed in the "keyboard" tab in the customize dialog box. I can assign this to something already there (like the Page Down key) but I don't see how to add a key that is not listed (such as the Right Arrow key) and then assign to that.Thanks.
have a look autohotkey @ www.autohotkey.com
it's the coolest thing since sliced bread! a must have tool for the cad user.
0 -
@ John:
You just append a shortcut, select a command and finish by typing your key combination. See attached image. You may want to check if your key combination is not already being used.
@ Daniel:
You are right, you could use www.autohotkey.com (or www.autoitscript.com) to accomplish this.
Love your new avatar!Add_Keyboard_Shortcut.png0 -
Thanks for all your help! That worked great.0