This section discusses how to specify which ModelManager database attributes are to be exchanged with Creo Elements/Direct Modeling.
In this section:
An Integration Kit function sd-define-db-attribute is provided to support specification of which of Creo Elements/Direct Modeling user defined attributes are to be exchanged with the ModelManager database. It is envisaged that these definitions will generally be specified by administrators and, in an operational environment, will be established in Creo Elements/Direct Modeling (corporate or site) customization files.
Below is an example of a database attribute definition:
(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 :on-split :detach :command-name 'assign_material_attribute)
Subsequent sections of this document will explain the significance of each of the parameters supplied to the function.
Each Creo Elements/Direct Modeling user-defined attribute that is exchanged with the database must map to a single database table (:class-name). In the example, the Material attribute is mapped to the MODEL_3D database table. Once an attribute has been defined, its name may not be used in a subsequent definition which links to a table of the same class. In any case, it is good practice to ensure that the names of all user-defined attributes are unique.
A Creo Elements/Direct Modeling user-defined attribute may map to one or more database attributes (in a single table). The :keys parameter specifies (at minimum) a list of database attribute names. In the example, the Material attribute is mapped to the MODEL_MAT_ID, HEAT_TREAT and FINISH database attributes. Thus in each Creo Elements/Direct Modeling Material user defined attribute, there will be three keyed values ("MODEL_MAT_ID", "HEAT_TREAT" and "FINISH"). Note that each database attribute may be mapped to only one Creo Elements/Direct Modeling user-defined attribute.
Creo Elements/Direct Modeling user-defined attributes that are exchanged with the database possess the same properties as those which are not exchanged. Thus it is possible to specify the attachment level of the attribute (:contents or :instance) and a set of behaviours in the same way as for standard user-defined attributes (see sd-attach-item-attribute ).
Note current restrictions:
Database exchanged user-defined attributes support an additional :filing behaviour :db. This is the default behaviour established when an attribute is defined. If the :db behaviour is not specified, the attribute is not exchanged with the database (and all parameters relating to data exchange are superfluous). In this way, sd-define-db-attribute can be used to define a command for creating standard user-defined attributes.
By default, attributes are exchanged between Creo Elements/Direct Modeling and the database in both directions. Thus, changes made to attribute values on the model will propagate to the database (subject to any business rules in place) and changes made in the database environment will propagate back to the model. However this default behaviour can be changed using the :master parameter.
If Creo Elements/Direct Modeling is the master environment (:master :osd), then no changes to attribute values made in the database environment will be propagated back to Creo Elements/Direct Modeling. If the database is the master environment (:master :db), then no changes to attribute values made in the modeling environment will be propagated to the database (although an initial set of values may be specified on creation in the modeling environment).
When a Creo Elements/Direct Modeling attribute is defined, a corresponding command for creating and modifying such an attribute on an object is automatically created. For the example Material attribute definition, the following command is created:
assign_material_attribute :owner owner :ID id :HEAT_TREAT ht :FINISH sf
with the following user interface:
The commands section of this document explains the operation of such a command. The form of the command is to a great extent influenced by the database schema entries for the database attributes with which data is exchanged. However, at definition time it is possible to specify:
Normally, the names of the database attribute keys (specified using the :keys parameter) will be used as the names of the options in the auto-generated command and as the names for options in the user interface. However, if the names of the database attributes are localized strings, alternative non-localized names must be chosen for command options.
Note that a command will not be created if no command name is specified and that it is not possible to override an existing Creo Elements/Direct Modeling command (unless that command was previously associated with an attribute being re-defined).
© 2023 Parametric
Technology GmbH (a subsidiary of PTC Inc.), All Rights Reserved |