Uniting multiple shapes¶
Uniting multiple shapes¶
1# This example creates a sausage around every entity in the active block,
2# and amalgamates all these shapes together.
3
4ad = impact.active_drawing
5
6if not ad.isNone():
7
8 # Create the Shape impact.creator
9 ShapeCreator = impact.creator.shape_creator()
10
11 # Create a local variable for the entities in the active block
12 entities = ad.active_layer.active_block.entities
13 united_shape = None
14
15 for entity in entities:
16
17 # It would be easy here to check any properties of the entities, and
18 # for example process only lines, or only crease entities.
19 if entity.geometric:
20
21 # Set the properties and create a shape for this entity
22 ShapeCreator.entity = entity
23 ShapeCreator.sausage_distance = 5
24 ShapeCreator.sausage_end_mode = ipSausageEndMode.semRoundEnds
25 this_shape = ShapeCreator.perform(ipShapeCreationType.sctSausage)
26
27 # Reset the properties, ready for the next time
28 ShapeCreator.reset()
29
30 # Amalgamation (a simple unite)
31 if united_shape is None or (hasattr(united_shape, "isNone") and united_shape.isNone()):
32 united_shape = this_shape
33 else:
34 united_shape = united_shape.union(this_shape)
35
36 # Now create new entities from this shape. Note that the entities' palette
37 # will be what was the current palette when the Perform method was used, not the
38 # current palette now.
39 united_shape.copy_to_block(active_block)