help to modify lisp

help to modify lisp

Edwin.Saez
Advisor Advisor
691 Views
8 Replies
Message 1 of 9

help to modify lisp

Edwin.Saez
Advisor
Advisor

Hi everyone,


could you help me to modify the following lisp. the section is defined to only one viewport at a time, and I would like to be able to select several viewports at the same time.

 

Thanks

 

;LISP SCALE VIEWPORT
(defun c:ee (/ e s)
 (if (setq e (car (entsel "\nSelecciona el Viewport: ")))
   (if (eq "AcDbViewport" (vla-get-objectname (setq e (vlax-ename->vla-object e))))
     (if (setq s (getreal (strcat "\nNueva Escala (Actual: 1\/"
                                  (rtos (/ 1000. (vla-get-customscale e)) 2)
                                  "): "
                          )
                 )
         )
       (vl-catch-all-apply (function vla-put-customscale) (list e (/ 1000. s)))
     )
     (princ "\nInvalid object!")
   )
 )
 (princ)
)

 

Edwin Saez


LinkedIn / AutoCAD Certified Professional


EESignature


 


Si mi respuesta fue una solución para usted, por favor seleccione "Aceptar Solución", para que también sirva a otro usuarios.

0 Likes
692 Views
8 Replies
Replies (8)
Message 2 of 9

Kent1Cooper
Consultant
Consultant

Try this [untested]:

;LISP SCALE VIEWPORT
(defun c:ee (/ ss n e s)
  (if (setq ss (ssget "_:L" '((0 . "VIEWPORT"))))
    (repeat (setq n (sslength ss)) ; then
      (setq e (vlax-ename->vla-object (ssname ss (setq n (1- n)))))
      (if
        (setq s
          (getreal
            (strcat
              "\nNueva Escala (Actual: 1\/"
              (rtos (/ 1000. (vla-get-customscale e)) 2)
              "): "
            ); strcat
          ); getreal
        ); setq
        (vl-catch-all-apply (function vla-put-customscale) (list e (/ 1000. s))); then
      ); if
    ); repeat
  ); if
  (princ)
)

It prevents invalid objects by filtering in the selection, rather than by checking after selection as in the one-at-a-time version.

Kent Cooper, AIA
0 Likes
Message 3 of 9

Edwin.Saez
Advisor
Advisor

thank you for answering @Kent1Cooper 


I don't know if it was my mistake in explaining or if the lisp is not working properly.
The multiple selection is fine, but it should apply to the whole selection (all the viewports you select) the single scale that I indicated.

Edwin Saez


LinkedIn / AutoCAD Certified Professional


EESignature


 


Si mi respuesta fue una solución para usted, por favor seleccione "Aceptar Solución", para que también sirva a otro usuarios.

0 Likes
Message 4 of 9

ronjonp
Advisor
Advisor

You have to put the scale outside of the loop like so:

(defun c:ee (/ ss n e s)
  (if (and (setq ss (ssget "_:L" '((0 . "VIEWPORT"))))
	   (setq s (cond ((getreal "\nNueva Escala (Actual: 1\/100): "))
			 (100)
		   )			; getreal
	   )
      )
    (repeat (setq n (sslength ss))	; then
      (setq e (vlax-ename->vla-object (ssname ss (setq n (1- n))))) ; setq
      (vl-catch-all-apply 'vla-put-customscale (list e (/ 1000. s))) ; then
					; if
    )					; repeat
  )					; if
  (princ)
)
0 Likes
Message 5 of 9

Edwin.Saez
Advisor
Advisor

@ronjonp ,

 

works fine now, but the initial lisp, at the moment of showing the message to change the scale, also showed the current scale. Could this be added please?

 

 

 

 

 

Edwin Saez


LinkedIn / AutoCAD Certified Professional


EESignature


 


Si mi respuesta fue una solución para usted, por favor seleccione "Aceptar Solución", para que también sirva a otro usuarios.

0 Likes
Message 6 of 9

Kent1Cooper
Consultant
Consultant

@Edwin.Saez wrote:

.... the initial lisp, at the moment of showing the message to change the scale, also showed the current scale. Could this be added please?


And what if the current scales of multiple Viewports are not the same as each other?  It showed the current scale of a specific Viewport [either the one selected in your original, or each one as it goes in my modification].   If you want a single scale, which needs to be given before it has "looked at" any of the Viewports, what should it use for the "current scale"?

Kent Cooper, AIA
0 Likes
Message 7 of 9

Edwin.Saez
Advisor
Advisor

good point @Kent1Cooper , in this case I don't care to know the current scale of all the viewports I have selected, I would only be interested in knowing the current scale when I make the selection of a single viewport.

 

 

 

 

 

Edwin Saez


LinkedIn / AutoCAD Certified Professional


EESignature


 


Si mi respuesta fue una solución para usted, por favor seleccione "Aceptar Solución", para que también sirva a otro usuarios.

0 Likes
Message 8 of 9

john.uhden
Mentor
Mentor

Then it should show "varies"

John F. Uhden

0 Likes
Message 9 of 9

Sea-Haven
Mentor
Mentor

Maybe this, for me I work metric so I have the Viewports toolbar turned on, when you make a viewport, zoom in etc at random scale, the box in the vports toolbar shows the scale as a number so its easy to just type a number into that box it will then set the scale, if units are metres then for 1:1000 just put 1 in box, so create with correct scale set. 

 

The scale factor is for metres 1000/scale, 4 = 1:250 5=1:200 10= 1:100 etc

 

As you have zoomed a fit can see what sort of scale should be used eg scale number is 3.8654 so use 4. then true 1:250 scale. may need a small adjustment of viewport to match viewable area.

 

0 Likes