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.
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.
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.
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
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.