Macro Hide/Show Sketch Bend Line

Hello

I am once again calling on the community to find an example or piece of code to be able to hide or show the bend lines from an MEP.

Hello

To follow up after research, here is a partially functional piece of code:

Dim swApp As Object
Dim boolstatus As Boolean
Sub main()

Set swApp = Application.SldWorks


Set Part = swApp.ActiveDoc
boolstatus = Part.ActivateView("Drawing View1")
boolstatus = Part.Extension.SelectByID2("Bend-Lines2@Part1@Drawing View1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
Part.BlankSketch
MsgBox "Ligne de pliage caché"
boolstatus = Part.Extension.SelectByID2("Bend-Lines2@Part1@Drawing View1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
Part.UnblankSketch
MsgBox "Ligne de pliage affiché"
End Sub

I can get the name of the view (Drawing View 1), the name of the part (Part1), but it's impossible to get the name of the bend line when they are hidden (Bend-Lines2)

Here is the functional code for non-hidden bend lines:

While Not swView Is Nothing
    If swView.IsFlatPatternView Then
        swDraw.ActivateView swView.GetName2
        Debug.Print swView.GetName2
        Debug.Print swView.GetBendLineCount
        If swView.GetBendLineCount > 0 Then
            BendlinesArr = swView.GetBendLines
            For Each Bendline In BendlinesArr
                Set swSketchLine = Bendline

                'ajout pour cacher montrer les lignes de pliages
                Dim swFeat As SldWorks.Feature
                Dim swDrComp As SldWorks.DrawingComponent
                Set swDrComp = swView.RootDrawingComponent
                Debug.Print swDrComp.Name
                Dim swSkSeg As SldWorks.SketchSegment
                Set swSkSeg = Bendline
                Dim swSketch As SldWorks.Sketch
                Set swSketch = swSkSeg.GetSketch
                Set swFeat = swSketch
                Debug.Print swFeat.Name

The problem is that it does not find a bend line if they are hidden Bendlines = 0 and therefore does not  launch the code to retrieve the name of the bend lines.

Nobody has another simple idea to select this famous bend line?

Hello, you want to show or hide the fold lines on your plans, right?

If so, the bend lines are actually sketches, so with the filters you may or may not activate the Sketch filters with one click.

may the force be with you.

 

It's a little more complicated than that unfortunately! I have a macro that does a laser marking of the ends of the fold lines (Strongly inspired by JeromeP's link), which only works when this sketch is visible (if it's hidden it doesn't work) And then this macro does something else. So you really have to show this sketch in the MEP which is hidden in some drawings out of necessity and not only via the general options.

I close this subject that I have just unearthed with an answer to another question later but which fulfills the role:

https://www.lynkoa.com/forum/solidworks/macro-pour-r%C3%A9cuperer-le-nom-de-lesquisse-dans-le-1er-%C3%A9tat-d%C3%A9pli%C3%A9