ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
CMChris Mueller12/09/2012

I'm trying to create a design checker check, but cannot get past the declarations.  The thing that makes this REALLY frustrating is that I have copied code directly from the API help.  Also, being a half-newb with this type of programming, I find the API help not very, erm... helpful.  The example code below is from the Custom Check Document (VBA) section of the API help for SW2012.  Edited for brevity.

My code always hangs at the line Dim dcApp As DesignCheckerLib.SWDesignCheck, with a Compile error: User-defined type not defined.

Code follows below, with the Runcheck function having been shortened for brevity, but otherwise this is a direct copy/paste of the example.


Dim nFailedItemCount As Integer

Dim bCheckStatus As Boolean

Dim swApp As SldWorks.SldWorks

Dim errorCode As Long

Sub Validate()

Set swApp = Application.SldWorks

 

' Validate document

    bCheckStatus = True

    Dim FailedItemsArr() As String

    bCheckStatus = RunCheck(FailedItemsArr)

 

' Inform SolidWorks Design Checker about the results

    Dim dcApp As DesignCheckerLib.SWDesignCheck

    Set dcApp = swApp.GetAddInObject("SWDesignChecker.SWDesignCheck")

    errorCode = dcApp.SetCustomCheckResult(bCheckStatus, (FailedItemsArr))

End Sub

 

Function RunCheck(ByRef FailedItemsArr() As String) As Boolean

   RunCheck = False

End Function