Jump to content

Viewport to follow moved objects


Recommended Posts

Is there a way for a viewport (in paper space) to follow objects as they are moved in model space.

I was wondering if there's a setting which says "follow this block" or something similar.

Or is coding required?

Link to comment
Share on other sites

It is possible to create a view object that is linked to a viewport. It is possible to add various objects to a group. If you grouped a view with your block, you might be able to do what you want. Just spitballing here.

 

Of course, this gets hideously complex in a hurry. What happens if there are two blocks and you move one? What if the items aren't coplanar? How do you manage viewport scale?

 

Good luck.

  • Thanks 1
Link to comment
Share on other sites

3 minutes ago, sketch11 said:

OK no worries, it sounds too difficult then.

Don't misunderstand, I wasn't telling you not to try it. I don't know enough about your scenario to have an opinion about that. Someone else here may have a better, more elegant solution that does exactly what you want.

  • Like 1
Link to comment
Share on other sites

If I  wanted to do this somewhat predictably, I might do something like this.

 

Draw a rectangle or other polygon in Modelspace to essentially frame the view or Objects in question.

If you later move or create a new viewport, double click inside of it to activate it, then use the ZOOM command with Object commandline option, and choose the frame which you created.  It will zoom to fit, don't forget to check your viewport scale and lock the viewport.  As long as you move the frame with the object, you should be good.

 

image.thumb.png.166eb2877a5c63e34a06643991e261d8.png

Edited by Dadgad
septugenarian
  • Thanks 1
Link to comment
Share on other sites

A lisp could read the viewport details in particualr scale, unlock if locked, jump to model space, pick a point, then jump back paperspace and reset Center and Customscale. Not tested.

; IAcadPViewport 3dd11c70 : TeighaX Interface of rectangular object created in paper space that display view
;
; Property values :
;
;   Application (RO) = #<VLA-OBJECT IAcadApplication 000000002C756D60>

;   Center = (135.0 100.0 0.0)
;   CustomScale = 0.448933782267116
;   Height = 136.0
;   Width = 196.0
  

You need to use the trans function to work out the XYZ etc. Did drawgrid in paperspace based on model pick pt so have the answers but need to rewrite it to suit.

Edited by BIGAL
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

OK thanks.

What if the view was linked to a single block which was a bounding rectangle, wherever this went the viewport would follow.

Link to comment
Share on other sites

I dont think you can do this auto update. If say one block or a block with a attribute say layout number then run a lisp and would update. still thinking about it.

 

Post a sample dwg with say 2viewports and 2 blocks.

 

Try this

; pick new pt in a viewport
; By AlanH May 2021

(defun c:vpmove ( / lockv sss obj pt )
(command "._PSPACE")
(prompt "\nPick viewport ")
(setq sss (ssget "_+.:E:S" (list (cons 0 "Viewport"))))
(setq cspace (cdr (assoc 69 (entget (ssname sss 0)))))
(setq obj (vlax-ename->vla-object (ssname sss 0)))
(if (= (vla-get-objectname obj)  "AcDbViewport")
  (progn
    (if (= (vla-get-displaylocked obj) :VLAX-TRUE)
    (progn
      (setq lockv "Y")
      (vla-put-displaylocked obj :VLAX-FALSE)
    )
    )
  (command "Mspace")
  (setvar 'cvport cspace)
  (setq pt (getpoint "\nPick new point "))
  (command "zoom" "C" pt "")
  (if (= lockv "Y")(vla-put-displaylocked obj :VLAX-TRUE))
    (command "pspace")
  )
)
(princ)
)

 

Edited by BIGAL
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...