Include a "shift-down" alterna
I've tried googling this but come up empty handed.Is it possible to make a routine that does one thing normally, but something else when you keep the shift key pressed?
Just like the "trim" command executes an "extend" command when shift is presed.
My particular example is a routine that copies objects in along only the z-axis. But it would be sweet if i could keep chift pressed when selecting my reference point and copy itto same z-value but getting the x and y coordinates from my reference.
Yes i know this can be achived by regular commands using .x and .y or two separate commands, and so on but the reason we love our lisps is because we are lazy, I believe it is not possible to capture shift. But you could use (grread) to toggle your selection mode, for example to use the tab key to toggle between to modes. A grread example from not so long ago can be found here : http://www.cadtutor.net/forum/showthread.php?93966-Rotation-with-options-on-imput&highlight=rotate
You could use grread to capture whether you pressed a key or selected a point. If you pressed tab , change selection mode , if you selected a point , use that point for a getcorner selection.
Another way would be to let your routine detect the direction you make your selection , just like a window or crossing selection.
It's just for information / learning only , i'm sure there will be better examples to be found here or elsewhere.
gr. Rlx
Perish the thought ! You can capture shift & ctrl using the Express Tools (acet-sys-shift-down) & (acet-sys-control-down) functions.
Good tip! (for those who have ET on their pc).
gr. Rlx Thanks so much all of you. Got busy with other stuff but looked into the grread wich looks like it can do something acceptable.
Or maybe i should just go with what lee mac says cause his advice always seems like best practice. Ok was easy and works lika a charm. Will post here, could possibly come in handy for someone:
(defun c:mx ()(setq obj (ssget ))(setq P1 ( getpoint "\nPick basepoint : "))(setq P2 ( getpoint "\nPick X-value point : "))(if (acet-sys-shift-down);If shift-down(command "_.Move" obj "" P1 ".x" P1 P2) ;If not shift-down(command "_.Move" obj "" P1 ".x" P2 P1) );;(princ))
I know of external commands that can capture certain keys (and much more) but I can't rely with my programs on 3rd party apps to be installed. Once I decided to go basic (visual basic) and some releases later it was no longer installed standard. So that's why I try to be as generic as possible. Even here at work , some people do E&I , some do piping , some of those use CadWorx... and they all have there special needs.
If you do have ET on your pc and everybody else does too , do what Lee says and live happily everafter :-)
Gr. Rlx Happy to help
页:
[1]