Announcements

Community notifications may experience intermittent interruptions between 10–12 November during scheduled maintenance. We appreciate your patience.

Layer Visibility On Different Sheets

Layer Visibility On Different Sheets

Anonymous
Not applicable
1,583 Views
6 Replies
Message 1 of 7

Layer Visibility On Different Sheets

Anonymous
Not applicable

I am trying to control the layer visibility on different sheets of the same drawing but have not quite figured it out yet.

 

We add a DXF sheet to drawings with flat pattern views to export to DXF for our laser.  I wrote a VBA macro that adds the sheet, copies the flat pattern view and removes the dimensions to clean it up before creating the DXF.  I am having a problem turning off the visibility of the bend lines on JUST the DXF sheet.  I can turn bend lines and hidden lines off with this:

 

'Turn off bend lines and hidden lines
For Each oView In oSheet.DrawingViews

    'Set the layers collection
    Set oLayers = oDrawingDoc.StylesManager.Layers
    
    'Turn off all bend lines and hidden lines
    For Each oLayer In oLayers
        If Not InStr(oLayer.Name, "Bend Centerline") = 0 Or Not InStr(oLayer.Name, "Hidden") = 0 Then
            oLayer.Visible = False
        Else
        End If
    Next
    
Next

 but it turns them off on all sheets.  I want to only turn them off on the DXF sheet.  How would this be done?

0 Likes
Accepted solutions (3)
1,584 Views
6 Replies
Replies (6)
Message 2 of 7

jdkriek
Advisor
Advisor
Accepted solution

Here's how I usually turn off hidden for a specific sheet.

 

Sub TurnOffHidden()
Dim oDrawingDoc As DrawingDocument
Set oDrawingDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
'Define which sheet
Set oSheet = oDrawingDoc.Sheets.Item(1)

Dim oView As DrawingView
    For Each oView In oSheet.DrawingViews
        oView.ViewStyle = kHiddenLineRemovedDrawingViewStyle
    Next
End Sub
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes
Message 3 of 7

Anonymous
Not applicable

Thanks, that is half the problem.  Any ideas for the bend lines?

0 Likes
Message 4 of 7

jdkriek
Advisor
Advisor

I usually set those options when I export the DXF

 

Dim oDataIO As DataIO
Set oDataIO = oPart.ComponentDefinition.DataIO
        
'Set ACAD Version, Outer Profile, and hide bend lines
Dim sOut As String
sOut = "FLAT PATTERN DXF?AcadVersion=2000&OuterProfileLayer=Outer&InvisibleLayers=IV_Tangent;IV_Bend;IV_Bend_Down;IV_Bend_Up;IV_ARC_CENTERS"
        
'Create Save Path
Dim SavePath As String
SavePath = "C:\DXF OUT\" & sPartNum.Value & ".dxf"

'Create the DXF file.
oDataIO.WriteDataToFile sOut, SavePath
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes
Message 5 of 7

Anonymous
Not applicable

I usually do it that way too but we like to have a separate sheet that shows the flat view exactly as you would see it in the DXF.  Right now we just right click on them and turn off.

0 Likes
Message 6 of 7

jdkriek
Advisor
Advisor
Accepted solution

This is as far as I got. 

 

It's interesting to me that once I found the bendline, I wasn't able to select it for DrawingEntityVisibilityCtxCmd via the Command Manager which is the command that is used when you right-click and hide the line through the UI.

 

Sub NixHiddenBend()
Dim oDrawingDoc As DrawingDocument
Set oDrawingDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
'Define which sheet
Set oSheet = oDrawingDoc.Sheets.Item(1)
Dim oView As DrawingView
    For Each oView In oSheet.DrawingViews
        oView.ViewStyle = kHiddenLineRemovedDrawingViewStyle
        'If it's a flatpattern view
        If oView.IsFlatPatternView = True Then
            Dim oViewCurves As DrawingCurvesEnumerator
            Set oViewCurves = oView.DrawingCurves()
            Dim oBendLine As DrawingCurve
                'Find all the lines
                For count = 1 To oViewCurves.count
                    Set oBendLine = oViewCurves.Item(count)
                    'If it's a bendline
                    If oBendLine.EdgeType = kBendDownEdge Or oBendLine.EdgeType = kBendUpEdge Then
                        MsgBox ("Found you pesky bendline")
                    End If
                Next
        End If
    Next
End Sub
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes
Message 7 of 7

xiaodong_liang
Autodesk Support
Autodesk Support
Accepted solution

Hi 

Sub NixHiddenBend()
Dim oDrawingDoc As DrawingDocument
Set oDrawingDoc = ThisApplication.ActiveDocument

Dim oSel As SelectSet
Set oSel = oDrawingDoc.SelectSet
oSel.Clear

Dim oSheet As Sheet
'Define which sheet
Set oSheet = oDrawingDoc.Sheets.Item(1)
Dim oView As DrawingView
    For Each oView In oSheet.DrawingViews
        oView.ViewStyle = kHiddenLineRemovedDrawingViewStyle
        'If it's a flatpattern view
        If oView.IsFlatPatternView = True Then
            Dim oViewCurves As DrawingCurvesEnumerator
            Set oViewCurves = oView.DrawingCurves()
            Dim oBendLine As DrawingCurve
                'Find all the lines
                For Count = 1 To oViewCurves.Count
                    Set oBendLine = oViewCurves.Item(Count)
                    'If it's a bendline
                    If oBendLine.EdgeType = kBendDownEdge Or oBendLine.EdgeType = kBendUpEdge Then
                        'MsgBox ("Found you pesky bendline")
                        Dim oSeg As DrawingCurveSegment
                        For Each oSeg In oBendLine.Segments
                            oSel.Select oSeg
                        Next
                    End If
                Next
        End If
    Next
    
    
     ThisApplication.CommandManager.ControlDefinitions("DrawingEntityVisibilityCtxCmd").Execute
End Sub