Example use of path-finder object¶
Example use of path-finder object¶
1# This example shows how to use the PathFinder and Path Options functionality.
2# To use, draw any geometric path with at least four lines/arcs (a rectangle will do).
3
4if impact.active_drawing.isNone():
5 impact.gui.output_toolbox.add("Unable to continue: no active drawing")
6else:
7
8 # Get a hold of the PathFinder Object and create some PathOptions
9 PathFinder = impact.creator.path_finder()
10 PathOptions = PathFinder.create_hole_path_options()
11
12 # This allows the Path Options to match an existing master tool setting
13 db = impact.active_database
14 ms = db.find_master_tool_setting("<<Default>>", ipMasterSettingType.mstHoleFinder)
15 if not ms.isNone():
16 PathOptions.apply_master_setting(ms)
17
18 # You can then adjust the settings as well
19 PathOptions.leave_original = True
20 PathOptions.original_sub_block = True
21 PathOptions.original_block_name = "OriginalBlock"
22 PathOptions.original_use_palette = True
23 PathOptions.original_palette = "Cut"
24 PathOptions.original_leave_selected = True
25 PathOptions.original_merge_entities = False
26
27 PathOptions.do_left_out_offset = True
28 PathOptions.left_out_sub_block = True
29 PathOptions.left_out_block_name = "LeftOutBlock"
30 PathOptions.left_out_use_palette = True
31 PathOptions.left_out_palette = "Cut"
32 PathOptions.left_out_offset_dist = 5.0
33 PathOptions.left_out_number = 2
34 PathOptions.left_out_sharp_corners = False
35 PathOptions.left_out_leave_selected = False
36 PathOptions.left_out_initial_offset_dist = 1.0
37 PathOptions.left_out_use_initial_offset = True
38 PathOptions.left_out_offset_deadends = 4.0
39 PathOptions.left_out_merge_entities = False
40
41 PathOptions.do_right_in_offset = True
42 PathOptions.right_in_sub_block = True
43 PathOptions.right_in_block_name = "RightInBlock"
44 PathOptions.right_in_use_palette = True
45 PathOptions.right_in_palette = "Cut"
46 PathOptions.right_in_offset_dist = 2.0
47 PathOptions.right_in_number = 1
48 PathOptions.right_in_auto_fill = True
49 PathOptions.right_in_sharp_corners = False
50 PathOptions.right_in_leave_selected = True
51 PathOptions.right_in_initial_offset_dist = 1.0
52 PathOptions.right_in_use_initial_offset = False
53 PathOptions.right_in_offset_deadends = 4.0
54 PathOptions.right_in_merge_entities = True
55
56 PathOptions.do_interiors = True
57 PathOptions.do_interior_holes = False
58 PathOptions.leave_interior_original_hole = True
59 PathOptions.offset_interior_holes_inside = False
60 PathOptions.offset_dist_interior_holes_inside = 2.0
61 PathOptions.offset_interior_holes_outside = True
62 PathOptions.offset_dist_interior_holes_outside = 3.0
63 PathOptions.do_interior_paths = True
64 PathOptions.leave_interior_original_paths = True
65 PathOptions.pocket_interior_paths = True
66 PathOptions.pocket_dist_interior_paths = 2.0
67 PathOptions.interior_into_blocks = True
68 PathOptions.interior_block_name = "InteriorBlockName"
69 PathOptions.interior_use_palette = False
70 PathOptions.interior_palette = "Cut"
71 PathOptions.interior_merge_entities = True
72 PathOptions.interior_sharp_corners = False
73
74 PathFinder.hole_path_options = PathOptions
75
76 # Set the rest of the PathFinder parameters
77 # (We need at least 4 entities for this example, all geometric)
78 ab = impact.active_drawing.active_layer.active_block
79 if ab.entities.count < 4:
80 impact.gui.output_toolbox.add("Fewer than four entities")
81 else:
82 start_entity = ab.entities.item(1)
83 end_entity = ab.entities.item(4)
84 position = start_entity.get_along(1.0)
85
86 PathFinder.start_entity = start_entity
87 PathFinder.end_entity = end_entity
88 PathFinder.position = position
89 PathFinder.replicate = True
90 PathFinder.left_on_junction = True
91 PathFinder.continue_past_deadends = True
92
93 # Perform the PathFinder operation
94 result = PathFinder.perform()
95
96 impact.gui.output_toolbox.add("PathFinder result=" + str(result))
97
98