Use iLogic to add Description to Leader Text

Use iLogic to add Description to Leader Text

el_jefe_de_steak
Collaborator Collaborator
1,631 Views
2 Replies
Message 1 of 3

Use iLogic to add Description to Leader Text

el_jefe_de_steak
Collaborator
Collaborator

 

Hi, I'm trying to use iLogic to add the linked model property "description" to my leader text. However, this code does not work for me. Any ideas on how to fix it? This code works great for changing view labels.

 

If ThisApplication.ActiveDocumentType <> kDrawingDocumentObject Then
	MessageBox.Show("This rule only works in a drawing document.", "Change Leader Text",MessageBoxButtons.OK,MessageBoxIcon.Error)
	Return
End If

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument

Dim oLeaderNote As LeaderNote

saveOriginalText = False
addDescription = False

Question = MessageBox.Show("Overwrite existing leader text?", "Change Leader Text",MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question,MessageBoxDefaultButton.Button1)

Select Case Question:
Case vbYes
	saveOriginalText = False
Case vbNo
	saveOriginalText = True
Case vbCancel
	Return
End Select


'define model property values
oDescription = "<Property Document='model' PropertySet='Design Tracking Properties' Property='Description'>DESCRIPTION</Property>"


For Each oLeaderNote In oDoc.ActiveSheet.DrawingNotes
	
	'saves the original text
	originalText = oLeaderNote.FormattedText
	
	oLeaderNote.FormattedText = oDescription
		
	'adds original beginning to end of label text if applicable
	If saveOriginalText = True Then
		oLeaderNote.FormattedText = oLeaderNote.FormattedText & vbCr & originalText
	End If
Next

 

 

Accepted solutions (2)
1,632 Views
2 Replies
Replies (2)
Message 2 of 3

el_jefe_de_steak
Collaborator
Collaborator
Accepted solution

This code works fine as is...

 

There was an error in my original code which I mindlessly fixed while formatting it for putting it on the forum.

0 Likes
Message 3 of 3

A.Acheson
Mentor
Mentor
Accepted solution

Thanks for posting this code. I found an error, where the collection the code was trying to modify was omitted. 

Error on this line collection in red was omitted.

For Each oLeaderNote In oDoc.ActiveSheet.DrawingNotes.LeaderNotes

Below code is working now.

If ThisApplication.ActiveDocumentType <> kDrawingDocumentObject Then
	MessageBox.Show("This rule only works in a drawing document.", "Change Leader Text",MessageBoxButtons.OK,MessageBoxIcon.Error)
	Return
End If

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument

Dim oLeaderNote As LeaderNote

saveOriginalText = False
addDescription = False

Question = MessageBox.Show("Overwrite existing leader text?", "Change Leader Text",MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question,MessageBoxDefaultButton.Button1)

Select Case Question:
Case vbYes
	saveOriginalText = False
Case vbNo
	saveOriginalText = True
Case vbCancel
	Return
End Select


'define model property values
oDescription = "<Property Document='model' PropertySet='Design Tracking Properties' Property='Description'>DESCRIPTION</Property>"


For Each oLeaderNote In oDoc.ActiveSheet.DrawingNotes.LeaderNotes
	
	'saves the original text
	originalText = oLeaderNote.FormattedText
	
	oLeaderNote.FormattedText = oDescription
		
	'adds original beginning to end of label text if applicable
	If saveOriginalText = True Then
		oLeaderNote.FormattedText = oLeaderNote.FormattedText & vbCr & originalText
	End If
Next

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes