Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Automatically open modelspace and zoom to object in selected paperspace viewport

ancrayzy
Advocate
Advocate

Automatically open modelspace and zoom to object in selected paperspace viewport

ancrayzy
Advocate
Advocate

I'm searching for a way that will automatically open model space and zoom to an object in the selected paper space viewport.

 

For example, while viewing the drawing in the layout tab, I press a command and select any viewport. It will automatically switch to the model tab and zoom the screen to the correct position, similar to the viewport's view.

 

It's similar to Leemac's Viewport Outline lisp, but instead of creating a polyline, it zooms through the model onto that object

0 Likes
Reply
Accepted solutions (1)
744 Views
8 Replies
Replies (8)

paullimapa
Mentor
Mentor

Could be as simple as doing the following:

Go inside the pspace Vport

Use View command to save current model space view position with unique name

Change Tilemode to 1 to go to Model tab

Use View command to restore or set current the saved view & Delete the saved view name


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos

scot-65
Advisor
Advisor

@ancrayzy 

 

Do you use LIMMIN and LIMMAX? Is LIMITS turned Off?

Since we do not use LIMITS, I use these variables to define zoom window corners.

 

defun c:ZZR to redefine these variables (getpoint and  getcorner).

The values will be stored in the drawing.

Use ZZR while in modelspace.

 

defun c:ZZZ to automatically zoom "Window" (getvar "LIMMIN") (getvar "LIMMAX") into the area.

 

Entering into a viewport is up to you.

 

Hope this helps.


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Sea-Haven
Mentor
Mentor

Similar to Pauli's answer Zoom Object then UCS S "V1" etc, in another viewport UCS R "V1"

scot-65
Advisor
Advisor
As an extension to my earlier reply one can use vlax-ldata-put to store an array of point lists in a given DWG file.
For example, Model Space has a "checkerboard" of composing boxes that will be used as viewport definitions. Create one "zoom object" per checkerboard square.

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Kent1Cooper
Consultant
Consultant
Accepted solution

@ancrayzy wrote:

....

For example, while viewing the drawing in the layout tab, I press a command and select any viewport. It will automatically switch to the model tab and zoom the screen to the correct position, similar to the viewport's view.

....


It took some trial and error to figure it out, but I think this does what you're after:

 

(defun C:ZVAM ; = Zoom to Viewport Area in Model space
  (/ vp vpdata)
  (setvar 'tilemode 0); ensure in Paper Space layout
  (command "_.pspace"); and not in Model Space via a Viewport
  (setq
    vp (car (entsel "\nSelect Viewport by its boundary: "))
    vpdata (entget vp)
  )
  (setvar 'tilemode 1); force to Model Space, not via a Viewport
  (command "_.zoom" "_c" (trans (cdr (assoc 12 vpdata)) 2 0) (cdr (assoc 45 vpdata)))
  (prin1)
)

 

It could be improved upon, particularly to check whether what you selected is, in fact, a Viewport, but also with other little things like command-echo suppression and/or Undo begin/end wrapping.  But first see whether it fits your description.

Kent Cooper, AIA

ancrayzy
Advocate
Advocate
It's amazing, it works perfectly.
It not only helps me and even others save a lot of time working on autocad.
Thank you so much.
0 Likes

Kent1Cooper
Consultant
Consultant

Glad you like it.  It occurs to me to wonder -- would you ever not be in the World Coordinate System in Model Space when you use this?  I'd have to experiment, but it may be that the (trans) function for the Zoom center point should end with ... 2 1) instead of 0, to translate from Display to current-UCS coordinates.

Kent Cooper, AIA

Sea-Haven
Mentor
Mentor

Hi Kent in our civil plans we would use multiple UCS as we walk along a road so road is shown horizontal in a layout, sometimes we would not reset the world UCS in Model. It would  be like last view direction used. So may need the Current UCS if setting view. Not sure though if it would be twisted, but zoom C should still work. Have a look at image, red rectangs are layout views.

 

SeaHaven_0-1712804075780.png

 

 

 

 

 

0 Likes