1. | Allocate the two-dimensional section and define its name. |
2. | Add section entities (lines, arcs, splines, and so on) to define the section geometry, in section coordinates. |
3. | Add section dimensions that parametrically drive the shape of the entities. |
4. | Solve and regenerate the section. |
5. | Save the section. |
ProSection section;
ProName wname;
ProSection2DAlloc (§ion);
ProStringToWstring (wname, "demo");
ProSectionNameSet (section, wname);
|
|
|
|
|
Constraint Type
|
Description
|
---|---|
PRO_CONSTRAINT_SAME_POINT
|
Make the points coincident.
|
PRO_CONSTRAINT_HORIZONTAL_ENT
|
Make the entity horizontal.
|
PRO_CONSTRAINT_VERTICAL_ENT
|
Make the entity vertical.
|
PRO_CONSTRAINT_PNT_ON_ENT
|
Place the point on the entity.
|
PRO_CONSTRAINT_TANGENT_ENTS
|
Make the entities tangent.
|
PRO_CONSTRAINT_ORTHOG_ENTS
|
Make the entities perpendicular.
|
PRO_CONSTRAINT_EQUAL_RADII
|
Make the arcs or circles of equal radius.
|
PRO_CONSTRAINT_PARALLEL_ENTS
|
Make the entities parallel.
|
PRO_CONSTRAINT_EQUAL_SEGMENTS
|
Make the segments of equal length.
|
PRO_CONSTRAINT_COLLINEAR_LINES
|
Make lines co-linear.
|
PRO_CONSTRAINT_90_ARC
|
Make the arcs 90 degrees.
|
PRO_CONSTRAINT_180_ARC
|
Make the arcs 180 degrees.
|
PRO_CONSTRAINT_HORIZONTAL_ARC
|
Make the arcs horizontal.
|
PRO_CONSTRAINT_VERTICAL_ARC
|
Make the arcs vertical.
|
PRO_CONSTRAINT_SYMMETRY
|
Impose symmetry.
|
PRO_CONSTRAINT_SAME_COORD
|
Assume the endpoints and centers of arcs to have the same coordinates.
|
• | PRO_TK_CONSTRAINT_DENIED—The constraint is denied. This gives you more control over the section. |
• | PRO_TK_CONSTRAINT_ENABLED—The constraint is enabled. The Sketcher uses the predefined assumption. |
|
|
|
|
|
|
|
• | Solving—Calculating the way in which the geometry of the entities is driven by the dimensions. It is at this stage that Sketcher constraints are applied, under- or over-dimensioning is discovered and reported, and values are assigned to new dimensions. |
• | Regenerating—Reconstructing the geometry of the section to obey the current dimension values. |
• | Epsilon determines the smallest possible entity in a section. If an entity is smaller than epsilon, then the entity is considered to be a degenerate entity. Degenerate entity is an entity which cannot be solved. It causes solving and regenerating of the section to fail. For example, a circle with radius 0 or line with length 0 are considered as degenerate entities. |
• | There are many types of constraints, and epsilon has a different meaning for each type. For example, consider two points. For the constraint PRO_CONSTRAINT_SAME_POINT, epsilon is the minimum distance between the two points beyond which the points will be treated as separate points. If the distance between the two points is within the epsilon value, the two points are treated as coincident points. |
• | Creo Parametric has a default value set for epsilon. This value is also used in the Sketcher user interface. |
• | If the input geometry is accurate and the user does not want the solver to change it by adding constraints, then set the value of epsilon to 1E-9. |
• | If the input geometry is nearly accurate and the user wants the solver to guess the intent by adding constraints and further aligning the geometry, then in this case epsilon should reflect the maximal proximity between geometry to be constrained. |
• | You cannot set the value of epsilon to zero. |
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);
• | handle—The section handle. |
• | entity_id—The identifier of the section entity. |
• | pnt_type—Specifies the type of point selection on the entity. The valid values are:
|
• | pnt—Specifies the location of the point on the entity geometry. |
• | idx_pnt—Specifies the index of interpolation point relative to pnt_type, if the section entity is a spline. In this case the value of the argument pnt is ignored. Specify PRO_VALUE_UNUSED if the entity is not a spline. |
|
|
|
|
|
|
|
|
|
|
|
|
Constant
|
Description
|
---|---|
PRO_TK_DIM_LINE
|
Length of a line
|
PRO_TK_DIM_LINE_POINT
|
Distance between a line and a vertex
|
PRO_TK_DIM_RAD
|
Radius of an arc or a circle
|
PRO_TK_DIM_DIA
|
Diameter of an arc or a circle
|
PRO_TK_DIM_LINE_LINE
|
Distance between two lines
|
PRO_TK_DIM_PNT_PNT
|
Distance between two points
|
PRO_TK_DIM_PNT_PNT_HORIZ
|
Distance between two points (X coordinates)
|
PRO_TK_DIM_PNT_PNT_VERT
|
Distance between two points (Y coordinates)
|
PRO_TK_DIM_AOC_AOC_TAN_HORIZ
|
Horizontal distance between two arcs or circles
|
PRO_TK_DIM_AOC_AOC_TAN_VERT
|
Vertical distance between two arcs or circles
|
PRO_TK_DIM_ARC_ANGLE
|
Angle of an arc
|
PRO_TK_DIM_LINES_ANGLE
|
Angle between two lines
|
PRO_TK_DIM_LINE_AOC
|
Distance between a line and an arc or a circle
|
PRO_TK_DIM_LINE_CURVE_ANGLE
|
Angle between a spline and a line
|
PRO_TK_DIM_3_PNT_ANGLE
|
Angular dimension defined by three points
|
PRO_TK_DIM_DIA_LINEAR
|
Linear diameter dimension
|
PRO_TK_DIM_PNT_PNT_ORI
|
Distance between two points in specified orientation
|
PRO_TK_DIM_AOC_AOC_ORI
|
Distance between two arcs or circles in specified orientation
|
PRO_TK_DIM_TOT_INC_ANG
|
Total included angle
|
PRO_TK_DIM_ANG_POLAR
|
Angle between the x-axis and a vector. The vector is defined by two points
|
• | int entity_ids[]—An array of integers that are the identifiers of the section entities to which the dimension refers. |
• | ProSectionPointType point_types[]—A dimension can reference a vertex (the end of an entity), the center of an arc or a circle, a line or circle itself (the whole entity), or tangent points on an arc or a circle. To specify these types of dimension reference points, specify the appropriate point type constant for each dimension in the entity_ids array. These constants are listed in the include file ProSecdimType.h. |
• | int num_ids—The number of section dimension identifiers in the entity_ids array. This is typically 1 or 2 (line length versus a point-to-point dimension). |
• | ProSecdimType dim_type—The type of section dimension to create, as listed in the ProSecdimType.h file. |
• | Pro2dPnt place_pnt—The two-dimensional location of the dimension label. This is equivalent to the middle mouse button pick when you are using
Sketcher mode. Note that the position of this label can sometimes determine the exact role of the dimension. For example, a dimension of
type PRO_TK_DIM_LINES_ANGLE may refer to the acute or obtuse angle between two lines, depending on where the label is positioned.
|
int line_id[1], width_dim;
Pro2dPnt point;
ProSectionPointType pnt_type[1];
line_id[0] = 1;
point[0] = 5.0;
point[1] = 1.0;
pnt_type[0] = PRO_ENT_WHOLE;
ProSecdimCreate (section, line_id, pnt_type, 1,
PRO_TK_DIM_LINE, point,
&width_dim);
int arc1_id, arc2_id, arc1_end2, arc2_end1,
dist_dim;
Pro2dPnt point;
int entities[2];
ProSectionPointType pnt_types[2];
pnt_types[0] = PRO_ENT_START;
pnt_types[1] = PRO_ENT_END;
entity[0] = arc1_end2;
entity[1] = arc2_end1;
point[0] = 5.0;
point[1] = 5.0;
ProSecdimCreate (section, entities, pnt_types, 2,
PRO_TK_DIM_PNT_PNT_HORIZ, point, &dist_dim);
|
|
|
|
|
|
ProWSecerror errors;
int n_errors, e;
ProError status;
ProMsg wmsg;
char msg[PRO_PATH_SIZE];
int ent_id;
ProSecerrorAlloc (&errors);
status = ProSectionSolve (section, &errors);
if (status != PRO_TK_NO_ERROR)
{
ProSecerrorCount (&errors, &n_errors);
for (e = 0; e < n_errors; e++)
{
ProSecerrorMsgGet (errors, e, wmsg);
ProWstringToString (msg, wmsg);
ProSecerrorItemGet (errors, e, &ent_id);
printf ("%s: Problem ID, %d\n", msg, ent_id);
}
ProSecerrorFree (&errors);
return (-1);
}