Fill Area¶
Fill Area¶
1# Check there is an active drawing
2ad = impact.active_drawing
3if ad.isNone():
4 impact.gui.output_toolbox.add("Unable to continue: no active drawing")
5else:
6 settings_name = "Fill Area 1mm"
7
8 # Check that the settings exist
9 settings = impact.active_database.find_master_tool_setting(settings_name, ipMasterSettingType.mstFillArea)
10 if settings.isNone():
11 impact.gui.output_toolbox.add("Unable to continue: can't locate hole finder settings '" + str(settings_name) + "'")
12 else:
13 ab = ad.active_layer.active_block
14
15 # define the extents of the rectangle
16 r = impact.creator.rect(0, 0, 0, 0)
17 r.bottom_left.x = 0
18 r.bottom_left.y = 0
19 r.top_right.x = 100
20 r.top_right.y = 100
21
22 # delete all visible entities in the active block
23 ab.select_all()
24 ab.delete_selected()
25
26 # draw a rectangle
27 ab.move_ad(r.bottom_left.x, r.bottom_left.y)
28 ab.line_ad(r.top_right.x, r.bottom_left.y)
29 ab.line_ad(r.top_right.x, r.top_right.y)
30 ab.line_ad(r.bottom_left.x, r.top_right.y)
31 ab.line_ad(r.bottom_left.x, r.bottom_left.y)
32
33 # Define the points to use (equivalent to the user picking points in the interactive tool)
34 point = impact.creator.vector(50, 50)
35
36 # Call Fill Area and get the entities that are created
37 entities = impact.gui.tools.fill_area([point], settings)
38
39 # now select each of the new entities
40 for entity in entities:
41 entity.selected = True
42