10-19-2021
12:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-19-2021
12:22 AM
You can use the general note for this. here is a small example. I created a simple excel sheet with two columns to test this. you need to add some check if the material is not found for example.
You can chaneg the code if you need custom formatted text. if you run the code twice, it will place a new note as well i hope this gives you a good starting point.
Sub main ' This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument Dim modelDoc = ThisDrawing.ModelDocument Try If modelDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then Dim oPart As PartDocument oPart = modelDoc 'get active material oMaterial = oPart.ComponentDefinition.material.name Else Logger.Info("model is not part") Exit Sub End If Catch Logger.Info("No model document") Exit Sub End Try 'ophalen template path definitie oPathWP = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath 'get data from excel oFile = oPathWP & "\Projects\PRJ0081\Mat.xlsx" i = GoExcel.FindRow(oFile, "Sheet1", "Material", "=", oMaterial) oNewText = GoExcel.CellValue(oFile, "Sheet1", "B"&i) ' Set a reference to the active sheet. Dim oActiveSheet As Sheet oActiveSheet = oDrawDoc.ActiveSheet ' Set a reference to the GeneralNotes object Dim oGeneralNotes As GeneralNotes oGeneralNotes = oActiveSheet.DrawingNotes.GeneralNotes Dim oTG As TransientGeometry oTG = ThisApplication.TransientGeometry ' Create text with simple string as input. Since this doesn't use ' any text overrides, it will default to the active text style. Dim sText As String sText = oNewText Dim oGeneralNote As GeneralNote oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(3, 18), sText) End Sub