Adding Section Entities
Functions Introduced:
The function
ProSectionEntityAdd() takes as input the
ProSection that identifies the section, and a pointer to a user-visible structure called
Pro2dEntdef, which defines the entity.
The
Pro2dEntdef structure is a generic structure that contains only a field indicating the type of entity. For each type of entity, there is a dedicated structure that has the entity type as its first field; these structures are named
Pro2dLinedef,
Pro2dArcdef, and so on. The
Creo TOOLKIT application builds up the structure appropriate to the entity to be added, and inputs it to
ProSectionEntityAdd() by casting its address to (
Pro2dEntdef*). The entity structures are declared in the include file
Pro2dEntdef.h.
The function
ProSectionEntityAdd() outputs an integer that is the identifier of the new entity within the section. The
Creo TOOLKIT application needs these values because they are used to refer to entities when adding dimensions.
The following code fragment demonstrates how to add a single line entity.
Pro2dLinedef line;
int line_id;
line.type = PRO_2D_LINE;
line.end1[0] = 0.0;
line.end1[1] = 0.0;
line.end2[0] = 10.0;
line.end2[1] = 0.0;
ProSectionEntityAdd (section,
(Pro2dEntdef*)&line, &line_id);
The function
ProSectionEntityDelete() enables you to delete a section entity from the specified section.
The function
ProSectionEntityReplace() enables you to replace an existing entity from the specified section with another entity in the same section. This functionality enables you to redefine an existing section programmatically.
To use the function
ProSectionEntityReplace(), you must first add the new entity to the section (to get its identifier), then replace the old entity identifier with the new one.