HIDE SKETCH IN ALL CONFIGURATIONS

Hello everyone, I hope you are well.

I have a question about the sketches.

I have a room that has a lot of color configurations.

There is a basic sketch in the tree for building the functions.

The sketch is visible in all configurations.

I would like to know if anyone has a solution to hide this sketch in all configurations at once?

Because when you look at the properties of the sketch, you can check "deleted" and have the configuration option. But there's nothing to hide...

Thank you in advance.

1 Like

Hi, look at this macro that from memory does the job. (hides all the sketches of all the configs)

Option Explicit

 

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim curFeature As Feature

Dim subFeature As Feature

Dim featureTypeName As String

Dim firstSub As Boolean

Dim Msg As String

Dim Style As Variant

Dim cfgNames As Variant

Dim cfg As Variant

Dim Title As String

Dim originalCfg As String

Dim lastCfg As String

 

Dim modView As ModelView

 

 

 

 

 

Sub main()

 

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

   

    If swModel.GetType <> swDocPART Then

        Msg = "Only Allowed on Part" ' Define message

        Style = vbOKOnly ' OK Button only

        Title = "Error" ' Define title

        Call MsgBox(Msg, Style, Title) ' Display error message

        Exit Sub ' Exit this program

    End If


    cfgNames = swModel.GetConfigurationNames

   

    originalCfg = swModel.GetActiveConfiguration.Name

    Debug.Print "Original Cfg:" & originalCfg

   

    For Each cfg In cfgNames

        swModel.ShowConfiguration2 cfg

        HideGeom swModel

        lastCfg = cfg

        Debug.Print "Last Cfg:" & lastCfg

    Next

   

    If Not lastCfg = originalCfg Then

        swModel.ShowConfiguration2 originalCfg

    End If

   

    Set modView = swModel.ActiveView

    modView.DisplayMode = swViewDisplayMode_e.swViewDisplayMode_ShadedWithEdges

    modView.DisplayMode = swViewDisplayMode_e.swViewDisplayMode_PerspectiveOff

   

    swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swDisplayAmbientOcclusionShadows, False

    swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swDisplayShadowsInShadedMode, False

   

    swModel.Extension.ViewDisplayRealView = False

   

    swModel.ShowNamedView2 "", swStandardViews_e.swIsometricView

    swModel.ViewZoomtofit2

   

    swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swPerformanceVerifyOnRebuild, True

   

End Sub

 

Sub HideGeom(m As ModelDoc2)

   

    Set curFeature = m.FirstFeature()

    Do While Not curFeature Is Nothing

        featureTypeName = curFeature.GetTypeName2()

        If curFeature.Visible = swVisibilityState_e.swVisibilityStateShown And Not curFeature.IsSuppressed Then

            Select Case featureTypeName

                Case "RefPlane", "RefAxis", "CoordSys", "RefPoint", "ReferenceCurve"

                    Debug.Print "FeatureTypeName: " & curFeature.Name & " " & featureTypeName

                    curFeature.Select (False)

                    m.BlankRefGeom

                Case "ProfileFeature", "3DProfileFeature"

                    Debug.Print "FeatureTypeName: " & curFeature.Name & " " & featureTypeName

                    curFeature.Select (False)

                    m.BlankSketch

            End Select

        End If

       

        firstSub = True

        Set subFeature = curFeature.GetFirstSubFeature()

        Do While Not subFeature Is Nothing

            featureTypeName = subFeature.GetTypeName2()

            If subFeature.Visible = swVisibilityState_e.swVisibilityStateShown And Not subFeature.IsSuppressed Then

                Select Case featureTypeName

                    Case "RefPlane", "RefAxis", "CoordSys", "RefPoint", "ReferenceCurve"

                        If firstSub Then

                            Debug.Print "FeatureTypeName: " & subFeature.Name & " " & featureTypeName

                            firstSub = False

                        End If

                        Debug.Print vbTab & "FeatureTypeName: " & subFeature.Name & " " & featureTypeName

                        curFeature.Select (False)

                        m.BlankRefGeom

                    Case "ProfileFeature", "3DProfileFeature"

                        If firstSub Then

                            Debug.Print "FeatureTypeName: " & subFeature.Name & " " & featureTypeName

                            firstSub = False

                        End If

                        Debug.Print vbTab & "FeatureTypeName: " & subFeature.Name & " " & featureTypeName

                        curFeature.Select (False)

                        m.BlankSketch

                End Select

            End If

           

        Set subFeature = subFeature.GetNextSubFeature()

        Loop

       

    Set curFeature = curFeature.GetNextFeature()

    Loop

End Sub

 

4 Likes

See this link among others

A macro that works in 2017 matches the demand

https://www.lynkoa.com/forum/conception-3d/est-il-possible-de-cacher-automatiquement-les-esquisses-et-%C3%A9l%C3%A9ments-de-construct

@+:-)

3 Likes

Well a BIG THANK YOU Shadenis, the macro works perfectly well and will simplify my life!!!

It's perfect.

Have a nice day

3 Likes

Thanks @gt22, the macro function on the active config only I have the impression.

On the other hand, it is interesting for its mode of operation with multiple choices (sketches, plans, etc.)

 

 

3 Likes