Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am just creating a script that should implement a certain number of text strings (t_1, t_2...) into the same number of sketches. This sketches are always named "Text1_sketch, Text2_sketch..." the text strings ("ZZZ", "UUU"...) are entered manually in the script.
In general I am just starting a loop 1-5 and iterate "i" to use it as indicator for the related sketch AND the related variable. But the variable is not correctly assigned or initialized. I guess it is just my lag in python programming. Has anyone a hint how to "easily" achieve my goal
# change text in sketch "i" to variable "t_i"
sketches = app.activeProduct.rootComponent.sketches
for i in range(1,5😞
t_1 = "ZZZ"
t_2 = "UUU"
t_3 = "PPP"
t_4 = "EEE"
sketchname = "Text" + str(i) + "_sketch"
textstring = "t_"+(i)
textsketch = sketches.itemByName(sketchname)
textsketchtexts = textsketch.sketchTexts
#.item(no.): no. indicates number of text in dedicated sketch
textinputitem = textsketchtexts.item(0)
textinputitem.text = textstring
Solved! Go to Solution.