Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Inventor 2014 / Drawing (IDW, DWG) export to Picture

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
mario.lung
334 Views, 2 Replies

Inventor 2014 / Drawing (IDW, DWG) export to Picture

Hi, this function "SaveasBitmap" is a Printscreen Function from ActiveView ==> Call ThisApplication.ActiveView.SaveAsBitmap("C:\Temp\test.png", 400, 240) so i when set the Sheet better then the Function ActiveView.Fit i dosent want see the Background i want made only a Export from the Current Sheet any one information about it please how i can export or zoom it thx for help Mario
Tags (1)
2 REPLIES 2
Message 2 of 3
matt_jlt
in reply to: mario.lung

The only way I have got it working is to get the size of the active sheet, open a new window for that drawing (duplicate window), re-size the new window to the size of the sheet then zoom to about 101% so you don't get any of the page border.

 

It's not a perfect solution but It works without any noticeable effects.

 

Regards, Matt.

Message 3 of 3
mario.lung
in reply to: matt_jlt

Hey, with your keywords i found this Code and it works perfect! 

 

 

 

' Saves the active sheet as a bmp.
' Resolution - Specifies the output resolution of the bitmap in pixels per inch.
' Filename - Specifies the output filename. It should have a .bmp extension.
Public Sub SaveDrawingAsBMP()

Dim Resolution As Long
Dim Filename As String

 Resolution = 400
 Filename = "c:\temp\test.png"

' Get the active view.
Dim oView As View
Set oView = ThisApplication.ActiveView
' Determine if a drawing is active.
If Not oView.Document.DocumentType = kDrawingDocumentObject Then
    MsgBox "A drawing must be active when running this macro."
    Exit Sub
    End If
    ' Get the drawing document and the active sheet.
    Dim oDoc As DrawingDocument
    Set oDoc = oView.Document
    Dim oSheet As Sheet
    Set oSheet = oDoc.ActiveSheet
    ' Change the size of the window so it has the same aspect ratio
    ' as the sheet. It changes the view such that it becomes smaller.
    oView.WindowState = kNormalWindow
    Dim dSheetAspectRatio As Double
    dSheetAspectRatio = oSheet.Width / oSheet.Height
    Dim dViewAspectRatio As Double
    dViewAspectRatio = oView.Width / oView.Height
    If dSheetAspectRatio > dViewAspectRatio Then
        oView.Width = oView.Height / dSheetAspectRatio
    Else
        oView.Height = oView.Width / dSheetAspectRatio
    End If
    ' Get the camera and use it to zoom in so only the sheet is seen.
    Dim oCamera As Camera
    Set oCamera = oView.Camera
    oCamera.Target = ThisApplication.TransientGeometry.CreatePoint(oSheet.Width / 2, oSheet.Height / 2, 0)
    oCamera.Eye = ThisApplication.TransientGeometry.CreatePoint(oCamera.Target.X, oCamera.Target.Y, 1)
    Call oCamera.SetExtents(oSheet.Width, oSheet.Height)
    oCamera.ApplyWithoutTransition
    ' Determine the number of pixels wide the output needs to be
    ' to result in the desired resolution.
    Dim lWidth As Long
    lWidth = (oSheet.Width / 2.54) * Resolution
    ' Save the bitmap.
    Call oView.SaveAsBitmap(Filename, lWidth, 0)

End Sub

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report