Jump to content

LISP to scale viewport and adjust extents off of a base point?


WindowsIHateYou

Recommended Posts

LISP to scale viewport and adjust extents off of a base point?

 

What my boss gave me: A billion viewports at 1/40

What my boss wants: The same billion viewports at 1/20, but showing the exact same full extents. (I know this will make viewport Areas on layout quadruple in size)

 

Is there a way to scale the viewport so that the zoom scales also?

Link to comment
Share on other sites

Is this example works ?

 

(defun c:Test (/ s vl)
 (princ "\n Select Single viewport ..")
 (if (setq s (ssget "_+.:S:E:L" '((0 . "VIEWPORT"))))
   (progn (vla-put-customscale (setq vl (vlax-ename->vla-object (ssname s 0))) 0.025)
          (vla-scaleentity vl (vla-get-center vl) 2.)
   )
 )
 (princ)
) (vl-load-com)

Link to comment
Share on other sites

is that change the scale if and only if the scale is 1/40?

 

For this project all viewports start at 1/40. If starting scale needs to be input to make a function work, it would still be faster than "manual" changes.

 

Is this example works?

 

Wow, so few lines of code to work! Thank you very much:D.

Is there any way to use a reference point instead of 'center' of viewport? 'User pick'(?) would be perfect, or 'bottom left'(?) would work for me.

 

Thanks

Link to comment
Share on other sites

 

Wow, so few lines of code to work! Thank you very much:D.

Thanks

 

You're welcome .

 

Is there any way to use a reference point instead of 'center' of viewport? 'User pick'(?) would be perfect, or 'bottom left'(?) would work for me.

 

Try these two routines .

 

User input for the base point .

 

(defun c:Test1 (/ s v p)
 (princ "\n Select Single viewport ..")
 (if (and (setq s (ssget "_+.:S:E:L" '((0 . "VIEWPORT"))))
          (setq p (getpoint "\n Specify base point :")))
   (progn (vla-put-customscale (setq v (vlax-ename->vla-object (ssname s 0))) 0.025)
          (vla-scaleentity v (vlax-3d-point p) 2.)
   )
 )
 (princ)
) (vl-load-com)

 

Without user intervention .

 

(defun c:Test2 (/ s v l r)
 (princ "\n Select Single viewport ..")
 (if (setq s (ssget "_+.:S:E:L" '((0 . "VIEWPORT"))))
   (progn (vla-getboundingbox (setq v (vlax-ename->vla-object (ssname s 0))) 'l 'r)
     (vla-put-customscale v 0.025)
          (vla-scaleentity v (vlax-3d-point (vlax-safearray->list l)) 2.)
   )
 )
 (princ)
) (vl-load-com)

Link to comment
Share on other sites

You're welcome .

 

 

 

Try these two routines .

 

User input for the base point .

 

Test1

 

Without user intervention .

 

Test2

 

Thanks again. Both of these work perfectly. Test1 will be useful in the future. Test 2 will save me time on THIS job.

Link to comment
Share on other sites

Ok, I found a problem. My original viewports SAID they were 1"=40', but after much swearing and problem shooting, I discovered that properties said they are actually .0226 (not .025). Then there was more swearing. The lisp still saves me time though. Just not as much.

Link to comment
Share on other sites

I encountered this problem many times, (like making an exploded view of a model using many viewports frezing everithing but one part in each vport, then due to changes the exploded view is too large to fit on a page).. the best solution I found is very simple:

-make a block with the viewports

-rescale the block (you can use reference with an entity drawn in model and transfered with chspace prior to make the block if the starting scale is an odd number)

-explode the block.

 

hope it helps.

regards

Jef!

Link to comment
Share on other sites

I encountered this problem many times, (like making an exploded view of a model using many viewports frezing everithing but one part in each vport, then due to changes the exploded view is too large to fit on a page).. the best solution I found is very simple:

-make a block with the viewports

-rescale the block (you can use reference with an entity drawn in model and transfered with chspace prior to make the block if the starting scale is an odd number)

-explode the block.

 

I had a chance to try today. I am VERY surprised that this works. :shock: Since it uses block, all additional notes/dims/info also scales up in the correct position. And ALL viewports can be done at once. Thanks for the alternate method.

Link to comment
Share on other sites

I found that few years ago, and it saved me (and many coworkers) so many hours of drafting time. If you said that notes/dims/infos followed and scaled up, it means that your dimensions are in paper space. Since you also mentioned that the viewports were actually at a scale of .0226 (not .025) I'd strongly suggest that you double check them since you probably used a dimscale of 1:40 to start with. At a starting scale of .0226, chances are that they wont be accurate. Worst case scenario, import a dimension of the correct scale and match prop them all.

 

I'm glad I could help you.

cheers

Jef!

Link to comment
Share on other sites

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