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: 

Components in Section Drawing View

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
642 Views, 5 Replies

Components in Section Drawing View

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.

5 REPLIES 5
Message 2 of 6
philippe.leefsma
in reply to: Anonymous

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

Message 3 of 6
Anonymous
in reply to: philippe.leefsma

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.

Message 4 of 6
xiaodong_liang
in reply to: Anonymous

Hi 3DAriel,

 

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

Message 5 of 6
Anonymous
in reply to: Anonymous

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

 

 

Message 6 of 6
philippe.leefsma
in reply to: Anonymous

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

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

Post to forums  

Autodesk Design & Make Report