Editing the Delegate (AutoCAD)
Out-of-the-box delegate
Windchill provides an out-of-the-box mechanism to pass additional information related to the CAD Document as custom system parameters.
To customize the parameters, set the server-side preference, > at the site level.
• The value is a list of additional attributes from objects related to the CAD Document that are shown in the CAD tool as parameters or properties.
• The value is a comma separated list of CAD property and Windchill attribute pairs in the following format:
<name_of_CAD_property>:<relatedObjectCode>.<WindchillAttributeName>
Where:
Value
|
Description
|
Possible values
|
name_of_CAD_property
|
This is the name of the parameter or property in the CAD tool
|
PART_REVISION
|
relatedObjectCode
|
This is the string used to identify the related object
|
• docMaster
• associatedPart
• relatedECN
• promote
|
WindchillAttributeName
|
This is the logical name or internal name of the attribute in Windchill for the related object
|
• soft type attributes on CAD Document Master
• Part Attributes
◦ soft type attribute on the related Part of type Boolean, Date, Integer, Real, Real with Units or String
◦ lifeCycleState
◦ lifecycleTemplate.name
◦ name
◦ number
◦ orgid
◦ view.identity
◦ partType
• For related ECN
◦ number
◦ orgid
◦ resolutionDate
• For promote
◦ number
◦ promotionDate
◦ orgid
◦ approvers
◦ approveDates
◦ reviewers
◦ reviewDates
|
|
For soft-type attributes, values sent to the CAD tool are the display values as seen on the object’s Information page. Display values use Attribute Handling preferences and Type and Attribute Management settings but do not support complex display customizations using data utilities for rendering.
|
This functionality can only be used if you do not have a customized server-side delegate CustomModeledAttributesDelegate that can be used to insert parameters (see the next section below for Custom Delegate).
For the associated part:
• This functionality supports parts related to the CAD Document with Owner, Contributing Image, Image and Contributing Content.
• The selected part version is similar to the CAD Document’s information page related parts table.
• If more than one revision of the same part is related to the CAD Document, then the latest revision of each part is returned.
• More than one part can be returned if the system is configured to allow multiple build associations, with the server-side preference > > set to Yes. In this case, the information for each related part is returned in a delimited format. The delimiter used is defined by the server-side preference > .
For the related ECN:
• When the CAD Document revision participates in the Change Notice as Resulting Object, then the attributes about the ECN are sent to the CAD parameter.
• If the CAD Document revision participates in more than one Change Notice , then the delimiter used is defined by the server-side preference >
• The rejected ECNs are not listed.
For the Promotion request:
• When the CAD Document version participates in the Promotion request, then the attributes about the Promotion request are sent to the CAD parameter.
• If the CAD Document revision participates in more than one Promotion request, then the delimiter used is defined by the server-side preference >
• The rejected Promotion request is not listed.
Custom Delegate
Windchill provides a server-side delegate that can be used to insert parameters into a authoring application part upon download. This mechanism can be used to pass information from the server down to the authoring application, where it can be used like any other authoring application parameter (for example, to place information on drawing forms). Parameters beginning with PTC or PROI are regarded as reserved system parameters and cannot be propagated by the customization. If they are added in the customization, they are ignored by the download service.
|
• If you configure the system to use a custom delegate, then the attributes defined in the server-side preference, > Only the PTC delegate checks that preference.
• The customized parameters are provided to the client upon download and are not updated in the CAD application session after a Windchill operation such as check in. For example, if a customized parameter is assigned the value of the CAD document number, its value is provided to the client upon download. If the CAD document is later renumbered, the value in the authoring application session or the client cache is not automatically updated. The Windchill service delegate mechanism is used to allow the customization.
|
The following steps explain the customization process:
1. Create a Java class that implements the interface ModeledAttributesDelegate in a customer-specific location separate from the PTC classes (For example, <WT_HOME>\com\acme). The interface definition is as follows:
package com.acme.download;
import static org.junit.Assert.assertTrue;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import com.ptc.windchill.uwgm.proesrv.c11n.DefaultModeledAttributesDelegate;
import java.util.Iterator;
import wt.epm.EPMDocument;
import wt.fc.collections.WTCollection;
import wt.fc.collections.WTHashSet;
import wt.preference.PreferenceHelper;
import wt.util.WTException;
/**
* When CustomizedModeledAttributesDelegate is configured following modeled attributes would be added to the CAD
* Document, which would be combination of custom CURRENT_DATE parameter along with Parameters configured in mentioned
* preference "Mapping Custom System Attributes and File Properties". For eg.When preference "Mapping Custom System
* Attributes and File Properties" set with value as
* -CREO_PART_REVISION:associatedPart.revision,CREO_PART_VIEW:associatedPart.view.identity,ECN_NUMBER:relatedECN.number
* Modeled attributes on CAD Document would be- CREO_PART_REVISION=A, ECN_NUMBER=00192, CREO_PART_VIEW=Design,
* CURRENT_DATE=2023/10/11 05:07
*/
public class CustomizedModeledAttributesDelegate extends DefaultModeledAttributesDelegate {
private static final String CUSTOM_SYSTEM_PARAMS_PREF = "system.attribute.mapping.custom";
private static final String PROE = "PROE";
private static final String CURRENT_DATE = "CURRENT_DATE";
// getAvailableAttributes() returns
// HashMap<String, Object> which contains
// HashMap<Attribute name, Attribute type> @Override
public HashMap getAvailableAttributes() {
System.out.println(
"Invoked CustomizedModeledAttributesDelegate extends DefaultModeledAttributesDelegate :: getModeledAttributes() :Returning an empty list of modeled Attributes.");
return new HashMap();
}
/**
* Returns a map of modeled attributes for the EPMDocument objects in the provided collection. This method retrieves
* the modeled attributes from the PTC default implementation.
*
* @param collection a collection of EPMDocument objects for which to retrieve the modeled attributes
* @return a map of modeled attributes for the provided EPMDocument objects
* @throws WTException if an exception occurs while retrieving the modeled attributes
*/
@Override
public HashMap getModeledAttributes(
final Collection collection)
throws WTException {
System.out.println(
"Invoked CustomizedModeledAttributesDelegate extends DefaultModeledAttributesDelegate :: getModeledAttributes() ");
String prefValue = (String) PreferenceHelper.service.getValue(CUSTOM_SYSTEM_PARAMS_PREF,
PROE);
System.out.println("CustomizedModeledAttributesDelegate prefValue " + prefValue);
HashMap objVsAttrNameVsValue = new HashMap();
// Fetching only EPMDocuments from input collection.
WTCollection inEPMDocs = new WTHashSet(collection).subCollection(EPMDocument.class);
Iterator persistableIterator = inEPMDocs.persistableIterator();
if (prefValue != null && (!prefValue.isBlank())) {
while (persistableIterator.hasNext()) {
EPMDocument anEPMDoc = (EPMDocument) persistableIterator.next();
objVsAttrNameVsValue = super.getModeledAttributes(collection);
Map<String, String> attrNameVsValueMap = (Map<String, String>)objVsAttrNameVsValue.get(anEPMDoc);
assertTrue(attrNameVsValueMap != null);
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm");
LocalDateTime now = LocalDateTime.now();
attrNameVsValueMap.put(CURRENT_DATE, dtf.format(now).toString());
System.out.println("CustomizedModeledAttributesDelegate attrNameVsValueMap " + attrNameVsValueMap);
return objVsAttrNameVsValue;
}
}
System.out
.println("Could not find CustomizedModeledAttributesDelegate extends DefaultModeledAttributesDelegate");
return objVsAttrNameVsValue;
}
} // end class
2. The PTC provided custom system attributes are available out-of-the-box in the DefaultModeledAttributesDelegate. However, the site.xconf file (found in <Windchill>), can be changed to point to your customization service on the server:
◦ Use the path of your class in place of value of serviceClass (that is, replace com.ptc.windchill.uwgm.proesrv.c11n.DefaultModeledAttributesDelegate with the path to your class). For example:
<Service context="default"
name="com.ptc.windchill.uwgm.proesrv.c11n.ModeledAttributesDele
gate" targetFile=codebase/service.properties">
<Option cardinality="singleton"
requestor="java.lang.Object"
serviceClass="com.acme.download.CustomizedModeledAttributesDelegate"/>
</Service>
◦ Use the xconfmanager tool to apply the changes to service.properties file (run xconfmanager -p).
3. Restart the method server.