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?
Solved! Go to Solution.
Solved by xiaodong_liang. Go to Solution.
Solved by jdkriek. Go to Solution.
Solved by jdkriek. Go to 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
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
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.
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
Hi jdkriek,
I just took a look at the issue "wasn't able to select it for DrawingEntityVisibilityCtxCmd". After I modified the code as below, it works.
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