bvanhiel
Mechanical
- Oct 23, 2001
- 510
I was just wondering if there was a quick way to find childless features that sometimes accumulate in large models. Things like extra planes, sketches, etc.
-b
-b
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
' ******************************************************************************
' C:\TEMP\swx266\Macro1.swb - macro recorded on 08/13/02 by Chen
' ******************************************************************************
Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Sub deleteplanes()
Dim SubFeatObj As Object
Dim FeatObj As Object
Dim FeatType As String
Dim retval As Variant
Set FeatObj = Part.FirstFeature
Do While Not FeatObj Is Nothing
FeatType = FeatObj.GetTypeName
If FeatType = "RefPlane" And FeatObj.Name <> "Front" _
And FeatObj.Name <> "Top" And FeatObj.Name <> "Right" _
Then 'a sketch - select it
retval = FeatObj.GetChildren()
If IsEmpty(retval) Then
Part.AndSelectByID FeatObj.Name, "PLANE", 0, 0, 0
End If
End If
Set FeatObj = FeatObj.GetNextFeature
Loop
Part.DeleteSelection (False)
End Sub
Sub main()
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
If (Part Is Nothing) Then
swApp.SendMsgToUser2 _
"No Active Part !! " _
, swMbWarning, swMbOk
Exit Sub
End If
If (Part.GetType <> 1) Then ' If not an assembly or parts, then
exit
swApp.SendMsgToUser2 "Only for use with parts.", swMbWarning,
swMbOk
Exit Sub
End If
Set SelMgr = Part.SelectionManager() ' Get the selection manager
object
Part.ClearSelection
Call deleteplanes
End Sub [\code]
Hope it helps
Pete