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:
<p>Sub selectOrigin(swModel As SldWorks.ModelDoc2)</p><p> Dim swFeature As SldWorks.Feature</p><p> Dim bRet As Boolean</p><p> </p><p> Set swFeature = swModel.FirstFeature</p><p> Do While Not swFeature Is Nothing</p><p> If swFeature.GetTypeName = "OriginProfileFeature" Then</p><p> bRet = swFeature.Select2(True, 6): Debug.Assert bRet</p><p> Exit Do</p><p> End If</p><p> Set swFeature = swFeature.GetNextFeature</p><p> Loop</p><p>End Sub</p>
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.
<p>Public Function getOrigin(swModel As SldWorks.ModelDoc2) As SldWorks.Feature</p><p> Dim swFeature As SldWorks.Feature</p><p> Dim bRet As Boolean</p><p> </p><p> Set swFeature = swModel.FirstFeature</p><p> Do While Not swFeature Is Nothing</p><p> If swFeature.GetTypeName = "OriginProfileFeature" Then</p><p> Set getOrigin = swFeature</p><p> Exit Function</p><p> End If</p><p> Set swFeature = swFeature.GetNextFeature</p><p> Loop</p><p>End Function</p>
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"
<p>Set swOriginFeature = getOrigin(pModel)</p><p>Debug.Print (swOriginFeature.Name)</p>
Does anyone have experience with using the Origin in the API?
Thanks,
John Alexander
SolidworksApi macros