Setting the command

Setting the command
 1# This example gets a text style sheet from the active drawing
 2# and creates a text entity at position 0,0 using the text style
 3# of the text style sheet. The command of the text entity is then modified
 4# so that the text entity displays the name of the active drawing
 5
 6# create a local variable for the active block
 7ab = impact.active_drawing.active_layer.active_block
 8
 9# create a local variable for the text style sheet to use
10text_style_sheet_name = "Palette Default"
11
12# attempt to get the specified text style sheet from the active drawing
13text_style_sheet = impact.active_drawing.text_style_sheets.item(text_style_sheet_name)
14
15# check that a text style sheet was found
16if not text_style_sheet.isNone():
17
18    # create local variables for the anchor and caption
19    anchor_x = 0
20    anchor_y = 0
21    caption = "Arden Software"
22
23    # create a text entity
24    text_entity = ab.text_ad(anchor_x, anchor_y, caption, text_style_sheet.text_style)
25
26    # check the text entity was created
27    if text_entity is not None:
28        text_entity.command = "[Script(""<VBScript>Result =  impact.active_drawing.full_name"")]"
29
30    else:
31
32        # display a message in the output toolbox
33        impact.gui.output_toolbox.add("An error occured creating the text entity")
34
35else:
36
37    # display a message in the output toolbox
38    impact.gui.output_toolbox.add("Unable to find the text style sheet '" + str(text_style_sheet_name) + "'")
39
40
41