Dimensions and Parameters
This section describes the VB API methods and classes that affect dimensions and parameters.
Overview
Dimensions and parameters in Creo Parametric have similar characteristics but also have significant differences. In the VB API, the similarities between dimensions and parameters are contained in the IpfcBaseParameter class. This class allows access to the parameter or dimension value and to information regarding a parameter's designation and modification. The differences between parameters and dimensions are recognizable because IpfcDimension inherits from the class IpfcModelItem, and can be assigned tolerances, whereas parameters are not IpfcModelItems and cannot have tolerances.
The ParamValue Object
Both parameters and dimension objects contain an object of type IpfcParamValue. This object contains the integer, real, string, or Boolean value of the parameter or dimension. Because of the different possible value types that can be associated with a IpfcParamValue object there are different methods used to access each value type and some methods will not be applicable for some IpfcParamValue objects. If you try to use an incorrect method an exception will be thrown.
Accessing a ParamValue Object
Methods and Property Introduced:
  • CMpfcModelItem.CreateIntParamValue()
  • CMpfcModelItem.CreateDoubleParamValue()
  • CMpfcModelItem.CreateStringParamValue()
  • CMpfcModelItem.CreateBoolParamValue()
  • CMpfcModelItem.CreateNoteParamValue()
  • IpfcBaseParameter.Value
  • The CMpfcModelItem utility class contains methods for creating each type of IpfcParamValue object. Once you have established the value type in the object, you can change it. The property IpfcBaseParameter.Value returns the IpfcParamValue associated with a particular parameter or dimension.
    A NoteParamValue is an integer value that refers to the ID of a specified note. To create a parameter of this type the identified note must already exist in the model.
    Accessing the ParamValue Value
    Properties Introduced:
  • IpfcParamValue.discr
  • IpfcParamValue.IntValue
  • IpfcParamValue.DoubleValue
  • IpfcParamValue.StringValue
  • IpfcParamValue.BoolValue
  • IpfcParamValue.NoteId
  • The property IpfcParamValue.discr returns a enumeration object that identifies the type of value contained in the IpfcParamValue object. Use this information with the specified properties to access the value. If you use an incorrect property an exception of type IpfcXBadGetParamValue will be thrown.
    Parameter Objects
    The following sections describe the VB API methods that access parameters. The topics are as follows:
    Creating and Accessing Parameters
    Methods and Property Introduced:
  • IpfcParameterOwner.CreateParam()
  • IpfcParameterOwner.CreateParamWithUnits()
  • IpfcParameterOwner.GetParam()
  • IpfcParameterOwner.ListParams()
  • IpfcParameterOwner.SelectParam()
  • IpfcParameterOwner.SelectParameters()
  • IpfcFamColParam.RefParam
  • In the VB API, models, features, surfaces, and edges inherit from the IpfcParameterOwner class, because each of the objects can be assigned parameters in Creo Parametric.
    The method IpfcParameterOwner.GetParam() gets a parameter given its name.
    The method IpfcParameterOwner.ListParams() returns a sequence of all parameters assigned to the object.
    To create a new parameter with a name and a specific value, call the method IpfcParameterOwner.CreateParam().
    To create a new parameter with a name, a specific value, and units, call the method IpfcParameterOwner.CreateParamWithUnits().
    The method IpfcParameterOwner.SelectParam() allows you to select a parameter from the Creo Parametric user interface. The top model from which the parameters are selected must be displayed in the current window.
    The method IpfcParameterOwner.SelectParameters() allows you to interactively select parameters from the Creo Parametric Parameter dialog box based on the parameter selection options specified by the IpfcParameterSelectionOptions object. The top model from which the parameters are selected must be displayed in the current window. Refer to the section Parameter Selection Options for more information.
    The property IpfcFamColParam.RefParam returns the reference parameter from the parameter column in a family table.
    Parameter Selection Options
    Parameter selection options in the VB API are represented by the IpfcParameterSelectionOptions class.
    Methods and Properties Introduced:
  • CCpfcParameterSelectionOptions.Create
  • IpfcParameterSelectionOptions.AllowContextSelection
  • IpfcParameterSelectionOptions.Contexts
  • .IpfcParameterSelectionOptions.AllowMultipleSelections
  • IpfcParameterSelectionOptionsSelectButtonLabel
  • The method CCpfcParameterSelectionOptions.Create creates a new instance of the IpfcParameterSelectionOptions object that is used by the method IpfcParameterOwner.SelectParameters().
    The parameter selection options are as follows:
    •  AllowContextSelection—This boolean attribute indicates whether to allow parameter selection from multiple contexts, or from the invoking parameter owner. By default, it is false and allows selection only from the invoking parameter owner. If it is true and if specific selection contexts are not yet assigned, then you can select the parameters from any context.
    Use the property IpfcParameterSelectionOptions.AllowContextSelection to modify the value of this attribute.
    •  Contexts—The permitted parameter selection contexts in the form of the IIpfcParameterSelectionContexts object. Use the property IpfcParameterSelectionOptions.Contexts to assign the parameter selection context. By default, you can select parameters from any context.
    •  The types of parameter selection contexts are as follows:
      EpfcPARAMSELECT_MODEL—Specifies that the top level model parameters can be selected.
      EpfcPARAMSELECT_PART—Specifies that any part’s parameters (at any level of the top model) can be selected.
      EpfcPARAMSELECT_ASM—Specifies that any assembly’s parameters (at any level of the top model) can be selected.
      EpfcPARAMSELECT_FEATURE—Specifies that any feature’s parameters can be selected.
      EpfcPARAMSELECT_EDGE—Specifies that any edge’s parameters can be selected.
      EpfcPARAMSELECT_SURFACE—Specifies that any surface’s parameters can be selected.
      EpfcPARAMSELECT_QUILT—Specifies that any quilt’s parameters can be selected.
      EpfcPARAMSELECT_CURVE—Specifies that any curve’s parameters can be selected.
      EpfcPARAMSELECT_COMPOSITE_CURVE—Specifies that any composite curve’s parameters can be selected.
      EpfcPARAMSELECT_INHERITED—Specifies that any inheritance feature’s parameters can be selected.
      EpfcPARAMSELECT_SKELETON—Specifies that any skeleton’s parameters can be selected.
      EpfcPARAMSELECT_COMPONENT—Specifies that any component’s parameters can be selected.
    •  AllowMultipleSelections—This boolean attribute indicates whether or not to allow multiple parameters to be selected from the dialog box, or only a single parameter. By default, it is true and allows selection of multiple parameters.
    Use the property IpfcParameterSelectionOptions.AllowMultipleSelections to modify this attribute.
    •  SelectButtonLabel—The visible label for the select button in the dialog box.
    Use the property IpfcParameterSelectionOptionsSelectButtonLabel to set the label. If not set, the default label in the language of the active Creo Parametric session is displayed.
    Parameter Information
    Methods and Properties Introduced:
  • IpfcBaseParameter.Value
  • IpfcParameter.GetScaledValue()
  • IpfcParameter.SetScaledValue()
  • IpfcParameter.Units()
  • IpfcBaseParameter.IsDesignated
  • IpfcBaseParameter.IsModified
  • IpfcBaseParameter.ResetFromBackup()
  • IpfcParameter.Description
  • IpfcParameter.GetRestriction()
  • IpfcParameter.GetDriverType()
  • IpfcParameter.Reorder()
  • IpfcParameter.Delete()
  • IpfcNamedModelItem.Name
  • Parameters inherit methods from the IpfcBaseParameter, IpfcParameter and IpfcNamedModelItem classes.
    The property IpfcBaseParameter.Value returns the value of the parameter or dimension.
    The method IpfcParameter.GetScaledValue() returns the parameter value in the units of the parameter, instead of the units of the owner model as returned by IpfcBaseParameter.Value.
    The method IpfcParameter.SetScaledValue() assigns the parameter value in the units provided, instead of using the units of the owner model as assumed by IpfcBaseParameter.Value.
    The method IpfcParameter.Units() returns the units assigned to the parameter.
    You can access the designation status of the parameter using theproperty IpfcBaseParameter.IsDesignated .
    The property IpfcBaseParameter.IsModified and the method pfcBaseParameter.ResetFromBackup() enable you to identify a modified parameter or dimension, and reset it to the last stored value. A parameter is said to be "modified" when the value has been changed but the parameter's owner has not yet been regenerated.
    The property IpfcParameter.Description returns the parameter description, or null, if no description is assigned.
    The property IpfcParameter.GetRestriction() identifies if the parameter’s value is restricted to a certain range or enumeration. It returns the IpfcParameterRestriction object. Refer to the section Parameter Restrictions for more information.
    The property IpfcParameter.GetDriverType() returns the driver type for a material parameter. The driver types are as follows:
    •  EpfcPARAMDRIVER_PARAM—Specifies that the parameter value is driven by another parameter.
    •  EpfcPARAMDRIVER_FUNCTION—Specifies that the parameter value is driven by a function.
    •  EpfcPARAMDRIVER_RELATION—Specifies that the parameter value is driven by a relation. This is equivalent to the value obtained using IpfcBaseParameter.IsRelationDriven for a parameter object type.
    The method IpfcParameter.Reorder() reorders the given parameter to come immediately after the indicated parameter in the Parameter dialog box and information files generated by Creo Parametric.
    The method IpfcParameter.Delete( permanently removes a specified parameter.
    The property IpfcNamedModelItem.Name accesses the name of the specified parameter.
    Parameter Restrictions
    Creo Parametric allows users to assign specified limitations to the value allowed for a given parameter (wherever the parameter appears in the model). You can only read the details of the permitted restrictions from the VB API, but not modify the permitted values or range of values. Parameter restrictions in the VB API are represented by the classIpfcParameterRestriction.
    Method Introduced:
  • IpfcParameterRestriction.Type
  • The method IpfcParameterRestriction.Type returns the IpfcRestrictionType object containing the types of parameter restrictions. The parameter restrictions are of the following types:
    •  EpfcPARAMSELECT_ENUMERATION—Specifies that the parameter is restricted to a list of permitted values.
    •  EpfcPARAMSELECT_RANGE—Specifies that the parameter is limited to a specified range of numeric values.
    Enumeration Restriction
    The EpfcPARAMSELECT_ENUMERATION type of parameter restriction is represented by the interface IpfcParameterEnumeration. It is a child of the IpfcParameterRestriction interface.
    Property Introduced:
  • ParameterEnumeration.PermittedValues
  • The property ParameterEnumeration.PermittedValues returns a list of permitted parameter values allowed by this restriction in the form of a sequence of the IpfcParamValue objects.
    Range Restriction
    The EpfcPARAMSELECT_RANGE type of parameter restriction is represented by the interface IpfcParameterRange. It is a child of the IpfcParameterRestriction interface.
    Properties Introduced:
  • IpfcParameterRange.Maximum
  • IpfcParameterRange.Minimum
  • IpfcParameterLimit.Type
  • IpfcParameterLimit.Value
  • The property IpfcParameterRange.Maximum returns the maximum value limit for the parameter in the form of the IpfcParameterLimit object.
    The property IpfcParameterRange.Minimum returns the minimum value limit for the parameter in the form of the IpfcParameterLimit object.
    The property IpfcParameterLimit.Type returns the IpfcParameterLimitType containing the types of parameter limits. The parameter limits are of the following types:
    •  EpfcPARAMLIMIT_LESS_THAN—Specifies that the parameter must be less than the indicated value.
    •  EpfcPARAMLIMIT_LESS_THAN_OR_EQUAL—Specifies that the parameter must be less than or equal to the indicated value.
    •  EpfcPARAMLIMIT_GREATER_THAN—Specifies that the parameter must be greater than the indicated value.
    •  EpfcPARAMLIMIT_GREATER_THAN_OR_EQUAL—Specifies that the parameter must be greater than or equal to the indicated value.
    The property IpfcParameterLimit.Value returns the boundary value of the parameter limit in the form of the IpfcParamValue object.
    Example Code: Updating Model Parameters
    The sample code in the file pfcDimensionAndParameterExamples.vb located at <creo_vbapi_loadpoint>/vbapi_examples contains a method that reads a "properties" file and creates or updates model parameters for each property which exists in the file. Since each property value is returned as a String, a utility method parses the String into int, double, or boolean values if possible.
    Dimension Objects
    Dimension objects include standard Creo Parametric dimensions as well as reference dimensions. Dimension objects enable you to access dimension tolerances and enable you to set the value for the dimension. Reference dimensions allow neither of these actions.
    Getting Dimensions
    Dimensions and reference dimensions are Creo Parametric model items. See the section Getting ModelItem Objects for methods that can return IpfcDimension and IpfcRefDimension objects.
    Dimension Information
    Methods and Properties Introduced:
  • IpfcBaseParameter.Value
  • IpfcBaseDimension.DimValue
  • IpfcBaseParameter.IsDesignated
  • IpfcBaseParameter.IsModified
  • IpfcBaseParameter.ResetFromBackup()
  • IpfcBaseParameter.IsRelationDriven
  • IpfcBaseDimension.DimType
  • IpfcBaseDimension.Symbol
  • IpfcBaseDimension.Texts
  • All the IpfcBaseParameter methods are accessible to Dimensions as well as Parameters. See the section Parameter Objects for brief descriptions.
    Note
    You cannot set the value or designation status of reference dimension objects.
    The property IpfcBaseDimension.DimValue accesses the dimension value as a double. This property provides a shortcut for accessing the dimensions' values without using a IpfcParamValue object.
    The property IpfcBaseParameter.IsRelationDriven identifies whether the part or assembly relations control a dimension.
    The property IpfcBaseDimension.DimType returns an enumeration object that identifies whether a dimension is linear, radial, angular, or diametrical.
    The property IpfcBaseDimension.Symbol returns the dimension or reference dimension symbol (that is, “d#” or “rd#”).
    The property IpfcBaseDimension.Texts allows access to the text strings that precede or follow the dimension value.
    Dimension Tolerances
    Methods and Properties Introduced:
  • IpfcDimension.Tolerance
  • CCpfcDimTolPlusMinus.Create()
  • CCpfcDimTolSymmetric.Create()
  • CCpfcDimTolLimits.Create()
  • CCpfcDimTolSymSuperscript.Create()
  • CCpfcDimTolISODIN.Create()
  • Only true dimension objects can have geometric tolerances.
    The property IpfcDimension.Tolerance enables you to access the dimension tolerance. The object types for the dimension tolerance are:
    •  IpfcDimTolLimits—Displays dimension tolerances as upper and lower limits.
    Note
    This format is not available when only the tolerance value for a dimension is displayed.
    •  IpfcDimTolPlusMinus—Displays dimensions as nominal with plus-minus tolerances. The positive and negative values are independent.
    •  IpfcDimTolSymmetric—Displays dimensions as nominal with a single value for both the positive and the negative tolerance.
    •  IpfcDimTolSymSuperscript—Displays dimensions as nominal with a single value for positive and negative tolerance. The text of the tolerance is displayed in a superscript format with respect to the dimension text.
    •  IpfcDimTolISODIN—Displays the tolerance table type, table column, and table name, if the dimension tolerance is set to a hole or shaft table (DIN/ISO standard).
    A null value is similar to the nominal option in Creo Parametric.
    You can determine whether a given tolerance is plus/minus, symmetric, limits, or superscript using the following example code.If TypeOf (tolerance) Is IpfcDimTolLimits.
    Example Code: Setting Tolerances to a Specified Range
    The sample code in the file pfcDimensionAndParameterExamples.vb located at <creo_vbapi_loadpoint>/vbapi_examples shows a utility method that sets angular tolerances to a specified range.
    The example code shows a utility method that sets angular tolerances to a specified range. First, the program determines whether the dimension passed to it is angular. If it is, the method gets the dimension value and adds or subtracts the range to it to get the upper and lower limits.