Jump to content
alokmpatel

change viewports position (x and y cordinates)

Recommended Posts

Hello every one,

i found thread about change height and width of particular one viewport.

 

My current situation:

I have 3 viewports.

i want only one viewport at some specific coordinate (say x=100, y=200)

and remain two viewports are are at other coordinate (say x=1000, y=2000)

 

it is possible manually, by simply selecting 1st viewport and editing "Center X" and "Center Y" of their viewport property.

 

if some one know than please help me...

 

Alok

Share this post


Link to post
Share on other sites

Welcome to CADTutor Alok :)

 

Are you referring to the viewport target (i.e. the objects viewed through the viewport), or the position of the viewport object itself in paperspace?

 

If you are referring to the target, you will first need to store the current viewport scale (customscale property) so that it may be reset later; you will then need to activate the viewport (mspace property) and set it as the active paperspace viewport (activeviewport property).

 

To change the target, you could use the zoomcenter method with an arbitrary scale factor (since the viewport scale can be restored later by the program). The stored viewport scale can then be reinstated via the customscale property and the viewport deactivated using the mspace property.

Share this post


Link to post
Share on other sites

Thanks alot Lee,:)

For your instance reply.

 

But i am not that much familiar about VBA programming.

as i was go throug lots of treadds in CADTutor i just have some idea.

 

 

following code is working well for setting desire target(x,y) , scale, height and width.

 

Sub PVPortManipulation()

 

'Iterate through the viewports of every paperspace Layout.

'Change the pviewports height to 6

'Change it to SE Iso view

'Move each paperspace vport 2 units to the right.

'Set vport scale

'Modify target

 

 

Dim Entity As AcadEntity

Dim VPcenter As Variant

Dim PVport As AcadPViewport

Dim objLayout As AcadLayout

Dim dblDir(0 To 2) As Double

Dim i As Integer

For Each objLayout In ThisDrawing.Layouts

If objLayout.Name "Model" Then

ThisDrawing.ActiveLayout = objLayout

ThisDrawing.MSpace = False

For i = 1 To objLayout.Block.Count - 1 'avoid primary Paperspace PViewport

Set Entity = objLayout.Block.Item(i)

If TypeOf Entity Is AcadPViewport Then

Set PVport = Entity

PVport.Display True

PVport.Height = 10

PVport.Width = 50

dblDir(0) = -1#: dblDir(1) = -1#: dblDir(2) = 1#:

PVport.Direction = dblDir

VPcenter = PVport.Center

VPcenter(0) = 100#

VPcenter(1) = -50#

PVport.Center = VPcenter

PVport.StandardScale = acVp1_10

dblDir(0) = -6

PVport.Target = dblDir

PVport.Update

End If

Next

ThisDrawing.Regen acAllViewports

End If

Next

End Sub

 

 

but how i will set different viewports property.

above code is working, but it is changing all viewport target and all other properties to the same.

 

Thanks.

Alok:)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×