Core: Parameters
This section describes the Creo TOOLKIT functions that give access to parameters and geometric tolerances.
Parameter Objects
The object ProParameter describes the contents and ownership of a parameter. ProParameter is a DHandle whose declaration is as follows:
typedef struct proparameter
{
  ProType       type;
  ProName       id;
  ProParamowner owner;
} ProParameter;
  typedef struct proparamowner
  {
    ProParamfrom   type;
    union
    {
      ProModelitem item;
      ProMdl     model;
    } who;
  } ProParamowner;
    typedef enum proparamfrom
    {
      PRM_MODEL,
      PRM_ITEM
    } ProParamfrom;
A structure called ProParamvalue is used to represent the value of a parameter. Its declaration is as follows:
typedef struct Pro_Param_Value
{
  ProParamvalueType     type;
  ProParamvalueValue    value;
} ProParamvalue;
  typedef enum param_value_types
  {
    PRO_PARAM_DOUBLE,
    PRO_PARAM_STRING,
    PRO_PARAM_INTEGER,
    PRO_PARAM_BOOLEAN,
    PRO_PARAM_NOTE_ID,
    PRO_PARAM_VOID
  } ProParamvalueType;
  typedef union param_value_values
  {
    double    d_val;
    int       i_val;
    short     l_val;
    ProLine   s_val;
  } ProParamvalueValue;
Parameter Values
Functions introduced:
These three functions are utilities to help you manipulate the ProParamvalue structure. They do not directly affect any parameter in Creo Parametric.
The function ProParamvalueSet() sets the value type of a ProParamvalue structure, and writes a value of that type to the object.
The function ProParamvalueTypeGet() provides the type of a ProParamvalue object.
The function ProParamvalueValueGet() reads a value of the specified type from a ProParamvalue structure.
The function ProParameterIsListValue() provides the information if the parameter value type is a list or not. The output argument is_list is a ProBoolean and returns PRO_B_TRUE, if the specified parameter value type is a list, if not it returns PRO_B_FALSE.
Use the function ProParameterListValueGet() to get the list values and units for the specified parameter handle. The function returns the following output arguments:
•  provalProArray of ProParamvalue. The values are assumed to be in the units specified by the units argument (when the units argument is not NULL) or in the units of the owner model, when argument units is NULL.
•  units—The units in which the values are expressed. Pass NULL if units is not required. If none found, an empty string will be returned.
Use the function ProParameterListValueSet() to set the list values for the specified ProParameter handle with the given units. The input arguments are as follows:
•  param—Specify the handle to the parameter.
•  proval—Specify the ProArray of ProParamvalue. The values are assumed to be in the units specified by the units argument (when the units argument is not NULL) or in the units of the owner model, when argument units is NULL.
•  units—Specify the new units. The units must be the same quantity type as the units of the parameter (i.e. if the units are "inch", a value can be expressed in "cm"). Can be NULL. If you pass NULL, the function will assume the units of the owner model.
Use the function ProParameterListTypeSet() to set the value type as list for the specified parameter.
Use the function ProParameterEnumeratedSet() to set a parameter as enumerated(parameter restricted by a list of values) and to provide a list of allowed values. The input arguments are:
•  param—Handle to the parameter.
•  valid_values—Specify the valid values that should be assigned to this parameter. Cannot be NULL.
•  p_default—The default (current) value for the parameter.
Use the function ProParameterRangeSet() to identify the value to be restricted to a certain range for the specified parameter. The input arguments are as follows:
•  param—Handle to the parameter.
•  minimum —The minimum value for this parameter that is specified using the object ProParamLimit.
•  maximum —The maximum value for this parameter that is specified using the object ProParamLimit.
•  p_default—The default (current) value for the parameter.
Accessing Parameters
Functions introduced:
The function ProParameterInit() initializes a ProParameter object by defining its name and owner. The owner is expressed in terms of a ProModelitem object, and can be a Creo Parametric model, feature, surface, or edge.
If the owner is a model, use ProMdlToModelitem() to create the ProModelitem object; in other cases, use ProModelitemInit().
The function ProParameterValueWithUnitsGet() reads the value of a parameter specified by a ProParameter object into a ProParamvalue object provided by the application. The function also retrieves the units in which the parameter value was expressed. The output arguments of this function are as follows:
•  proval—The value held in the ProParameter object and is assumed to be in the specified units. Pass this as NULL to get the value in owner model units.
•  units—The units in which the value is expressed. Pass this as NULL if unit is not required. If the value is not found, an empty string is returned.
The function ProParameterValueWithUnitsSet() sets the value of a Creo Parametric parameter identified by a ProParameter object to a value specified in a ProParamvalue structure. The parameter is expressed using the value specified for the input parameter units.
Note
If the input argument units is passed as NULL, then the parameter will have the same units as that of the owner model.
The ProParameterIsModified() function returns a boolean value that indicates whether the value of the specified parameter has been modified since the last successful regeneration of the parameter owner. This function works successfully for solid models only.
The function ProParameterValueReset() sets the value of a parameter to the one it had at the end of the last regeneration.
The function ProParameterDelete() deletes a parameter, specified by a ProParameter object, from the Creo Parametric database.
The function ProParameterSelect() allows the user to select one or more parameters of a specified model or database item from the Parameters dialog box in Creo Parametric . The top model from which the parameters will be selected must be displayed in the current window. The input argument context allows you to select parameters by context. It takes the following values:
•  PRO_PARAMSELECT_ANY—Specifies any parameter.
•  PRO_PARAMSELECT_MODEL—Specifies the parameters of the top-level model.
•  PRO_PARAMSELECT_PART—Specifies the parameters of any part.
•  PRO_PARAMSELECT_ASM—Specifies the parameters of any assembly.
•  PRO_PARAMSELECT_FEATURE—Specifies the parameters of any feature.
•  PRO_PARAMSELECT_EDGE—Specifies the parameters of any edge.
•  PRO_PARAMSELECT_SURFACE—Specifies the parameters of any surface.
•  PRO_PARAMSELECT_QUILT—Specifies the parameters of any quilt.
•  PRO_PARAMSELECT_CURVE—Specifies the parameters of any curve.
•  PRO_PARAMSELECT_COMPOSITE_CURVE—Specifies the parameters of any composite curve.
•  PRO_PARAMSELECT_INHERITED—Specifies the parameters of any inheritance feature.
•  PRO_PARAMSELECT_SKELETON—Specifies the parameters of any skeleton.
•  PRO_PARAMSELECT_COMPONENT—Specifies the parameters of any component.
•  PRO_PARAMSELECT_ALLOW_SUBITEM_SELECTION—Specifies the parameters of all the subitems of the top model.
Note
The signature of ProParameterSelect() has changed from Pro/ENGINEER Wildfire 2.0 onward.
The function ProParameterTableExport() exports a file containing information from a parameter table in Creo Parametric in the CSV or TXT format. If the output type is CSV, the output file contains the columns specified by the input argument column_list, which is a bitmask of columns. In the CSV format, only the local parameters are exported. However, if the output type is TXT, then a default set of columns is exported. In the TXT format, all the parameters in the specified model are exported.
The function ProParameterVisit() visits all the parameters on a specified database item.
Note
•  The parameters are returned in the order that they appear in the parameter dialog box for the database item.
•  ProParameterVisit() does not visit mass property parameters.
The function ProParameterReorder() reorders the given parameter to come just after the indicated parameter.
The function ProParameterToFamtableItem() converts ProParameter objects to ProFamtableItem objects. You may need to call ProParameterToFamtableItem() after calling ProParameterSelect() that allows you to select parameters from a menu.
The function ProParameterUnitsGet() fetches the units assigned to a parameter.
The function ProParameterUnitsAssign() assigns the specified unit to a parameter. If the parameter already has a unit assigned to it, the function will reassign the specified unit to it. The function can reassign unit only from the same quantity type. To convert a parameter with unit to a unitless parameter, pass the input argument units as NULL.
The function ProParameterWithUnitsCreate() enables the creation of a new parameter with the assigned units. To create a parameter without units, pass the input argument units as NULL.
The function ProParameterScaledvalueGet() retrieves the parameter value in terms of the units of the parameter, instead of the units of the owner model.
The function ProParameterScaledvalueSet() sets the parameter value in terms of the units provided, instead of using the units of the owner model.
The function ProParameterDescriptionGet() obtains the description of the parameter. The function ProParameterDescriptionSet() assigns the description of the parameter.
The function ProParameterLockstatusGet() returns the access state of the specified parameter. Use the function ProParameterLockstatusSet() to set the access state for the specified parameter. The access state is defined in the enumerated data type ProLockstatus. The valid values are:
•  PRO_PARAMLOCKSTATUS_UNLOCKED—Parameters with full access are user-defined parameters, that can be modified from any application.
•  PRO_PARAMLOCKSTATUS_LIMITED—Full access parameters can be set to have limited access. Limited access parameters can be modified by user, family tables and programs. These parameters cannot be modified by relations.
•  PRO_PARAMLOCKSTATUS_LOCKED—Parameters with locked access are parameters that can be locked either by an external application, or by the user. If you have set the access state for a parameter using the function ProParameterLockstatusSet() and need to modify the parameter, you can change the access state from locked status to full access and then edit the parameter value. This can be done from an external application or an open Creo session.
The function ProParameterIsInactive() determines if the specified parameter is inactive.
Note
The function supports symbol instance and surface finish annotation element parameters only.
If the parameter is inactive due to current customization of symbol, the function outputs a ProBoolean with the value PRO_B_TRUE. Otherwise the function returns PRO_B_FALSE.
Notification Functions
The parameter notification functions support the parameters owned by an annotation element. These functions are call back functions and are accessible by calling the function ProNotificationSet().
The notification function ProParameterCreateWithUnitsPreAction() is called before the parameter is created in the Creo Parametric user interface. This function is available by calling ProNotificationSet() with the value of the notify type as PRO_PARAM_CREATE_W_UNITS_PRE. You can specify the units for the parameter.
The notification function ProParameterDeletePreAction() is called before the parameter is deleted. This function is available by calling ProNotificationSet() with the value of the notify type as PRO_PARAM_DELETE_PRE.
The notification function ProParameterModifyWithUnitsPreAction() is called before a parameter is modified in the Creo Parametric user interface. This function is available by calling ProNotificationSet() with the value of the notify type as PRO_PARAM_MODIFY_W_UNITS_PRE. The function returns the old and new units of the parameter along with the values.
You can use the PreAction functions to cancel any changes made to the parameters. If any value except PRO_TK_NO_ERROR is returned, then the change is not permitted. The application must provide appropriate messaging to the user to explain the reason for which the change was rejected.
Note
You are not permitted to cancel the parameter modification events when modifying multiple parameters as a group.
The notification function ProParameterCreatePostAction() is called after a parameter has been created. This function is available by calling ProNotificationSet() with the value of the notify type as PRO_PARAM_CREATE_POST.
The notification function ProParameterModifyWithUnitsPostAction() is called after a parameter has been modified in the Creo Parametric user interface. This function is available by calling ProNotificationSet() with the value of the notify type as PRO_PARAM_MODIFY_W_UNITS_POST. The function returns the old and modified units of the parameter along with the values.
The notification function ProParameterDeleteWithUnitsPostAction() is called after a parameter has been deleted in the Creo Parametric user interface. This function is available by calling ProNotificationSet() with the value of the notify type as PRO_PARAM_DELETE_W_UNITS_POST.
Example 1: Labeling a Feature with a String Parameter
The sample code in UgParamFeatLabel.c located at <creo_toolkit_loadpoint>/protk_appls/pt_userguide/ptu_param shows how to label the selected feature with the specified string parameter. The program calls ProParameterInit() to find out whether the parameter already exists.
Designating Parameters Windchill Servers
Functions introduced:
These functions control the designation of parameters for Windchill servers. A designated parameter will become visible within these management systems as an attribute on the owning model when it is next submitted.
The function ProParameterDesignationAdd() designates an existing parameter, referred to by its ProParameter object.
The function ProParameterDesignationRemove() removes the designation.
Note
PTC does not recommend undesignating or deleting a parameter that is already exposed to a Product Data Management system, such as Windchill PDMLink or Pro/INTRALINK.
The function ProParameterDesignationVerify() tells you whether a specified model parameter is currently designated or not.
Restricted Parameters
Restricted parameters can have either:
•  an enumeration which limits values only to those specified in advance; or
•  a range which limits numerical values to fall within that range.
Functions introduced:
Use the function ProParameterIsEnumerated() to identify if a parameter is enumerated, and provides the values that may be assigned to it. If the parameter is enumerated then it gives the ProArray of values that are assigned to this parameter.
Use the function ProParameterRangeGet() to identify if a parameter's value is restricted to a certain range. If the parameter is restricted by a range then it gives the maximum and minimum value of the parameter.
Table-Restricted Parameters
A parameter table is made up of one or more parameter table sets. Each set represents one or more parameters with their assigned values or assigned ranges. A given parameter owner (model, feature, annotation element, geometry item) can only have one parameter table set applied that creates a given parameter. In Creo TOOLKIT , a parameter table set is represented by the type ProParamtableSet and is made up of entries, represented by ProParamtableEntry. A single entry represents a parameter with an assigned value or range.
Functions introduced:
Use the function ProParameterTablesetGet() to obtain the governing parameter table set for this parameter, if it's a member of a set.
Use the function ProMdlParamtablesetsCollect() to obtain an array of all the table sets that are available for use in the given model. This includes all sets that are loaded from table files that are set up in this session, and any other sets that were previously stored in the model.
Use the function ProParamtablesetFree() to free the parameter table set and the function ProParamtablesetProarrayFree() to free an array of parameter table sets.
Use the function ProParamtablesetEntriesGet() to obtain the entries that are contained in a parameter table set.
Use the function ProParamtablesetTablepathGet() to obtain the name of the table that owns this parameter table set. If the set is loaded from a certain table file, this is the full path. If the set has been stored in the model directly, this is the table name.
Use the function ProParamtablesetLabelGet() to obtain the set label for a given parameter table set.
Use the function ProParamtableentryNameGet() to obtain the name for the parameter in this table set.
Use the function ProParamtableentryValueGet() to obtain the value for the parameter in this table set. If the parameter also has a range applied, this is the default value for the parameter. Use the function ProParamtableentryRangeGet() to obtain the permitted range for the parameter in this table set. The output arguments for this function are:
•  minimum—The minimum value for this parameter as set by the parameter set.
•  maximum—The maximum value for this parameter as set by the parameter set
You can use the function ProParamtableentryProarrayFree() to free an array of table entries.
The function ProParamtablesetApply() assigns this parameter set to the given parameter owner. Parameters used by the set are created or modified, as appropriate. The parameter values are set to the default values. This function does not regenerate the model and may fail if the parameter owner already has one or more of the set's required parameters defined which are not driven by this table.
The function ProRelsetConstraintsGet() obtains the constraints applied to a given relation set. Constraints may be assigned when one or more parameters of the set is governed by an external parameter file.
Driven Parameters
The functions described below provide access to the item (parameter or function) driving model parameters.
Functions Introduced:
The function ProParameterDrivertypeGet() retrieves the type of operation that is driving a model parameter in the form of ProParameterDriver object. In assemblies, you can refer to a parameter that belongs to another model. The function ProParameterDrivertypeGet() returns information for such parameters, which are referenced in the current model but belong to another model. The types of drivers are as follows:
•  PRO_PARAMDRIVER_PARAM—Specifies the parameter driving the model parameter.
•  PRO_PARAMDRIVER_FUNCTION—Specifies the function driving the model parameter.
•  PRO_PARAMDRIVER_RELATION—Specifies the relation driving the model parameter.
The function ProParameterDrivingsymbolGet() retrieves the driving parameter for a model parameter, if the driver type is PRO_PARAMDRIVER_PARAM. The function ProParameterDrivingsymbolGet() also returns information for parameters, which are referenced in the current model but belong to another model.
The function ProParameterDrivingparamSet() sets the driver type for a material parameter to the value PRO_PARAMDRIVER_PARAM.
The function ProParameterDrivingFunctionGet() obtains the driving function for a material parameter, if the driver type is PRO_PARAMDRIVER_FUNCTION.
The function ProParameterDrivingFunctionSet() sets the driver type for a material parameter to the value PRO_PARAMDRIVER_FUNCTION.