[Integration Kit Contents] [Integration Kit What's New] [Integration Kit Function Index] [More Documentation] [PTC]

Exchange of Creo Elements/Direct Modeling Attributes with Model Manager Database

For information on the concepts of sharing database attributes, see here.

sd-define-db-attribute
sd-assign-db-attribute
sd-remove-db-attribute
sd-inq-db-attributes
sd-inq-db-attribute-values
sd-define-db-personality
sd-set-db-attribute-verbose-error-handling
sd-db-attribute-browser-set-active-object
sd-is-required-db-attribute

additional hints

Function Index Top of Page

SD-DEFINE-DB-ATTRIBUTE  [function]

(sd-define-db-attribute name
                        :attachment          attachment
                        :class-name          class-name
                        :keys                keys
                        :allowed-owner-types allowed-owner-types
                        :master              master
                        :filing              filing
                        :on-copy             on-copy
                        :on-merge            on-merge
                        :on-split            on-split
                        :on-xform            on-xform
                        :command-name        command-name)
Description:
Provides a definition for an Creo Elements/Direct Modeling user-defined attribute that is to be exchanged with the database. Each keyed value in the Creo Elements/Direct Modeling attribute is mapped to a single attribute (column) in a specified database table. Existing definitions may be overridden.

Parameters:
name {STRING}
The name of the Creo Elements/Direct Modeling user-defined attribute (must not be an Creo Elements/Direct Modeling reserved attribute name).
:attachment {KEYWORD [:contents]}
Determines whether the attribute should be attached at the :instance or :contents.
:class-name {STRING}
The name of an existing database table into which the attribute is to be mapped. This parameter is not required for instance level attributes since these are always mapped to the INSTANCE_LINK table.
:keys {LIST of STRING or KEYWORD}
A list of names of database attributes which are to exchanged with this Creo Elements/Direct Modeling user-defined attribute. Each item in the list may be replaced by a list containing the item and additional data indexed by keyword. The keyword :label precedes a string which will be used to refer to the database attribute in the Creo Elements/Direct Modeling user interface (instead of the database attribute name). The keyword :option precedes a keyword which will be used to refer to the database attribute in any auto-generated command for assigning the attribute (see :command-name). The :option value must be specified if the supplied database attribute name is a multi-byte string. Each database attribute may be exchanged with only one Creo Elements/Direct Modeling user-defined attribute. This means that the Creo Elements/Direct Modeling user-defined attribute must have a unique name even if the corresponding database attribute is defined in different classes. If the database attribute is defined in different classes of same class type, the Creo Elements/Direct Modeling user-defined attribute must map to a pseudo attribute of the desired database attribute. Creo Elements/Direct Modeling reserved system database attribute names may not be used.
:allowed-owner-types {KEYWORD [:part-assembly]}
Specifies the value-types of owner to which the attribute may be attached. Valid keywords are the existing command value-types :part, :assembly, :part-assembly, :wp, :wp-with-profile, :wpset.
:master {KEYWORD [:all]}
Determines whether Creo Elements/Direct Modeling, the database or both control the attribute value.
  • :all - Changes to the Creo Elements/Direct Modeling attribute are propagated to the database and vise-versa.
  • :db - Changes made within the Creo Elements/Direct Modeling modeling session will not overwrite existing database values. After a store operation is performed, the Creo Elements/Direct Modeling attribute will be synchronized with the database values.
  • :osd - Changes made within the database environment will not overwrite attribute values maintained in the Creo Elements/Direct Modeling environment. Upon the next store operation, the database value will synchronized with the Creo Elements/Direct Modeling attribute value.
:filing {KEYWORD or LIST of KEYWORDS ['(:sd-file :db)]}
The :filing behaviour may include the additional keyword :db. If this keyword is not included, the attribute will not be exchanged with the database and the parameters :class-name and :master are not applicable. The default :filing behaviour is '(:db :sd-file). See sd-attach-item-attribute for further information.
:on-copy {KEYWORD [:copy]}
See sd-attach-item-attribute for further information.
:on-merge {KEYWORD [:maintain]}
See sd-attach-item-attribute for further information.
:on-split {KEYWORD [:copy]}
See sd-attach-item-attribute for further information.
:on-xform {KEYWORD [:maintain]}
See sd-attach-item-attribute for further information.
:command-name {SYMBOL [nil]}
The name of the command for assigning this attribute to be auto-generated by this function. No command is generated if this parameter is nil. Any created command will be registered as an 'available command' (in the Database group for all applications) so allowing its invocation from the Creo Elements/Direct Modeling user-defined toolbars, popup menus and menu-bar.

Return value:
t - if the attribute was successfully defined.
nil - if illegal parameter values were supplied or the database cannot be contacted.

Examples:
(sd-define-db-attribute "Material" 
                        :class-name "MODEL_3D"
                        :attachment :contents
                        :keys '(("MODEL_MAT_ID" :label "Id" :option :id)
                                ("HEAT_TREAT" :label "Heat Treat")
                                ("FINISH" :label "Finish"))
                        :allowed-owner-types :part-assembly
                        :master :db
                        :on-copy :copy
                        :command-name 'assign_material_attribute)

(sd-define-db-attribute "BoM"
                        :class-name "BOM_CLASS"
                        :keys '("Spares" "Overwrites")
                        :attachment :contents
                        :allowed-owner-types :assembly)

Function Index Top of Page

SD-ASSIGN-DB-ATTRIBUTE  [function]

(sd-assign-db-attribute name owner values)
Description:
Assigns a set of keyed values to a named Creo Elements/Direct Modeling user-defined attribute that is exchanged with the database. Any existing values for keys not contained in the supplied values list are retained. If the attribute does not already exist on the supplied owner, it is created. It will be created at the attachment level specified when it was defined (instance or contents) and will inherit the behaviours (:on-copy, :on-merge, etc) specified when it was defined. The attribute will also contain a system key, :class-type, identifying the class of the db table containing the attribute (:doc, :part or :link).

Parameters:
name {STRING}
The name of the Creo Elements/Direct Modeling user-defined attribute. This must be the name of an attribute previously defined by sd-define-db-attribute.
owner {SEL_ITEM}
The owner item to which the user-defined attribute is (to be) attached. The owner must be compatible with the value-types specified when the attribute was defined.
values {PROPERTY-LIST}
The keyed values to be assigned within the user-defined attribute. The key of each property-list entry is the name of the database attribute to which the keyed value is mapped. This must be a key defined when the attribute was defined. The value of each property-list entry is the value to be associated with the supplied key. The system keys may not be overridden.

Return value:
t - if the attribute was successfully assigned.
nil - if illegal parameter values were supplied or the owner is not modifiable.

Example:
(sd-assign-db-attribute "Material" my-part
                        '(:MODEL_MAT_ID "Steel"
                          :HEAT_TREAT "H32"
                          :FINISH "polished"))

Function Index Top of Page

SD-REMOVE-DB-ATTRIBUTE  [function]

(sd-remove-db-attribute name owner)
Description:
Removes a named Creo Elements/Direct Modeling user-defined attribute that is exchanged with database. Any corresponding database values are reset when the owner of the attribute is next stored.

Parameters:
name {STRING}
The name of the Creo Elements/Direct Modeling user-defined attribute. This must be the name of an attribute previously defined by sd-define-db-attribute.
owner {SEL-ITEM}
The owner item on which the attribute is (to be) removed.

Return value:
t - if the attribute was successfully cleared.
nil - if illegal parameter values were supplied or the owner is not modifiable.

Example:
(sd-remove-db-attribute "Material" my-part)

Function Index Top of Page

SD-INQ-DB-ATTRIBUTES  [function]

(sd-inq-db-attributes owner)
Description:
For a given owner, returns a list of all the Creo Elements/Direct Modeling user-defined attributes that are exchanged with the database.

Parameters:
owner {SEL-ITEM}
The owner item for which attributes are to be inquired.

Return value:
{KEYWORD LIST} of attribute names.
nil - if illegal parameter values were supplied or no attributes exist.

Example:
(sd-inq-db-attributes my-part) => ("Material" "BoM")

Function Index Top of Page

SD-INQ-DB-ATTRIBUTE-VALUES  [function]

(sd-inq-db-attribute-values name owner)
Description:
Returns a property list of the values for a named Creo Elements/Direct Modeling user-defined attribute that is exchanged with the database.

Parameters:
name {STRING}
The name of the Creo Elements/Direct Modeling user-defined attribute. This must be the name of an attribute previously defined by sd-define-db-attribute.
owner {SEL-ITEM}
The owner item for which attribute values are to be inquired.

Return value:
{PROPERTY-LIST} of keyed values if the attribute has one or more keyed values.
nil - if illegal parameter values were supplied or the attribute has no keyed values.

Example:
(sd-inq-db-attribute-values "Material" my-part) 
 => (:MODEL_MAT_ID "Steel" :HEAT_TREAT "H32" :FINISH "polished")

Function Index Top of Page

SD-DEFINE-DB-PERSONALITY  [function]

(sd-define-db-personality name
                          :attribute-names attribute-names
                          :auto-command auto-command
                          :command-name command-name
                          :category category
                          :allowed-values allowed-values
                          :default-values default-values
                          :always-offer-defaults always-offer-defaults
                          :icon icon
                          :visible visible)

Description:
Establishes a personality for creating, modifying and accessing Creo Elements/Direct Modeling user-defined attributes that are exchanged with the database.

Parameters:
name {STRING}
The name of the personality (must be unique). This name will be used to identify the personality in the Database Attribute Browser.
:attribute-names {STRING or LIST OF STRINGS}
The names of one or more Creo Elements/Direct Modeling user-defined attributes exchanged with the database, all of which must have been previously defined using the function sd-define-db-attribute. If incorrect, the Database Attribute Browser will not correctly represent the association between personalities and database attributes.
:auto-command {BOOLEAN [nil]}
If this option is nil, the :command-name parameter must refer to an existing Creo Elements/Direct Modeling custom command to be associated with the personality. If this option is non-nil (and :attribute-names is not a list), the :command-name parameter specifies the name to be used for the command which is to be auto-generated for the (single) attribute associated with this personality.
:command-name {SYMBOL [nil]}
The name of an Creo Elements/Direct Modeling command to be associated with the personality. The option :auto-command controls whether this is the name of an existing custom Creo Elements/Direct Modeling command to be associated with a personality (the default) or whether such a command should be auto-generated. The command will be invoked when the user multi-clicks on the corresponding node in the Database Attribute Browser. The command will also be registered as an 'available command' (in the Database group for all applications) so allowing its invocation from the Creo Elements/Direct Modeling user-defined toolbars and popup menus.
Custom Command
A custom command must include a variable with the name "OWNER" which accepts the SEL_ITEM of the object whose attribute values are to be manipulated. Any custom command should use the function sd-assign-db-attribute to assign attribute values when it completes. Although sd-assign-db-attribute will ensure that the supplied values are consistent with the attribute's definition, the command's author should check that the command passes only valid values to this function.
Auto-Generated Command
Any auto-generated command is the same as that auto-generated by sd-define-db-attribute for the (single) attribute associated with the personality (possibly modified by the :allowed-values and :default-values options). If :command-name is nil, the command-name supplied to sd-define-db-attribute is used.
:category {STRING}
The category path defining where the personality appears in the Database Attribute Browser tree. Any category path beginning with the '/' character is valid. If no category path is supplied, the personality will appear at the root of the Database Attribute Browser tree.
:allowed-values {PROPERTY-LIST}
Restricts the set of values that can be entered for keyed values. Requires that the :auto-command option is t. Each key in the property list must be a database attribute name (column) compatible with the definition for the attribute established via sd-define-db-attribute. Each value in the property list must be nil or a list of legal values (as restricted by the database schema) for the database attribute to be supported by this personality. The supplied values further restrict the allowed values in any auto-generated command for the attribute. A nil value disables the option for the corresponding key.
:default-values {PROPERTY-LIST}
Overrides the defaults for keyed values derived from the database schema. Requires that the :auto-command option is t. Each key in the property list must be a database attribute name (column) compatible with the definition for the attribute established via sd-define-db-attribute. Each value in the property list must be nil (only for optional database attributes) or a legal value (as restricted by the database schema and the :allowed-values option) for the database attribute to be supported by this personality. The supplied values are used as defaults for any variables associated with unset attribute keys (in the auto-generated command for the attribute).
:always-offer-defaults {BOOLEAN [nil]}
Indicates that when the owner option is passed to a personality command, the command should always offer any :default-values, even if the owner already has values for the keys with defaults.
:icon {URL [nil]}
An (optional) URL to an icon (Unix pixmap or Windows bitmap) file, to be used to represent the personality in the Database Attribute Browser.
:visible {BOOLEAN [t]}
Indicates whether the supplied personality command should be accessible from the Database Attribute Browser.

Return value:
t - if the personality was successfully created.
nil - if illegal parameter values were supplied.

Examples:
(sd-define-db-personality "S7"
                          :attribute-names "Material"
                          :auto-command t
                          :command-name 'assign_s7
                          :category "/Manufacturing/Material"
                          :always-offer-defaults t
                          :default-values
                          '(:MODEL_MAT_ID :Steel :HEAT_TREAT :H7 :FINISH :polished))

(sd-define-db-personality "S8"
                          :attribute-names "Material"
                          :auto-command t
                          :command-name 'assign_s8
                          :category "/Manufacturing/Material"
                          :always-offer-defaults t
                          :default-values
                          '(:MODEL_MAT_ID :Steel :HEAT_TREAT :H7 :FINISH :rough))

(sd-define-db-personality "Material"
                          :attribute-names "Material"
                          :auto-command t
                          :category "/Manufacturing"
                          :icon "bitmaps/personalities/material.bmp"
                          :allowed-values '(:FINISH (:polished :rough)))

Function Index Top of Page

SD-SET-DB-ATTRIBUTE-VERBOSE-ERROR-HANDLING  [function]

(sd-set-db-attribute-verbose-error-handling on)
Description:
Controls whether errors detected by the following functions are displayed in popup error dialogs:
sd-define-db-attribute
sd-assign-db-attribute
sd-remove-db-attribute
sd-inq-db-attributes
sd-inq-db-attribute-values
sd-define-db-personality

Parameters:
on {BOOLEAN [nil]}
Indicates whether errors should be displayed.
The default is off or nil which will hide many issues from the user.

Return value:
{BOOLEAN} the new verbose error setting.

Example:
(sd-set-db-attribute-verbose-error-handling t)

Function Index Top of Page

SD-DB-ATTRIBUTE-BROWSER-SET-ACTIVE-OBJECT  [function]

(sd-db-attribute-browser-set-active-object owner :show show)
Description:
Makes owner the active object in the database attribute browser, optionally showing the browser. This function is intended to be called by custom dialogs used with sd-define-db-personality when an owner object is selected (call it from :after-input-ui in the OWNER variable).

Parameters:
owner {SEL-ITEM}
The owner item for which will be made the active object in the database attribute browser. If owner is nil, the active object is cleared.
:show {BOOLEAN [nil]}
Indicates whether the database attribute browser should be shown.

Return value:
t - if browser was shown.
nil - otherwise.

Example:
(sd-db-attribute-browser-set-active-object my-part)

Function Index Top of Page

SD-IS-REQUIRED-DB-ATTRIBUTE  [function]

(sd-is-required-db-attribute name)
Description:
Determines if a named Creo Elements/Direct Modeling user-defined attribute has any required keys. Attributes with one or more required keys will not be completely removed by sd-remove-db-attribute (required keys will be reset to their default values).

Parameters:
name {STRING}
The name of the Creo Elements/Direct Modeling user-defined attribute. This must be the name of an attribute previously defined by sd-define-db-attribute.

Return value:
{LIST of STRING or KEYWORD} first element of list is a required key.
nil - if illegal parameter values were supplied or there were no required keys.

Example:
(sd-is-required-db-attribute "Material")

Function Index Top of Page

Additional Hints

Attribute with a lowercase name or a mixed lower/uppercase name.
These attributes might be found in schemas created by Workmanager in days before Modelmanager. They will allway appear as a string instead of a keyword in the key value list
[Integration Kit Contents] [Integration Kit What's New] [Integration Kit Function Index] [More Documentation] [PTC]
© 2023 Parametric Technology GmbH
(a subsidiary of PTC Inc.), All Rights Reserved