Auto Text in Drawing idw

Anonymous

Auto Text in Drawing idw

Anonymous
Not applicable

Hi all,

 

I found below code to create the general notes in drawing idw. It works fine. But, i have one issue with this code. Everytime, i run this code. It simply creates new general notes. I don't want to create the general notes each time. Is it possible to track the general notes and replace the text on each time.

 

Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument

    ' 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

    'Dim dGeneralNote As GeneralNote
    'dGeneralNote = oGeneralNotes.delete()
    oGeneralNotes.Delete()
    ' 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 = iProperties.Value("Custom", "Component type")
    
    Dim oGeneralNote As GeneralNote
    oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(3, 3), sText)

 

Please let me know your ideas.

 

Thanks for your time and effort in advance.

 

Regards,

SJ

0 Likes
Reply
438 Views
1 Reply
Reply (1)

mullerv
Explorer
Explorer

Hi,

 

You can try to set the Text property of your existing GeneralNote (instead of deleting and re-creating), something like this:

 

' Set a reference to the GeneralNotes object
Dim oGeneralNotes As GeneralNotes
oGeneralNotes = oActiveSheet.DrawingNotes.GeneralNotes
    
Dim oGeneralNote As GeneralNote
oGeneralNote = oGeneralNotes.Item(1)
    
oGeneralNote.Text = "Your text here"

 

I assume that you always have only one GeneralNote in your drawing in this example. You may have to loop through the collection of notes if this is not your case.

 

Hope it helps.

 

Vladimir

 

0 Likes