ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
БOБорис Ovsov02/11/2017

I have an dll library Gma.QrCodeNet.Encoding.dll to encode QRCODE in drawings. but macro can't find the function QREncode to do that.

text of macro is below:

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

'Dim oc As OcvitaBarcode1

'Imports OcvitaBarcode.barcode

Option Explicit

Private Enum TErrorCorretion

    QualityLow

    QualityMedium

    QualityStandard

    QualityHigh

End Enum

Private Declare PtrSafe Sub GenerateBMP Lib "D:\Gma.QrCodeNet.Encoding.dll" Alias "QrEncoder" (ByVal FileName As String)

               

Sub main()

'Set oc = OcvitaBarcode1

'oc.barcode = TextBox1

  GenerateBMP StrPtr("Hello world!")

    Set swApp = Application.SldWorks

  '  Set swModel = swApp.NewDocument("C:\ProgramData\SolidWorks\SOLIDWORKS 2017\templates\gost-part.prtdot", 0, 0, 0)

    Set swModel = swApp.ActiveDoc

 

    Set swSelMgr = swModel.SelectionManager

   ' swModel.SketchManager.InsertSketch True

    Set swSketchPicture = swModel.SketchManager.InsertSketchPicture("c:\temp\IMG_4359.jpg")

    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