Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Layer Visibility On Different Sheets

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Anonymous
1202 Views, 6 Replies

Layer Visibility On Different Sheets

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?

6 REPLIES 6
Message 2 of 7
jdkriek
in reply to: Anonymous

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.


Message 3 of 7
Anonymous
in reply to: jdkriek

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

Message 4 of 7
jdkriek
in reply to: Anonymous

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.


Message 5 of 7
Anonymous
in reply to: jdkriek

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.

Message 6 of 7
jdkriek
in reply to: Anonymous

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.


Message 7 of 7
xiaodong_liang
in reply to: jdkriek

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

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report