The end result I want is an image of a draft where the image only includes the area within the borders defined by the sheet setup height and width.
To accomplish this, my idea was to get the size from the sheet setup, move the sheet to the top left corner of the viewing window, and then resize the window to the size of the sheet and take the picture. The code below does what I want until the last step of resizing the window. I have tried all the ways I can think of that might work using Application.Windows or as shown below using the Draft.SheetWindow object, but I either get errors or it just doesn't work. Does anyone know how to accomplish that last step, or is there a better way to go about this altogether? Thanks!
Dim objApp As SolidEdgeFramework.Application = Nothing Dim objDraft As SolidEdgeDraft.DraftDocument = Nothing Dim objSheet As SolidEdgeDraft.Sheet = Nothing Dim objSheetSetup As SolidEdgeDraft.SheetSetup = Nothing Dim objSheetWin As SolidEdgeDraft.SheetWindow = Nothing ' Connect to a running instance of Solid Edge objApp = Marshal.GetActiveObject("SolidEdge.Application") ' Get a reference to the active document objDraft = objApp.ActiveDocument ' Get a reference to the first sheet objSheetWin = objDraft.Windows(0) objSheet = objDraft.ActiveSheet objSheetSetup = objSheet.SheetSetup ' Set the sheet to fit the screen objSheetWin.FitEx(SolidEdgeDraft.SheetFitConstants
.igFitWorkingAndBackgroundGraphics) ' Move the sheet to the upper left corner of the screen objSheetWin.SetOrigin(0, objSheetSetup.SheetHeight) ' Set the window so that it is not maximized, and therefore can be re-sized objApp.WindowState = System.Windows.Forms.FormWindowState.Normal Dim factor As Double = 39.3700787402 * 72 ' meters to inches * 72 dots per inch ' this code does not work (no re-sizing occurs at all): objSheetWin.Height = objSheetSetup.SheetHeight * factor objSheetWin.Width = objSheetSetup.SheetWidth * factor ' Save the current view as an image objSheetWin.SaveAsImage("C:\Users\tim\Desktop\test draftimage.jpg")
Posted by: Tim
Post date: 6/20/2012 10:50:59 AM
You must set the viewer windowstate to normal
objSheetWin.WindowState = System.Windows.Forms.FormWindowState.Normal
and not objApp.WindowState
Posted by: JR
Post date: 6/21/2012 7:12:45 AM