Invisible parts in drawings

Invisible parts in drawings

kresh.bell
Collaborator Collaborator
793 Views
5 Replies
Message 1 of 6

Invisible parts in drawings

kresh.bell
Collaborator
Collaborator

Hi,

is it possible to create iLogic that in drawings will make invisible all parts coming from eg a specific folder from library?

0 Likes
Accepted solutions (1)
794 Views
5 Replies
Replies (5)
Message 2 of 6

JelteDeJong
Mentor
Mentor

Hi,

i guessed to you mean a folder on your drive. if that is the case try this script. if you want to hide files from an other folder then change the variable "textToSearchFor "

Dim textToSearchFor As String = "\forum\"
Dim view As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select view")
Dim assembly As AssemblyDocument = view.ReferencedDocumentDescriptor.ReferencedDocument

For Each occ As ComponentOccurrence In assembly.ComponentDefinition.Occurrences
    Dim fileName As String = occ.ReferencedFileDescriptor.FullFileName
    If (fileName.Contains(textToSearchFor)) Then
        For Each curve As DrawingCurve In view.DrawingCurves(occ)
            For Each segment As DrawingCurveSegment In curve.Segments
                segment.Visible = False
            Next
        Next
    End If
Next

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 6

kresh.bell
Collaborator
Collaborator

Hi,

absolutely fantastic, works great.

 

Is it possible to edit this iLogic to hide all parts that have the prefix "-" in the solid bodies name? All my hols make parts with the prefix "-"  in the solid bodies name and in drawing are in reality redundant.

 

2020-03-20 210507.jpg

 

 

0 Likes
Message 4 of 6

JelteDeJong
Mentor
Mentor
Accepted solution
Sub Main()

    Dim view As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select view")
    Dim assembly As AssemblyDocument = view.ReferencedDocumentDescriptor.ReferencedDocument

    For Each occ As ComponentOccurrence In assembly.ComponentDefinition.Occurrences
        Dim occDoc As Document = occ.Definition.Document
        If (occDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject) Then
            Dim partDoc As PartDocument = occDoc
            Dim name As String = partDoc.ComponentDefinition.SurfaceBodies.Item(1).Name
            If (name.StartsWith("-")) Then
                hideOccurence(view, occ)
            End If
        End If
    Next

End Sub

Private Sub hideOccurence(view As DrawingView, occ As ComponentOccurrence)
    For Each curve As DrawingCurve In view.DrawingCurves(occ)
        For Each segment As DrawingCurveSegment In curve.Segments
            segment.Visible = False
        Next
    Next
End Sub

this rule will only work if the first body has the prefix.

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 5 of 6

kresh.bell
Collaborator
Collaborator

Hi,

extraordinary !!!! It works great. Thanks again

0 Likes
Message 6 of 6

kresh.bell
Collaborator
Collaborator

I found one minor problem. Can you fix it?
iLogic works great if solid with the prefix "-" is not part of subassembly.

 

I'll point to an example of a drawer.

 

It works for this solid

img 01.jpg


It doesn't work for this solid

img 02.jpg

 

in drawing it looks like this

img 03.jpgimg 04.jpg

0 Likes