Using the hole finder¶
Using the hole finder¶
1# This example creates a rectangle in the active block and uses
2# ITools.hole_finder() to create geometry offsetting inside from the rectangle
3
4# Check there is an active drawing
5ad = impact.active_drawing
6if ad.isNone():
7 impact.gui.output_toolbox.add("Unable to continue: no active drawing")
8else:
9
10 # the name (including path) of the hole-finder master tool settings to use
11 settings_name = "Matrix|Matrix Vacuum Hole"
12
13 # Check that the settings exist
14 settings = impact.active_database.find_master_tool_setting(settings_name, ipMasterSettingType.mstHoleFinder)
15 if settings.isNone():
16 impact.gui.output_toolbox.add("Unable to continue: can't locate hole finder settings '" + str(settings_name) + "'")
17 else:
18 ab = ad.active_layer.active_block
19
20 # define the extents of the rectangle
21 r = impact.creator.rect(0, 0, 0, 0)
22 r.bottom_left.x = 0
23 r.bottom_left.y = 0
24 r.top_right.x = 100
25 r.top_right.y = 100
26
27 # delete all visible entities in the active block
28 ab.select_all()
29 ab.delete_selected()
30
31 # draw a rectangle
32 ab.move_ad(r.bottom_left.x, r.bottom_left.y)
33 ab.line_ad(r.top_right.x, r.bottom_left.y)
34 ab.line_ad(r.top_right.x, r.top_right.y)
35 ab.line_ad(r.bottom_left.x, r.top_right.y)
36 ab.line_ad(r.bottom_left.x, r.bottom_left.y)
37
38 # set up the array of points to use (equivalent to the user picking points in the interactive tool)
39 points = [None] * 2
40 points[0] = impact.creator.vector(50, 50)
41
42 # check for holes
43 result = impact.gui.tools.hole_finder2(points, False, settings)
44 impact.gui.output_toolbox.add("Hole found: " + str(result))
45
46
47
48
49
50
51
52
53
54
55
56