Simple shape example (Python)¶
Simple shape example (Python)¶
1# Simple example of using an IShape object
2
3# Use the shape impact.creator to create a shape from all the
4# entities in the active block. Note that the entities
5# must form one or more closed shapes, otherwise they will be ignored.
6ShapeCreator = impact.creator.shape_creator()
7ShapeCreator.entities = impact.active_block.entities
8Shape = None
9try:
10 Shape = ShapeCreator.perform( ipShapeCreationType.sctEntities )
11except Exception as exc:
12 impact.gui.output_toolbox.add(f"Failed to create object via shape_creator.perform(): {exc}")
13
14# We ought to check that we haven't made an empty shape,
15# for example by having no entities.
16if Shape.sub_shape_count > 0:
17
18 # Make another shape by offsetting the first one
19 newShape = Shape.offset_bigger( 20, True )
20
21 # Now create entities from the shape, so that we can see it
22 newEntities = newShape.copy_to_block( impact.active_block )