Announcements

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

Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Automatically open modelspace and zoom to object in selected paperspace viewport

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
ancrayzy
742 Views, 8 Replies

Automatically open modelspace and zoom to object in selected paperspace viewport

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

Labels (2)
8 REPLIES 8
Message 2 of 9
paullimapa
in reply to: ancrayzy

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
Message 3 of 9
scot-65
in reply to: ancrayzy

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


Message 4 of 9
Sea-Haven
in reply to: ancrayzy

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

Message 5 of 9
scot-65
in reply to: ancrayzy

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.


Message 6 of 9
Kent1Cooper
in reply to: ancrayzy


@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
Message 7 of 9
ancrayzy
in reply to: Kent1Cooper

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.
Message 8 of 9
Kent1Cooper
in reply to: ancrayzy

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
Message 9 of 9
Sea-Haven
in reply to: Kent1Cooper

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

 

 

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report