Jump to content

Recommended Posts

Posted

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?

Posted
(defun c:FOO (/ scale)
 (if (setq scale (getreal "\nEnter a zoom scale factor: "))
   (command "._zoom" "scale" (strcat (rtos scale 2 2) "xp"))
 )
 (princ)
)

Posted (edited)

(Defun C:v (/ userscale)

(setq userscale (strcat (getstring "enter required scale:") "xp"))

(command "_zoom" "_scale" userscale)

(princ)

)

Edited by feargt
too slow
Posted

Ah, seems simple enough.. thanks, i can use this in the future :).

Posted

(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. :thumbsup:

 

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]

Posted
Ah, seems simple enough.. thanks, i can use this in the future :).

 

You're welcome; I'm happy to help. :beer:

Posted

Could possible be an 22.5 value, guess yours (Blackbox) make both possible?

Posted
Could possible be an 22.5 value, guess yours (Blackbox) make both possible?

 

Simple fix... I changed GetInt to GetReal... See revised code here.

Posted
:thumbsup: an extra beer for you !
Posted
:thumbsup: an extra beer for you !

 

Awesome... Frosty Erdinger Hefeweizen for me please. :beer:

 

images?q=tbn:ANd9GcQJInBTamy0h4weaa8vTqhKdofKnYlvtp6py9D6QDtbRS-kenHzSg

Posted
I sure hope that the user enters a valid integer/real number everytime. :thumbsup:

 

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

Posted
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

Posted

Good call with INITGET, Lee. :thumbsup:

 

 

 

[Edit] - Looks like Lee deleted his post.

Posted

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)
)

Posted
[Edit] - Looks like Lee deleted his post.

 

Yup - missed an 'if' and caught it just as I pressed the post button!

Posted
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. :beer:

Posted
No worries; I was actually just admiring the If within the If (as test expression, as opposed to nested)... Nicely done. :beer:

 

Cheers dude :thumbsup:

Posted

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)
)

Posted

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.

Posted

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 :)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...