How can the text height be adjusted with iLogic?

How can the text height be adjusted with iLogic?

FeelGoodGirl
Advocate Advocate
1,232 Views
2 Replies
Message 1 of 3

How can the text height be adjusted with iLogic?

FeelGoodGirl
Advocate
Advocate

Hey everybody,

 

I made a piece of iLogic code that puts text in a desired place. Only now I want to adjust the size of the text. Below is an example of what I have now and what I want.

Aantekening 2020-03-04 152517.png

Does anyone know how I can do this?

 

This is my code so far.

Sub Main
	Dim Sheet
	Sheet = "page1:1"
	
	DeleteNote(Sheet)
	
	TextX = 5
	TextY = 5
	
	AddNote(Sheet, TextX, TextY, scale)
End Sub

'-----Deleting note-----
Sub DeleteNote(Sheet)
	oActiveSheet = ThisDrawing.Sheet(Sheet).Sheet
		
	For Each oGeneralNote In oActiveSheet.DrawingNotes.GeneralNotes
		If oGeneralNote.Rotation = 0.01
			oGeneralNote.Delete
		End If
	Next	
End Sub 'DeleteNote
	
'-----Adding note-----
Sub AddNote(Sheet, TextX, TextY, scale)
	oActiveSheet = ThisDrawing.Sheet(Sheet).Sheet
	
	' Tekst what is going to be placed
	tekst = "test"
	
	XPos = TextX
	YPos = TextY
	
	oNote = oActiveSheet.DrawingNotes.GeneralNotes.AddFitted(ThisApplication.TransientGeometry.CreatePoint2d(XPos, YPos), tekst)
	
	' When adding the note, it is placed at a small angle. Searching for text at this angle can remove it again.
	With oNote
		.Rotation = 0.01 'radianti
	End With
	
	oActiveSheet.Update()
End Sub 'AddNote

 

I look forward to your response.

0 Likes
Accepted solutions (1)
1,233 Views
2 Replies
Replies (2)
Message 2 of 3

Justin.B.
Enthusiast
Enthusiast
Accepted solution

Give this a try:

'-----Adding note-----
Sub AddNote(Sheet, TextX, TextY, scale)
	oActiveSheet = ThisDrawing.Sheet(Sheet).Sheet
	
	' Tekst what is going to be placed
	tekst = "test"
	
	XPos = TextX
	YPos = TextY
	
	oNote = oActiveSheet.DrawingNotes.GeneralNotes.AddFitted(ThisApplication.TransientGeometry.CreatePoint2d(XPos, YPos), tekst)
	oNote.FormattedText = "<StyleOverride FontSize='10'>" & tekst & "</StyleOverride>"

You can use the <StyleOverride> tag to change size, font, or set things like bold and underlines, etc.

Message 3 of 3

FeelGoodGirl
Advocate
Advocate

This works perfectly. Thank you for your code.

0 Likes