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

Default viewport created automatically using VBA

1 REPLY 1
Reply
Message 1 of 2
Anna_FF
115 Views, 1 Reply

Default viewport created automatically using VBA

Hello everyone,

I'm working with AutoCAD VBA and I’m encountering an issue that I can't quite figure out. Here's the situation:

  1. I create a new layout and a viewport programmatically using VBA.
  2. However, when I check the layout, I notice that there are two viewports instead of just the one I created. It seems like AutoCAD automatically creates an extra viewport.
  3. I then try to delete the extra viewport, but nothing happens. The viewport remains in the layout even after attempting to delete it.

Has anyone experienced a similar issue where AutoCAD automatically adds an extra viewport when creating a new layout via VBA? If so, how can I delete the extra viewport or prevent it from being created in the first place?

Any help or guidance would be greatly appreciated!

Thanks in advance!

1 REPLY 1
Message 2 of 2
norman.yuan
in reply to: Anna_FF

If you open "Options" dialog box in AutoCAD, go to tab "Display", at the lower-left corner, you can see an checkbox "Create viewport in new layout". If it is checked, AutoCAD will create a viewport when a new layout is added.

 

You can use code to change this option via Application.Preferences.Display.LayoutCreateViewport by setting its value to False/True.

 

However, it might be good practice to let your code to always examine the layout for existing viewports and do something accordingly, such as erasing, or modifying as needed.

 

There is no reason that existing viewport cannot be deleted from code, unless the code is wrong. Since you did not show your code, I can only say that your code does not delete the layout correctly.

 

Norman Yuan

Drive CAD With 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