I have one doubt API Name CreateBoundaryHatch
It is not working on Drawing where i have selected faces runtime.When i am executing the API Solidworks crashes
Here is the Code:-
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeat As SldWorks.Feature
Dim swFaceFeat As SldWorks.Feature
Dim swSelData As SldWorks.SelectData
Dim swFace As SldWorks.Face2
Dim swEnt As SldWorks.Entity
Dim swSketchMgr As SldWorks.SketchManager
Dim vFaceArr As Variant
Dim vFace As Variant
Dim vHatchArr As Variant
Dim MyHatch As Variant
Dim boolStatus As Boolean
Sub CreateHatch()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If (swModel Is Nothing) Then Exit Sub
Set swDraw = swModel
If (swDraw Is Nothing) Then Exit Sub
Set swSelMgr = swModel.SelectionManager
If (swSelMgr Is Nothing) Then Exit Sub
Set swSketchMgr = swModel.SketchManager
If (swSketchMgr Is Nothing) Then Exit Sub
boolStatus = swModel.Extension.SelectByID2("DRUM_FOR_DRG@STEAM_DRUM_DRG-1@Drawing View1/SD_SHELL_DRG-1@STEAM_DRUM_DRG", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
Set swFeat = swSelMgr.GetSelectedObject6(1, -1)
swModel.ClearSelection2 True
If (swFeat Is Nothing) Then Exit Sub
Set swSelData = swSelMgr.CreateSelectData
If (swSelData Is Nothing) Then Exit Sub
vFaceArr = swFeat.GetFaces: If IsEmpty(vFaceArr) Then Exit Sub
swModel.ClearSelection2 True
For Each vFace In vFaceArr
Set swFace = vFace
Set swEnt = swFace
Set swFaceFeat = swFace.GetFeature
If swFaceFeat Is swFeat Then
boolStatus = swEnt.Select4(True, swSelData): Debug.Assert boolStatus
End If
Next
MyHatch = swSketchMgr.CreateBoundaryHatch(0, 1, 0, "Solid", "")
swModel.ClearSelection2 True
End Sub
