Entity clipping and masking using shapes¶
Entity clipping and masking using shapes¶
1# The script demonstrates how to clip or mask entities against a shape.
2# In this case the shape is a circle, with a circular hole. Two horizontal
3# lines are created that cross the shape, then one is clipped and the other
4# is masked. No other entities in the drawing are affected.
5
6
7if impact.active_drawing.isNone():
8 impact.gui.output_toolbox.add("Unable to continue: no active drawing")
9else:
10 ab = impact.active_drawing.active_layer.active_block
11
12 circ1 = ab.circle_ad(20, 20, 15, 0, True)
13 circ2 = ab.circle_ad(20, 20, 8, 0, True)
14
15 # We need to put these entity objects into a collection
16 masking_entities_collection = impact.creator.entities([ circ1, circ2 ])
17
18 # Create a shape using these entities
19 ShapeCreator = impact.creator.shape_creator()
20 ShapeCreator.entities = masking_entities_collection
21 the_shape = ShapeCreator.perform(ipShapeCreationType.sctEntities)
22
23 # Draw some geometry which will intersect with the shape
24 ab.move_ad(0, 18)
25 line1 = ab.line_ad(50, 18)
26 ab.move_ad(0, 22)
27 line2 = ab.line_ad(50, 22)
28
29 # Now modify the entities by clipping or masking them against the shape
30 the_shape.clip_entity(line1)
31 the_shape.mask_entity(line2)
32