Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Zoom all for silent drawing

snichols
Advocate

Zoom all for silent drawing

snichols
Advocate
Advocate

I have the code below that opens a drawing "silently" and adds a sheet with a border and title block to it. I need to do a zoom all on the sheet but can't figure out how to do it when the drawing is silent. There are no views on the sheet yet, it is just a blank sheet. Can anybody point me in the right direction? Thanks in advance!

 

'Open the drawing template silently
dwgFile = ThisDoc.Path() & "\Dwgs\Musco Pole.dwg" '<- Change Drawing name here
Dim oDrawDoc as DrawingDocument = ThisApplication.Documents.Open(dwgFile, False)
Dim oSheet2 As Sheet
oSheet2 = oDrawDoc.Sheets.Add 
oSheet2.Activate
oSheet2.Name ="Layout2"
oSheet2.ExcludeFromPrinting = False
oSheet2.ExcludeFromCount = False

'get current size
Dim Size As DrawingSheetSizeEnum
Size = oSheet2.Size

'set new size
oSheet2.Size = DrawingSheetSizeEnum.kBDrawingSheetSize

Dim oBorder As Border = oSheet2.Border
Dim borderDef As BorderDefinition
oSheet2.AddBorder("PiRod Border") '<- Change Border name here

Dim oTitleBlock As TitleBlock = oSheet2.TitleBlock
Dim TitleBlockDef As TitleBlockDefinition
oSheet2.AddTitleBlock("Plymouth") '<- Change Title Block name here'ThisApplication.ActiveView.Fit '<- This doesn't work because the drawing is not the active document

'update sheet to see results
oSheet2.Update
0 Likes
Reply
Accepted solutions (1)
724 Views
5 Replies
Replies (5)

marcin_otręba
Advisor
Advisor

try:

ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomAllCmd").Execute

 

edit:

 

sorry i just noticed that by silent you mean invisible, in this scenario it will not work.

Hi, maybe you want to check my apps:


DrawingTools   ViewTools   MRUFolders

0 Likes

WCrihfield
Mentor
Mentor
Accepted solution

I don't think setting up the zoom level of the page and saving it that way, without ever seeing the drawing file is possible.  I know it can be done when visible is set to true, because it is active at the time.  I have used a code that 'cleans-up' a drawing before saving, which collapses everything on the Model tab, then loops through each sheet, and zoom all, then saves the drawing file at the end.

All zoom type commands deal with with the 'visual' size/scale difference between your specific monitor (its usable screen size, and its resolution), compared to the virtual size of what you're looking at.  When dealing with a drawing, the best you can hope for is knowing the ratio of the drawings Paper Size vs available screen area size (less the ribbon, side docked dialogs, bottom status bar, bottom tabs bar, etc.  Then you would have to use a zoom-to-secified-scale type command (which I don't know of one, for this context).  Model files have views & cameras that can be set-up.  DrawingViews have a scales and a camera, that can be set-up.  But I don't think the display size of the drawing sheet can be set-up this way without visually activating the sheet, and using those zoom tools in that setting.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

marcin_otręba
Advisor
Advisor

@snichols I checked couple of times and when i create new drawing it is always zoomed to whole sheet, also when i add new sheet to it. Do you really need this funtionality then ? did you check the drawing created without zoom command ?

Hi, maybe you want to check my apps:


DrawingTools   ViewTools   MRUFolders

0 Likes

snichols
Advocate
Advocate

I checked the drawing and it is zoomed out, I don't absolutely have to have it, but it would have been nice.

Thanks All! 🙂

0 Likes

snichols
Advocate
Advocate

Makes sense, Thanks!

0 Likes