Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Sub main()
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oActiveSheet As Sheet = oDoc.ActiveSheet
For Each oDrawingView As DrawingView In oActiveSheet.DrawingViews
If oDrawingView.Name = "VIEW6" Then
Dim oRefDoc As AssemblyDocument = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oAssDef As AssemblyComponentDefinition = oRefDoc.ComponentDefinition
Dim oOcc As ComponentOccurrence
For Each oOcc In oAssDef.Occurrences
Dim oSubOcc As ComponentOccurrence
For Each oSubOcc In oOcc.SubOccurrences
Dim componente As String = oSubOcc.Name
If componente.Contains("Gaskets:1") Then
MessageBox.Show(componente)
Dim oSubSubOcc As ComponentOccurrence
For Each oSubSubOcc In oSubOcc.SubOccurrences
Dim subComponente As String = oSubSubOcc.Name
If subComponente.Contains("Gasket:1") Then
MessageBox.Show(subComponente)
Dim Sheet_1 = ThisDrawing.Sheets.ItemByName("Sheet:1")
Dim VIEW6 = Sheet_1.DrawingViews.ItemByName("VIEW6")
Dim namedGeometry1 = VIEW6.GetIntent(subComponente,"WP_GasketTop")
Dim namedGeometry2 = VIEW6.GetIntent(subComponente, "WP_GasketBottom")
Dim genDims = Sheet_1.DrawingDimensions.GeneralDimensions
Dim dimX = -0.02
Dim dimY = -0.02
Dim linDim1 = genDims.AddLinear("Dimension 1" & componente, VIEW6.SheetPoint(dimX, dimY), namedGeometry1, namedGeometry2)
End If
Next
End If
Next
Next
End If
Next
End Sub
I have this code to generate dimensions in a drawing but I have this error
GetIntent("Gasket:1", "WP_GasketTop"): The component named "Gasket:1" was not found, what I don't understand is why it doesn't find the component if in a previous if it finds it.
I don't know if there is something I'm not seeing right in the code, I would appreciate your help!
Solved! Go to Solution.