OMEGA-ThundeR Posted July 11, 2013 Share Posted July 11, 2013 Hi, I want to be able to just type in the viewport scale i want. Manually in a active viewport i have to type 'Zoom' > 'Scale' > 1xp (1:1000). i allready got it 'lisped' that when i enter '1' in the viewport the scale goes to 1:1000, and when i enter 4 it goes 1:250 and so on. For some drawings it doesn't matter what scale it is, but then i have to do to many actions to change it (2 mouseclicks is allready to much for me). So i want to create a lisp. (Defun C:v () (command "_zoom" "scale" pause) (princ) ) This is what i got. Just plain and simple. The pause gives me manual input and i have to end my input with 'xp' for the right scale. Zoom > Scale > 22 is not the same as Zoom > Scale > 22xp But i don't want to ad the XP in the end. So i kinda want that it's predefined and added automaticly when i type in '22' and then >enter Is that possible? Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 11, 2013 Share Posted July 11, 2013 (defun c:FOO (/ scale) (if (setq scale (getreal "\nEnter a zoom scale factor: ")) (command "._zoom" "scale" (strcat (rtos scale 2 2) "xp")) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
feargt Posted July 11, 2013 Share Posted July 11, 2013 (edited) (Defun C:v (/ userscale) (setq userscale (strcat (getstring "enter required scale:") "xp")) (command "_zoom" "_scale" userscale) (princ) ) Edited July 11, 2013 by feargt too slow Quote Link to comment Share on other sites More sharing options...
OMEGA-ThundeR Posted July 11, 2013 Author Share Posted July 11, 2013 Ah, seems simple enough.. thanks, i can use this in the future . Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 11, 2013 Share Posted July 11, 2013 (Defun C:v (/ userscale) (setq userscale (strcat (getstring "enter required scale:") "xp")) (command "_zoom" "_scale" userscale) (princ) ) I sure hope that the user enters a valid integer/real number everytime. Command: v enter required scale:[color="red"]foo[/color] _zoom Specify corner of window, enter a scale factor (nX or nXP), or [All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: _scale Enter a scale factor (nX or nXP): [color="red"]fooxp[/color] Requires a distance (or numberX). [color="red"]; error: Function cancelled[/color] Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 11, 2013 Share Posted July 11, 2013 Ah, seems simple enough.. thanks, i can use this in the future . You're welcome; I'm happy to help. Quote Link to comment Share on other sites More sharing options...
OMEGA-ThundeR Posted July 11, 2013 Author Share Posted July 11, 2013 Could possible be an 22.5 value, guess yours (Blackbox) make both possible? Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 11, 2013 Share Posted July 11, 2013 Could possible be an 22.5 value, guess yours (Blackbox) make both possible? Simple fix... I changed GetInt to GetReal... See revised code here. Quote Link to comment Share on other sites More sharing options...
OMEGA-ThundeR Posted July 11, 2013 Author Share Posted July 11, 2013 an extra beer for you ! Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 11, 2013 Share Posted July 11, 2013 an extra beer for you ! Awesome... Frosty Erdinger Hefeweizen for me please. Quote Link to comment Share on other sites More sharing options...
feargt Posted July 11, 2013 Share Posted July 11, 2013 I sure hope that the user enters a valid integer/real number everytime. Command: v enter required scale:[color="red"]foo[/color] _zoom Specify corner of window, enter a scale factor (nX or nXP), or [All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: _scale Enter a scale factor (nX or nXP): [color="red"]fooxp[/color] Requires a distance (or numberX). [color="red"]; error: Function cancelled[/color] so do I now that u mention it Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 11, 2013 Share Posted July 11, 2013 so do I now that u mention it No worries; it's the little things that can trip one up... I've coded similar more times than I'd care to admit. Cheers Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 11, 2013 Share Posted July 11, 2013 Good call with INITGET, Lee. [Edit] - Looks like Lee deleted his post. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 11, 2013 Share Posted July 11, 2013 Some minor additions: (defun c:zs ( / scl ) (initget 6) (if (if (setq scl (getreal (strcat "\nSpecify scale factor" (if *scl* (strcat " <" (rtos *scl* 2) ">: ") ": ")))) (setq *scl* scl) (setq scl *scl*) ) (command "_.zoom" "_S" (strcat (rtos scl 2) "xp")) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 11, 2013 Share Posted July 11, 2013 [Edit] - Looks like Lee deleted his post. Yup - missed an 'if' and caught it just as I pressed the post button! Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 11, 2013 Share Posted July 11, 2013 Yup - missed an 'if' and caught it just as I pressed the post button! No worries; I was actually just admiring the If within the If (as test expression, as opposed to nested)... Nicely done. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 11, 2013 Share Posted July 11, 2013 No worries; I was actually just admiring the If within the If (as test expression, as opposed to nested)... Nicely done. Cheers dude Quote Link to comment Share on other sites More sharing options...
alanjt Posted July 11, 2013 Share Posted July 11, 2013 One more: (defun c:ZS (/) (initget 6) (if (setq *zs:scale* (cond ((getreal (strcat "\nSpecify scale factor" (if *zs:scale* (strcat " <" (rtos *zs:scale* 2) ">: ") ": " ) ) ) ) (*zs:scale*) ) ) (command "_.zoom" "_S" (strcat (rtos *zs:scale* 2) "xp")) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 12, 2013 Share Posted July 12, 2013 One way not lisp if you have the viewport toolbar open you can type direct the scale number factor in the square put 4 = 1:250 1 1:1000 have a look the number changes if you manually zoom with mouse wheel. Quote Link to comment Share on other sites More sharing options...
OMEGA-ThundeR Posted July 13, 2013 Author Share Posted July 13, 2013 True, but the less i have to move the mouse the better. Just a button to active the command and a number to enter and it's done. I guess it's a matter of preferation, i like to do things with commands and use as less buttons as possible. And the viewport scale controls aren't even in the ribbon or switch there if you are in an active viewport. Although i don't use the ribbon, it's one of the many reasons why i don't use it, and prefer doing things by commands. Or even better, speeding things up with a lisp Quote Link to comment Share on other sites More sharing options...
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.