Seting Editable Text from Python Consol/Scrypt

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
tobiasfalk
Posts: 93
Joined: Fri Feb 05, 2021 2:35 pm

Seting Editable Text from Python Consol/Scrypt

Post by tobiasfalk »

I try to set editable text from a Python script, I am able to reade the text it is set to but not able to set:
Reading:

Code: Select all

App.ActiveDocument.Page.Template.EditableTexts["FC-Title"]
How I thought one is able to set:

Code: Select all

App.ActiveDocument.Page.Template.EditableTexts["FC-Title"] = "FAA"
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Seting Editable Text from Python Consol/Scrypt

Post by Roy_043 »

It is a dictionary:

Code: Select all

dict = App.ActiveDocument.Page.Template.EditableTexts
dict["FC-Title"] = "FAA"
App.ActiveDocument.Page.Template.EditableTexts = dict
User avatar
bensay
Posts: 202
Joined: Wed Dec 22, 2021 8:14 pm
Location: Danmark
Contact:

Re: Seting Editable Text from Python Consol/Scrypt

Post by bensay »

Roy_043 wrote: Sat May 06, 2023 2:40 pm It is a dictionary:

Code: Select all

dict = App.ActiveDocument.Page.Template.EditableTexts
dict["FC-Title"] = "FAA"
App.ActiveDocument.Page.Template.EditableTexts = dict
It's very weird that this works, but not the other code. It's the same and should give the same result. This is a bug IMO.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Seting Editable Text from Python Consol/Scrypt

Post by Roy_043 »

Not weird exactly. App.ActiveDocument.Page.Template.EditableTexts returns a dictionary that is no longer linked to the property. Also dict["FC-Title"] = "FAA" returns None.
Post Reply