Dim swApp As Object
Dim part As SldWorks.ModelDoc2
Dim boolstatus As Boolean
Dim longstatus As Long
Dim Annotation As Object
Dim Gtol As Object
Dim DatumTag As Object
Dim FeatureData As Object
Dim myFeature As SldWorks.Feature
Dim Component As Object
Dim Body As Object
Dim Face As Object
Dim bStatus As Boolean
Dim iCount As Integer
Dim sFeatName As String
Dim iNumFeat As Long
Sub main()
Set swApp = CreateObject("SldWorks.Application")
Set part = swApp.ActiveDoc
iNumFeat = part.GetFeatureCount
Set myFeature = part.FirstFeature
For iCount = 1 To iNumFeat
If Not myFeature.IsSuppressed Then
If myFeature.GetTypeName = "ProfileFeature" Then
myFeature.Select False
part.InsertSketch2 True
Call FixThePoints(myFeature.GetSpecificFeature2, part)
part.EditRebuild3
End If
End If
Set myFeature = myFeature.GetNextFeature
Next iCount
part.ClearSelection
End Sub
Sub FixThePoints(mySketch As SldWorks.Sketch, part As SldWorks.ModelDoc2)
Dim MyPointArray As Variant
Dim myPoint As SldWorks.SketchPoint
Dim myRelMgr As SldWorks.SketchRelationManager
Dim dummyRel As SldWorks.SketchRelation
Dim mySelMgr As SldWorks.SelectionMgr
Dim mySketchSegArray As Variant
Dim mySeg As SketchSegment
Dim myArc As SketchArc
Dim i As Long
'First we fix all the sketch points
MyPointArray = mySketch.GetSketchPoints
mySketchSegArray = mySketch.GetSketchSegments
Set myRelMgr = mySketch.RelationManager
Set mySelMgr = part.SelectionManager
part.ClearSelection
If Not IsEmpty(MyPointArray) Then
For i = 0 To UBound(MyPointArray)
Set myPoint = MyPointArray(i)
myPoint.Select True
Next i
End If
part.SketchAddConstraints "sgFIXED"
'Any partial arc will already be fixed by its center point
'and its end points. Circles, however, only have one point.
'Therefore we fix all complete circles
part.ClearSelection
If Not IsEmpty(mySketchSegArray) Then
For i = 0 To UBound(mySketchSegArray)
Set mySeg = mySketchSegArray(i)
If mySeg.GetType = swSketchARC Then
Set myArc = mySeg
If myArc.IsCircle = 1 Then 'Test whether it is complete circle
mySeg.Select True
End If
End If
Next i
End If
part.SketchAddConstraints "sgFIXED"
End Sub