- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm trying to write a program that checks which parts are not ballooned in the BOM and then goes through all the drawing curves in the assembly drawing to balloon them. However, an error occurs when attempting to get ModelGeometry from DrawingCurve (line 38). Can someone help me resolve this issue?
Public Sub CheckPartsList()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
Dim oActiveSheet As Sheet
Set oActiveSheet = oDrawDoc.ActiveSheet
Dim oPartsList As PartsList
Set oPartsList = oActiveSheet.PartsLists(1)
Dim oPartslistRow As PartsListRow
Dim lstOfComponents As String
For Each oPartslistRow In oPartsList.PartsListRows
If oPartslistRow.Ballooned = False Then
Dim ItemNumber As String
ItemNumber = oPartslistRow.Item(5).Value
lstOfComponents = ItemNumber
End If
Next
Dim oDrawView As DrawingView
Set oDrawView = oActiveSheet.DrawingViews.Item(1)
Dim oDrawCurves As DrawingCurvesEnumerator
Set oDrawCurves = oDrawView.DrawingCurves
Dim oDrawCurve As DrawingCurve
Dim oCurveModelGeometry As Object
Dim oCurveContainingOccurence As Object
Dim PartNameFromCurve
For Each oDrawCurve In oDrawCurves
Set oCurveModelGeometry = oDrawCurve.ModelGeometry
'-------------delet part name from ":"
Set oCurveContainingOccurence = oCurveModelGeometry.ContainingOccurrence
PartNameFromCurve = oCurveContainingOccurence.Name
colonPosition = InStr(PartNameFromCurve, ":")
If colonPosition > 0 Then
ConfiguredPartNameFromCurve = Left(PartNameFromCurve, colonPosition - 1)
Else
ConfiguredPartNameFromCurve = PartNameFromCurve
End If
'---------------------------
'-----------compare part name from BOM and Drawingcurve
If ConfiguredPartNameFromCurve = lstOfComponents Then
MsgBox (PartNameFromCurve)
Exit For
End If
'---------------------------
Next
Stop
End Sub
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It looks like DrawingCurves is also returning Interference Edges. They don't belong to a model, hence the error. Add a check for oDrawCurve.ProjectedCurveType <> kUnknownCurve2d before getting ModelGeometry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Iteration over drawing curves and check which model belongs to is highway to hell.
Much better is to get component from PartsListRow and obtain its drawing curves. The sample below show you just "HOW TO" . It is not full implementation. It just selects one of many drawing curves which belongs to un-balloned component.
Public Sub CheckPartsList()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
Dim oActiveSheet As Sheet
Set oActiveSheet = oDrawDoc.ActiveSheet
Dim oPartsList As PartsList
Set oPartsList = oActiveSheet.PartsLists(1)
Dim oPartslistRow As PartsListRow
Dim asm As AssemblyDocument
Set asm = oPartsList.ReferencedDocumentDescriptor.ReferencedDocument
For Each oPartslistRow In oPartsList.PartsListRows
If Not oPartslistRow.Ballooned Then
Dim drawingBomRow As drawingBomRow
Set drawingBomRow = oPartslistRow.ReferencedRows(1)
Dim bomRow As bomRow
Set bomRow = drawingBomRow.bomRow
Dim compDef As ComponentDefinition
Set compDef = bomRow.ComponentDefinitions(1)
Dim occurrences As ComponentOccurrencesEnumerator
Set occurrences = asm.ComponentDefinition.occurrences.AllReferencedOccurrences(compDef)
Dim drawingCurvesEnumerator As drawingCurvesEnumerator
Set drawingCurvesEnumerator = oActiveSheet.DrawingViews(1).DrawingCurves(occurrences(1))
Call oDrawDoc.SelectSet.Clear
Call oDrawDoc.SelectSet.Select(drawingCurvesEnumerator(1).Segments(1))
MsgBox ("Continue")
End If
Next
End Sub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
There are several reasons
1. Performance. I worked on drawings with ten-thousands of drawing curves. Iteration over this collection spends a lot of time.
2. Drawing curves are not persistent objects. Sometimes it can be replaced with the new drawing curve for some reason. (Historical experience, it is hard to prepare working dataset but it happens sometimes)