- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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! ![]()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report