Message 1 of 2
Placing custom leaders on parts in drawing view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have this ilogic code that places each individual part from the assembly on a new sheet in a drawing. In addition to that it places a text with some custom properties for that part.
I was wondering if there is a possibility to alter the code so that instead of a text there could be placed a custom leader that reads the same custom properties, aka something like an autoballon but with a custom leader.
This is the logic that I used:
'Determine if the file is an assembly or not and exit if this is only a Part
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("This rule is for assembly documents",, "iLogic")
Exit Sub
End If
'Define the necessary document variables
Dim oAssyDoc As AssemblyDocument = ThisDoc.Document
Dim oAssyCompDef As AssemblyComponentDefinition = oAssyDoc.ComponentDefinition
'Obtain the BOM and ensure the "Parts Only" BOM is enabled
Dim oBOM As BOM = oAssyCompDef.BOM
oBOM.PartsOnlyViewEnabled = True
Dim oBOMView As BOMView = oBOM.BOMViews.Item("Parts only")
Dim drawing As DrawingDocument ' Declare the drawing document variable
' Loop through each open document to find the drawing document
For Each doc As Document In ThisApplication.Documents
If doc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
drawing = doc ' Set the drawing document variable
Exit For ' Exit the loop once the drawing document is found
End If
Next
If drawing Is Nothing Then
MsgBox("No drawing document found", MsgBoxStyle.Exclamation, "iLogic")
Exit Sub
End If
' Create a new sheet in the drawing document
Dim newSheet As Sheet = drawing.Sheets.Add()
Dim XPos As String
Dim YPos As String
XPos = 65
YPos = 30
'Cycle through each row of the "Parts Only" BOMView
For Each oBOMRow As BOMRow In oBOMView.BOMRows
Dim occ As ComponentOccurrence = oBOMRow.ComponentOccurrences.Item(1)
Dim name = occ.Name
Dim Area As String
Dim oPoint As Point2d
oPoint = ThisApplication.TransientGeometry.CreatePoint2d(XPos+1, YPos-2)
oOne = "Item Number: " & iProperties.Value(oBOMRow.ComponentOccurrences.Item(1).Name, "Custom", "Item Number")
oTwo = "Quantity: " & iProperties.Value(oBOMRow.ComponentOccurrences.Item(1).Name, "Custom", "Item qt")
oFour = "Material: " & iProperties.MaterialOfComponent(oBOMRow.ComponentOccurrences.Item(1).Name)
oThree = "Mass: " & Round(iProperties.MassOfComponent(oBOMRow.ComponentOccurrences.Item(1).Name), 2) & " kg"
oFive = "Area: " & iProperties.Value(oBOMRow.ComponentOccurrences.Item(1).Name, "Custom", "Area") & "mm˘2"
Try
Dim refDoc = occ.Definition.Document
Dim insertPoint = ThisApplication.TransientGeometry.CreatePoint2d(XPos, YPos)
Dim orientation = ViewOrientationTypeEnum.kFrontViewOrientation
Dim scale = 1/10
Dim viewStyle = DrawingViewStyleEnum.kHiddenLineDrawingViewStyle
' Add drawing view to the new sheet
newSheet.DrawingViews.AddBaseView(refDoc, insertPoint, scale, orientation, viewStyle)
strText = oOne & vbLf & oTwo & vbLf & oThree & vbLf & oFour & vbLf & oFive
oGeneralNote = newSheet.DrawingNotes.GeneralNotes.AddFitted(oPoint, strText)
' Update position for the next view
XPos = XPos + 12
If XPos > 150 Then
YPos = YPos - 10
XPos = 65
End If
Catch ex As Exception
Logger.Info("Cannot create drawing view")
End Try
Next