Hide Table of Contents

Flip Sketch Picture Example (VBA)

This example shows how to flip a sketch picture.

'----------------------------------------------------------------------------
' Preconditions:
' 1. Verify that the specified document template exists.
' 2. Copy an image file (i.e., .bmp, .gif, .jpg, .jpeg, .tif, .wmf) to
'    c:\temp.
' 3. Replace image_file in the ISketchManager::InsertSketchPicture parameter
'    with the name of the copied file.
' 4. Open an Immediate window.
'
' Postconditions:
' 1. Creates a new model document.
' 2. Creates Sketch1 and Sketch Picture1 in the graphics area and the
'    FeatureManager design tree.
' 3. Selects Sketch Picture1 and flips it top to bottom.
' 4. Inspect the Immediate window.
'----------------------------------------------------------------------------

Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swFeat As SldWorks.Feature
Dim swSketchPicture As SldWorks.SketchPicture
Dim swSelMgr As SldWorks.SelectionMgr
Dim boolstatus As Boolean
Dim width As Double
Dim height As Double
Dim angle As Double

Sub main()

    Set swApp = Application.SldWorks
    Set swModel = swApp.NewDocument("C:\ProgramData\SolidWorks\SOLIDWORKS 2015\templates\Part.prtdot", 0, 0, 0)
    Set swModel = swApp.ActiveDoc
   

    Set swSelMgr = swModel.SelectionManager
    swModel.SketchManager.InsertSketch True
    Set swSketchPicture = swModel.SketchManager.InsertSketchPicture("c:\temp\image_file")
    swModel.SketchManager.InsertSketch True

    boolstatus = swModel.Extension.SelectByID2("Sketch Picture1", "SKETCHBITMAP", 0, 0, 0, False, 0, Nothing, 0)
    Set swFeat = swSelMgr.GetSelectedObject6(1, -1)
    

    Debug.Print "Feature name = " & swFeat.Name
   

    boolstatus = swSketchPicture.Flip(False)
    Debug.Print "  Sketch picture flipped? " & swSketchPicture.Flipped
   

    swSketchPicture.GetSize width, height
    Debug.Print "  Width: " & width * 1000 & " mm"
    Debug.Print "  Height: " & height * 1000 & " mm"
   

    angle = swSketchPicture.Angle
    '1 radian = 180º/p = 57.295779513º or approximately 57.3º
    Debug.Print "  Angle: " & angle * 57.3 & " degrees"

End Sub



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Flip Sketch Picture Example (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2015 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.