Components in Section Drawing View

Components in Section Drawing View

Anonymous
Not applicable
821 Views
5 Replies
Message 1 of 6

Components in Section Drawing View

Anonymous
Not applicable

Hi,

 

Does anyone know how to traverse only the components in the section drawing view? I was planning to display balloon to the components that are only visible in the section drawing view. I tried using ReferencedDocumentDescriptor.ReferencedDocument but this refers to the assembly file.

 

Please refer to the attached file for reference.

 

Please help me on this.

0 Likes
822 Views
5 Replies
Replies (5)
Message 2 of 6

philippe.leefsma
Alumni
Alumni

Hi

 

I don't think there is a direct way to achieve that.

 

You could either iterate through all occurrences of your top level assembly and see if "DrawingView.DrawingCurves(occurrence)" returns something, if yes the component is part of the view.

 

Or the other way around, iterate through all the DrawingCurves in the specific view and check "DrawingCurve.ModelGeometry" to see which occurrence this belong to.

 

I hope it helps.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi Philippe

 

I already tried both of your suggestion before but still I cannot get my expected output. I'm don't know why it still display the components even I trapped if drawingcurves is nothing and drawingcurves.count=0.

0 Likes
Message 4 of 6

xiaodong_liang
Autodesk Support
Autodesk Support

Hi 3DAriel,

 

Philippe's suggestions look fine to me. Could you provide your test code to help us to diagnose?

0 Likes
Message 5 of 6

Anonymous
Not applicable

Please see the attached code

Set iDrawingCurves = oView.DrawingCurves(subPart)
                        If Not iDrawingCurves Is Nothing And iDrawingCurves.count <> 0 Then
                            For Each iDrawingCurve In iDrawingCurves
                                If iDrawingCurve.CurveType = kLineSegmentCurve Then
                                    If countCLines = 0 Then
                                        Set oIntentPipe1 = oSheet.CreateGeometryIntent(iDrawingCurve)
                                        countCLines = countCLines + 1
                                    ElseIf countCLines = 1 Then
                                        Set oIntentPipe2 = oSheet.CreateGeometryIntent(iDrawingCurve)
                                        countCLines = countCLines + 1
                                        Exit For
                                    End If
                                End If
                            Next
                            
                            If countCLines = 2 Then
                                Call cLine.AddBisector(oIntentPipe1, oIntentPipe2)
                            End If
                        End If

 

 

0 Likes
Message 6 of 6

philippe.leefsma
Alumni
Alumni

Here is the code I am using with attached drawing (Inventor 2013) and it seems to work fine, maybe your issue is specific to the data set you are using...

 

Public Sub GetViewComponents()

    Dim doc As DrawingDocument
    Set doc = ThisApplication.ActiveDocument
    
    Dim sectionView As SectionDrawingView
    Set sectionView = doc.ActiveSheet.DrawingViews(2)
    
    Dim docDesc As DocumentDescriptor
    Set docDesc = sectionView.ReferencedDocumentDescriptor

    Dim asm As AssemblyDocument
    Set asm = docDesc.ReferencedDocument
    
    Debug.Print "Occurrences in View: " & sectionView.name
    
    On Error Resume Next
    
    Dim occurrence As ComponentOccurrence
    For Each occurrence In asm.ComponentDefinition.Occurrences
    
        Dim curves As DrawingCurvesEnumerator
        Set curves = sectionView.DrawingCurves(occurrence)
        
        If Err Then
            'DrawingCurves fails if no curves...
            Err.Clear
        ElseIf curves Is Nothing Or curves.count = 0 Then
            'Component not in view...
        Else
            'Component is in section view
            Debug.Print occurrence.name
        End If
    
    Next
    
End Sub

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes