How to set center of a viewport a specific point of a model space

How to set center of a viewport a specific point of a model space

parikhnidi
Advocate Advocate
2,211 Views
4 Replies
Message 1 of 5

How to set center of a viewport a specific point of a model space

parikhnidi
Advocate
Advocate

Hi Friends,

 

I have created a viewport in a paperspace using -

 

Set pviewportObj = ThisDrawing.PaperSpace.AddPViewport(loc, 100, 500)
pviewportObj.ViewportOn = True

Now I want to set the center of this viewport a specific point of the modelspace. How do I do that?

 

Nimish

0 Likes
2,212 Views
4 Replies
Replies (4)
Message 2 of 5

parikhnidi
Advocate
Advocate

Well after some struggle, I realize that there is no way to set this in AutoCAD VBA.

 

However, I found a crude way where, I activated the viewport in question in VBA using ThisDrawing.MSpace = True and then use ZoomCenter method to establish center and magnification. It worked well for me.

 

I wish there should be some property something like PSpaceViewPort.ModelSpaceCenter and PSpaceViewPort.ModelSpaceHeight.

 

With more emphasis on .NET development, and VBA being visible only in rear view mirror, I don't think I would like to send this as wish list item.

 

Nimish

PS: I am starting to switch my development to .NET but it will be a very long process.

0 Likes
Message 3 of 5

norman.yuan
Mentor
Mentor

Have you looked at Target property of AcadPVireport/Viewport/View object? That is what you need to set the center point of the ModelSpace one can see through the viewport. Then with StandardScale/CustomScale property you can achieve the effect of zooming by "ZOOM" command.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 4 of 5

parikhnidi
Advocate
Advocate

Thanks Norman for the suggestion.

 

I tried what you suggested to no avail. I believe, I will have to live with the work around as indicated earlier.

 

Nimish

0 Likes
Message 5 of 5

Sea-Haven
Mentor
Mentor

I dont agree with you look at a dump of properties they are not read only.

 

Select object: ; IAcadPViewport: IAcadPViewport Interface
; Property values:
; Application (RO) = #<VLA-OBJECT IAcadApplication 00007ff6cb551e30>
; Center = (397.414 301.03 0.0)
; CustomScale = 0.485444
; Height = 473.195
; Target = (610.872 453.508 0.0)
; TwistAngle = 0.0
; Width = 776.284

0 Likes