How to edit ChamferNote.Text

How to edit ChamferNote.Text

Anonymous
Not applicable
619 Views
4 Replies
Message 1 of 5

How to edit ChamferNote.Text

Anonymous
Not applicable

Windows 10(64bit)

Inventor Professional 2019 (64bit Edition)

 

I would like to edit ChamferNote.Text.

Here is my Python3.7 code.

 

# -*- coding:utf-8 -*- 
from win32com.client import gencache, constants
inv_lib = gencache.EnsureModule('{D98A091D-3A0F-4C3E-B36E-61F62068D488}', 0, 1, 0)

invApp = win32com.client.Dispatch("Inventor.Application")
doc = invApp.Documents.Open("Target.ipt", OpenVisible=True)
dra_doc = inv_lib.DrawingDocument(doc)
sheet = draw_doc.Sheets.Item(1)

for note in sheet.DrawingNotes.ChamferNotes:
print(note.Text) # C0.5
note.Text = "4-" + note.Text

Expected: note.Text == "4-C0.5"

Actual:

ChamferNote.png

 

How do I write to get the expected result?

 

0 Likes
Accepted solutions (2)
620 Views
4 Replies
Replies (4)
Message 2 of 5

NigelHay
Advisor
Advisor

You could just change the dimension style.

0 Likes
Message 3 of 5

Anonymous
Not applicable

Thank you for your reply. But I want to know methods using Inventor API.

0 Likes
Message 4 of 5

Anonymous
Not applicable
Accepted solution

I got it.

 

for note in sheet.DrawingNotes.ChamferNotes:
note.FormattedText = f"4-{note.FormattedText}"

Use "FormattedText". But FormattedText doesn't delete own it (I don't know how to delete). 

It means:

note.FormattedText = ""  # FormattedText doesn't be empty strings.
0 Likes
Message 5 of 5

Anonymous
Not applicable
Accepted solution

I got again.

Following is a way to hide FormattedText.

 

for note in sheet.DrawingNotes.ChamferNotes:
note.HideValue = False # Hide FormattedText
note.FormattedText = ""
print(note.Text) # "C0.5"

note.HideValue = True
note.FormattedText = ""
print(note.Text) # "" (empty string)