How to use Origin as datum for FullyDefineSketch?

I'm using FullyDefineSketch to dimension a hole wizard sketch. I would like to dimension this pattern with respect to the part's origin.

The function takes two arguments for the datum:

VerticalDatumDisp

HorizontalDatumDisp

If either of them are Nothing, the FullyDefineSketch method uses an entity with selection mark = 6. Otherwise, one should pass the desired Entity object for those parameters.

I've tried the selection approach using the following function:

Sub selectOrigin(swModel As SldWorks.ModelDoc2)

    Dim swFeature  As SldWorks.Feature

    Dim bRet        As Boolean

   

    Set swFeature = swModel.FirstFeature

    Do While Not swFeature Is Nothing

        If swFeature.GetTypeName = "OriginProfileFeature" Then

            bRet = swFeature.Select2(True, 6): Debug.Assert bRet

            Exit Do

        End If

        Set swFeature = swFeature.GetNextFeature

    Loop

End Sub

This doesn't have any impact on the FullyDefineSketch's output.

I would like to get a reference to the origin and pass it to this function. However, I have no idea what type of object the origin is. I know when a sketch is active, a projection of the origin is visible on the sketch in the graphics window. Although, I don't think that the origin shows up as a sketch entity and I don't know how to get a reference to it programmatically.

Public Function getOrigin(swModel As SldWorks.ModelDoc2) As SldWorks.Feature

    Dim swFeature  As SldWorks.Feature

    Dim bRet        As Boolean

   

    Set swFeature = swModel.FirstFeature

    Do While Not swFeature Is Nothing

        If swFeature.GetTypeName = "OriginProfileFeature" Then

            Set getOrigin = swFeature

            Exit Function

        End If

        Set swFeature = swFeature.GetNextFeature

    Loop

End Function

I've tried passing the OriginProfileFeature to FullyDefineSketch with no positive result and I've tried casting the OriginProfileFeature as an Entity and passing that as an argument. That didn't work either.

When I select the origin via the feature tree with the FullyDefineSketch tool open, it calls it "Point1@Origin" (Is "Point1@Origin" a Vertex? a Reference Point?)

Whereas, when I get the name of the feature via the API, it is just "Origin"

Set swOriginFeature = getOrigin(pModel)

Debug.Print (swOriginFeature.Name)

Does anyone have experience with using the Origin in the API?

Thanks,

John Alexander

SolidworksApi macros