VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Viewports get deleted

3 REPLIES 3
Reply
Message 1 of 4
NGVBA
168 Views, 3 Replies

Viewports get deleted

Hi All

I created viewports in various layouts and zoom window locked it.

All the stuff is visible before saving, after saving when I reopen it, all the viewports are not available and I need to do it manually.@norman

     acadDoc.ActiveSpace = 0
    ViewPinsertionPoint(0) = 504.5
    ViewPinsertionPoint(1) = 420.5
    ViewPinsertionPoint(2) = 0
    newViewport = "newViewport" & i
    Set newViewport = acadDoc.PaperSpace.AddPViewport(ViewPinsertionPoint, 979, 811)

    acadApp.ZoomExtents
    newViewport.Display (True)
    acadDoc.MSpace = True
    
    UpperLeft(0) = ThisWorkbook.Worksheets("Execute").Range("cf" & i - 7).Value  ' X-coordinate of lower-left corner
    UpperLeft(1) = ThisWorkbook.Worksheets("Execute").Range("cg" & i - 7).Value
    UpperLeft(2) = 0

    LowerRight(0) = ThisWorkbook.Worksheets("Execute").Range("ch" & i - 7).Value
    LowerRight(1) = ThisWorkbook.Worksheets("Execute").Range("ci" & i - 7).Value
    LowerRight(2) = 0
    
    
    
    
acadDoc.Application.ZoomWindow UpperLeft, LowerRight

acadDoc.MSpace = False

newViewport.DisplayLocked = True

 

Labels (1)
3 REPLIES 3
Message 2 of 4
ed57gmc
in reply to: NGVBA

In the code you show, you never saved the dwg.

activeDoc.Save()

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 3 of 4
NGVBA
in reply to: ed57gmc

Thanks Ed, Above is just part of the code hence . I am saving the drawing, in fact I have saved the drawing manually also and everything is fine before closing but when I reopen it all viewports are not available.

Message 4 of 4
ed57gmc
in reply to: NGVBA

Then can you post a complete code sample that we can test?

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

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