Specialized Administration > Tailoring Business Objects > Type and Attribute Management > Type and Attribute Management Command-Line Tools > Using the TypeAttributeMoveTool Utility
  
Using the TypeAttributeMoveTool Utility
The TypeAttributeMoveTool command-line utility allows you to copy attribute values from one attribute to another attribute for a type and all its subtypes. After copying the attribute values, this tool will help in deleting source attribute and their values.
This ability to copy values between attributes on a type can also be used to, in essence, rename an attribute or move an attribute within a type hierarchy, from a subtype to a parent type, or from a parent type to a subtype. These special use cases are described in later sections.
* 
Use of com.ptc.core.lwc.server.TypeAttributeMoveTool is NOT RECOMMENDED for EPM Documents / CAD Documents as it may result in inconsistencies in family table object IBA values.
The source and target attributes can be either local attributes or global attributes, allowing for the following four scenarios:
Copying values from a global attribute to a local attribute—To achieve a performance gain, as local attribute values reside in the same database table as the type, rather than in a different table.
Copying values from a global attribute to a global attribute—To combine or split attributes.
Copying values from a local attribute to a local attribute—To combine or split attributes, or to move data from one table column to another.
Copying values from a local attribute to a global attribute—To allow the attribute to have multiple values and have global scope.
Before you run the utility:
The specified type and both the source and target attributes must exist in the system.
Both attributes must be on the same type, and must have the same data type.
For String attributes, the data size of the source attribute must be the same size or smaller than the data size of the target attribute.
Any references to the original source attributes, such as in calculated attributes or derived constraints, must be changed to refer to the target attributes.
When you run the tool, for all instances of the specified type:
Any current values of the target attribute are deleted.
All values from the source attribute are copied to the target attributes.
If multi-valued attributes are encountered during this copy process, only certain values are copied:
If the copy is from a multi-valued global attribute to a local attribute, then only one of the multiple global attribute values is copied.
You must confirm that the desired attribute value was copied by viewing the attribute on the object information page after the copy is performed.
If the copy is from a multi-valued global attribute to another global attribute, all of the multiple values are copied.
The Immutable constraint is set on the source attribute to prevent new instances from being created or existing instances from being changed.
Once all the source attribute values are copied to the target attribute, you need to delete the original source attribute from the system either using the Type and Attribute Management utility or TypeAttributeMoveTool command-line utility . This deletes all existing instances of the source attribute and their values.
* 
Because any existing values on the target attribute are permanently deleted, use this utility with caution!
The syntax for running the utility is given:
To copy attribute values, use
windchill com.ptc.core.lwc.server.TypeAttributeMoveTool <typeName> <sourceAttributeName> <targetAttributeName> -u <userID> -p <password>
To delete the source attribute values and its definition from the system, use
windchill com.ptc.core.lwc.server.TypeAttributeMoveTool <typeName> <sourceAttributeName> <targetAttributeName> -d -u <userID> -p <password>
where:
<typeName> is the internal name of the type.
<sourceAttributeName> is the internal name of the source attribute.
<targetAttributeName> is the internal name of the target attribute.
<userID> is the user name of the site administrator user.
<password> is the password of the site administrator user.
* 
Local attributes are stored in columns directly on the underlying object class. If there are no additional columns available on the class for new local attributes, an error message displays when you attempt to complete the creation of a new local attribute. Out-of-the-box, there are no additional columns on any object class for local attributes.
For information on adding columns for local attributes, see Adding Columns to Types.
To get further help, you can run windchill com.ptc.core.lwc.server.TypeAttributeMoveTool -h on command-line utility.
Renaming an Attribute
While the internal name of an attribute cannot be changed, the TypeAttributeMoveTool utility can be used to achieve the same result by moving the values from the attribute with the old internal name to another attribute with the desired internal name.
For example, if you have an attribute with the internal name “ABC” that you want to change to “XYZ”, you can achieve this by completing the following steps:
1. In the Type and Attribute Management utility, create an attribute with the internal name of “XYZ” on the same type as, and with the same data type as, the attribute with the internal name “ABC”.
2. From a Windchill shell, run the TypeAttributeMoveTool utility:
windchill com.ptc.core.lwc.server.TypeAttributeMoveTool <typeName> "ABC" "XYZ" -u <userID> -p <password>
This copies all the attribute value instances from the attribute with the internal name “ABC” to the attribute with the internal name “XYZ”.
3. After you have confirmed that everything is in order with the instance values for the attribute with the internal name “XYZ”, you can delete attribute with the internal name “ABC”.
Moving an Attribute from a Subtype to a Parent Type, or a Parent Type to a Subtype
While attributes cannot be moved from one type to another, the TypeAttributeMoveTool utility can be used to achieve this result within a type hierarchy, by moving values of an attribute created on a subtype to an attribute inherited from the parent or other ancestor type, or by moving values from an attribute inherited from a parent or other ancestor type to an attribute created on a subtype.
To move an attribute definition higher in the type hierarchy, from a subtype to a parent or other ancestor type, complete the following steps:
1. In the Type and Attribute Management utility, create a new attribute on the parent or other ancestor type with the same data type as the attribute on the subtype. The subtype now inherits this new attribute from the parent type.
2. Use the TypeAttributeMoveTool to move the values from the attribute on the subtype to the attribute inherited from the parent type, as described in Renaming an Attribute.
3. Confirm that the results are as expected.
4. Delete the attribute from the child type.
To move an attribute definition lower in the type hierarchy, from a parent or other ancestor type to a subtype, complete the following steps:
1. In the Type and Attribute Management utility, create a new attribute on the subtype with the same data type as the attribute on the parent or other ancestor type. The child type now has both the newly created attribute and the attribute already inherited from the parent or other ancestor type.
2. Use the TypeAttributeMoveTool to move the values from the attribute inherited from the parent or other ancestor type to the newly created attribute on the subtype, as described in Renaming an Attribute.
3. Confirm that the results are as expected.
4. Delete the attribute from the parent type.
* 
The internal name of an attribute must be unique among all subtypes and parent types of a type. If you want to use the internal name from the attribute on the original type as the internal name of the attribute on the target type to which the attribute is being moved, create a temporary attribute on the target type first. Move the attribute values to the temporary attribute on the target type, using the steps previously given for moving an attribute definition higher or lower in the type hierarchy.
Once the original attribute has been deleted, a new attribute with the desired internal name can be created on the target type, and the attribute instance values moved from the temporary attribute to the newly created attribute, as described in Renaming an Attribute.
For more information, see the following detailed examples:
Moving a Local Attribute Definition Lower in the Type Hierarchy
Moving a Local Attribute Definition Higher in the Type Hierarchy
Moving a Global Attribute Definition Lower in the Type Hierarchy
Moving a Global Attribute Definition Higher in the Type Hierarchy
Moving Other Types of Attributes Lower or Higher in a Type Hierarchy
* 
For purposes of these examples, all types and attributes use the same value for their internal names as for their display names.
Moving a Local Attribute Definition Lower in the Type Hierarchy
Nigel’s company has created a subtype of the Part type named MyPart, which in turn has a subtype named MySubPart. Currently there is a local attribute named Color defined on the MyPart subtype, which is inherited by the MySubPart type. There are values for the Color attribute on both MyPart and MySubPart, but the company has decided that color only needs to be specified on the MySubPart type. As a result, Nigel wants to move the Color attribute definition from the MyPart subtype down the type hierarchy to the MySubPart subtype, so that the Color attribute is defined on the MySubPart subtype, and only the values already defined for the Color attribute on MySubPart are retained.
* 
If there are other subtypes of the MyPart type that are peers rather than children of the MySubPart subtype, any values specified for the original Color attribute defined on and inherited from the MyPart type are deleted when the original Color attribute is deleted at the end of this process.
This is accomplished by completing the following steps:
1. In the Type and Attribute Management utility, Nigel carefully notes the details of the Color attribute defined on the MyPart subtype, including the data type.
2. Nigel creates a new local attribute on the MyPart subtype, named ColorCopy, which is identical to the original Color attribute. The ColorCopy attribute is now also inherited by the MySubPart subtype.
3. From a Windchill shell, Nigel runs the following command to copy the values of the Color attribute to the ColorCopy attribute on the MyPart subtype:
windchill com.ptc.core.lwc.server.TypeAttributeMoveTool MyPart Color ColorCopy
When prompted, Nigel enters his administrative user name and password.
Because the MySubPart subtype inherits the Color attribute from the MyPart subtype, all values of the Color attribute on the MySubPart subtype are also copied to the inherited ColorCopy attribute.
4. Back in the Type and Attribute Management utility, Nigel deletes the Color attribute from the MyPart subtype. All instances of that attribute, including the attribute values, are deleted as well.
5. Nigel now creates a new local attribute on the MySubPart subtype named Color, which is identical to the original Color attribute.
6. From a Windchill shell, Nigel runs the following command to copy the values of the inherited ColorCopy attribute to the Color attribute now defined on the MySubPart subtype:
windchill com.ptc.core.lwc.server.TypeAttributeMoveTool MySubPart ColorCopy Color
When prompted, Nigel enters his administrative user name and password.
7. Back in the Type and Attribute Management utility, Nigel deletes the ColorCopy attribute from the MyPart subtype.
Moving a Local Attribute Definition Higher in the Type Hierarchy
There is a local attribute named Size on the MySubPart subtype that Nigel wants to move up the type hierarchy to the MyPart subtype so that the attribute is inherited by the MySubPart subtype and all other subtypes of MyPart. There are already values present for the Size attribute on the MySubPart subtype, and Nigel wants to keep these values intact, once the Size attribute is moved up to the MyPart subtype.
This is accomplished by completing the following steps:
1. In the Type and Attribute Management utility, Nigel carefully notes the details of the Size attribute defined on the MySubPart subtype, including the data type.
2. Nigel creates a new local attribute on the MyPart subtype, named SizeCopy, which is identical to the original Size attribute on the MySubPart subtype. The SizeCopy attribute is now inherited by the MySubPart subtype.
3. From a Windchill shell, Nigel runs the following command to copy the values of the Size attribute to the inherited SizeCopy attribute on the MySubPart subtype:
windchill com.ptc.core.lwc.server.TypeAttributeMoveTool MySubPart Size SizeCopy
When prompted, Nigel enters his administrative user name and password.
4. Back in the Type and Attribute Management utility, Nigel deletes the Size attribute from the MySubPart subtype.
5. Nigel now creates a new local attribute on the MyPart subtype named Size, which is identical to the original Size attribute. The MySubPart subtype now inherits the Size attribute from the MyPart subtype.
6. From a Windchill shell, Nigel runs the following command to copy the values of the inherited SizeCopy attribute to the new Size attribute on the MyPart subtype:
windchill com.ptc.core.lwc.server.TypeAttributeMoveTool MyPart SizeCopy Size
When prompted, Nigel enters his administrative user name and password.
7. Back in the Type and Attribute Management utility, Nigel deletes the SizeCopy attribute from the MyPart subtype.
Moving a Global Attribute Definition Lower in the Type Hierarchy
A global attribute named Shape is defined on the MyPart subtype, and is inherited by the MySubPart subtype. There are values for the Shape attribute on both the MyPart and MySubPart subtypes, but the company has decided that shape only needs to be specified on the MySubPart type. As a result, Nigel wants to move the Shape attribute definition from the MyPart subtype down the type hierarchy to the MySubPart subtype, so that the Shape attribute is defined on the MySubPart subtype, and only the values already defined for the Shape attribute on MySubPart are retained.
* 
If there are other subtypes of the MyPart type that are peers rather than children of the MySubPart subtype, any values specified for the original Shape attribute defined on and inherited from the MyPart type are deleted when the original Shape attribute is deleted at the end of this process.
This is accomplished by completing the following steps:
1. In the Type and Attribute Management utility, Nigel carefully notes the details of the Shape attribute defined on the MyPart subtype.
2. Nigel creates a new global attribute on the MyPart subtype, named ShapeCopy, which is identical to the original Shape attribute, with one exception. Only one global attribute within given type hierarchy can refer to a particular reusable attribute. Thus, the new ShapeCopy attribute must be based on a different reusable attribute than the Shape attribute. Both reusable attributes must have the same data type for the move action to succeed.
The ShapeCopy attribute is now also inherited by the MySubPart subtype.
3. From a Windchill shell, Nigel runs the following command to copy the values of the Shape attribute to the ShapeCopy attribute on the MyPart subtype:
windchill com.ptc.core.lwc.server.TypeAttributeMoveTool MyPart Shape ShapeCopy
When prompted, Nigel enters his administrative user name and password.
Because the MySubPart subtype inherits the Shape attribute from the MyPart subtype, all values of the Shape attribute on the MySubPart subtype are also copied to the inherited ShapeCopy attribute.
4. Back in the Type and Attribute Management utility, Nigel deletes the Shape attribute from the MyPart subtype. All instances of that attribute, including the attribute values, are deleted as well.
5. Nigel now creates a new global attribute on the MySubPart subtype named Shape, which is identical to the original Shape attribute, including referencing the same reusable attribute as the original Shape attribute did.
6. From a Windchill shell, Nigel runs the following command to copy the values of the inherited ShapeCopy attribute to the Shape attribute now defined on the MySubPart subtype:
windchill com.ptc.core.lwc.server.TypeAttributeMoveTool MySubPart ShapeCopy Shape
When prompted, Nigel enters his administrative user name and password.
7. Back in the Type and Attribute Management utility, Nigel deletes the ShapeCopy attribute from the MySubPart subtype.
Moving a Global Attribute Definition Higher in the Type Hierarchy
There is a global attribute named Material on the MySubPart subtype that Nigel wants to move up the type hierarchy to the MyPart subtype so that the attribute is inherited by the MySubPart subtype and all other subtypes of MyPart. There are already values present for the Material attribute on the MySubPart subtype, and Nigel wants to keep these values intact, once the Material attribute is moved up to MyPart subtype.
This is accomplished by completing the following steps:
1. In the Type and Attribute Management utility, Nigel carefully notes the details of the Material attribute defined on the MySubPart subtype.
2. Nigel creates a new global attribute on the MyPart subtype, named MaterialCopy, which is identical to the original Material attribute on the MySubPart subtype, with one exception. Only one global attribute within a given type hierarchy can reference a particular reusable attribute. Thus, the new MaterialCopy attribute must be based on a different reusable attribute than the Material attribute. Both reusable attributes must have the same data type for the move action to succeed.
3. From a Windchill shell, Nigel runs the following command to copy the values of the Material attribute to the inherited MaterialCopy attribute on the MySubPart subtype:
windchill com.ptc.core.lwc.server.TypeAttributeMoveTool MySubPart Material MaterialCopy
When prompted, Nigel enters his administrative user name and password.
4. Back in the Type and Attribute Management utility, Nigel deletes the Material attribute from the MySubPart subtype.
5. Nigel now creates a new global attribute on the MyPart subtype named Material, which is identical to the original Material attribute, including referencing the same reusable attribute as the original Material attribute did.
6. From a Windchill shell, Nigel runs the following command to copy the values of the MaterialCopy attribute on the MySubPart subtype to the new Material attribute now inherited from the MyPart subtype:
windchill com.ptc.core.lwc.server.TypeAttributeMoveTool MySubPart MaterialCopy Material
When prompted, Nigel enters his administrative user name and password.
7. Back in the Type and Attribute Management utility, Nigel deletes the MaterialCopy attribute from the MyPart subtype.
Moving Other Types of Attributes Lower or Higher in a Type Hierarchy
Alias, calculated and translated text attributes can be moved from one level to another within a type hierarchy by direct manipulation in the Type and Attribute Management utility. As no instance data is present for alias, calculated or translated text attributes, deleting them and recreating them in the desired location results in no loss of instance data.
To move an alias, calculated, or translated text attribute higher or lower within a type hierarchy, complete the following steps:
1. Record exactly how the alias, calculated, or translated text attribute is currently defined.
2. Delete the attribute.
3. Re-create the attribute on the desired type within the type hierarchy.