Ilogic for note generation?

Ilogic for note generation?

Mark.Valenti
Advocate Advocate
336 Views
1 Reply
Message 1 of 2

Ilogic for note generation?

Mark.Valenti
Advocate
Advocate

I would like upon drawing creation, notes to be generated. If Aluminum 6061 is chosen as the model material, then a note would be generated:

MATERIAL: ALUMINUM 6061-T6, -T651 OR -T6511 PER ASTM B209,
ASTM B211, AMS-QQ-A-200/8A OR AMS4027.

 

This would be pulled from an excel spreadsheet where the spreadsheet would be arranged by material

 

 

-Mark

i7-7700K @4.2GHz
32 GB Ram
Nvidia Quadro 5000
0 Likes
337 Views
1 Reply
Reply (1)
Message 2 of 2

theo.bot
Collaborator
Collaborator

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

 

0 Likes