Disable all Crosshatches in drawing section view
Posted: Fri Apr 05, 2024 1:24 am
I have been trying to disable the section hatching for every component in a section view.
Disabling the material hatching and setting the area fill to none.
Looping every single face in the view seems to take forever to process a single face...is there a better way to achieve this?
Sample code from the help I modified just select a section in a assembly and start the macro.
Disabling the material hatching and setting the area fill to none.
Looping every single face in the view seems to take forever to process a single face...is there a better way to achieve this?
Sample code from the help I modified just select a section in a assembly and start the macro.
Code: Select all
'-----------------------------------------------------------------
' Preconditions:
' 1. Open public_documents\introsw\bolt-assembly.slddrw.
' 2. Select Section View A-A in the FeatureManager design tree.
' 3. Open the Immediate window.
'
' Postconditions:
' 1. Gets face hatch data.
' 2. Examine the Immediate window.
'---------------------------------------------------------------
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swView As SldWorks.View
Dim vFaceHatch As Variant
Dim swFaceHatch As SldWorks.FaceHatch
Dim swFace As SldWorks.Face2
Dim i As Long
Dim temp As Boolean
Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swView = swSelMgr.GetSelectedObject6(1, -1)
Debug.Print "View = " & swView.Name
Debug.Print " Type = " & swView.Type
vFaceHatch = swView.GetFaceHatches
If IsEmpty(vFaceHatch) Then
Debug.Print " No face hatches in selected view."
Exit Sub
End If
Debug.Print " Number of face hatches in this view = " & (UBound(vFaceHatch) + 1)
If Not IsEmpty(vFaceHatch) Then
Debug.Print " Face hatches ="
Debug.Print ""
For i = 0 To UBound(vFaceHatch)
Set swFaceHatch = vFaceHatch(i)
' Get face hatch data
Debug.Print "Current Material crosshatch = " & swFaceHatch.UseMaterialHatch
Debug.Print "Current Material crosshatch = " & swFaceHatch.UseMaterialHatch
Set swFace = swFaceHatch.Face
swFace.Select2 True, 0
swFaceHatch.UseMaterialHatch = False
swFaceHatch.HatchType = 1
Next i
End If
End Sub