編輯委派 (SOLIDWORKS)
現成的委派
Windchill 提供了可將 CAD 文件相關的其他資訊作為自訂系統參數進行傳遞的現成機制。
欲自訂參數,請在網站層級設定伺服器端偏好設定「Workgroup Manager 用戶端」 > 「對應自訂系統屬性與檔案內容」
值是與 CAD 文件相關之物件中其他屬性的清單,這些屬性會在 CAD 工具中顯示為參數或內容。
值是 CAD 內容與 Windchill 屬性對的逗號分隔清單,格式如下:
<name_of_CAD_property>:<relatedObjectCode>.<WindchillAttributeName>
其中:
描述
可能的值
name_of_CAD_property
這是 CAD 工具中參數或內容的名稱
PART_REVISION
relatedObjectCode
這是用來識別相關物件的字串
docMaster
associatedPart
relatedECN
promote
WindchillAttributeName
這是 Windchill 中相關物件屬性的邏輯名稱或內部名稱
CAD 文件主物件中的可變類型屬性
零件屬性
類型為「布林值」、「日期」、「整數」、「實數」、「具有單位的實數」或「字串」之相關零件的可變類型屬性
lifeCycleState
lifecycleTemplate.name
name
number
orgid
view.identity
partType
針對相關 ECN
number
orgid
resolutionDate
針對推進
number
promotionDate
orgid
approvers
approveDates
reviewers
reviewDates
* 
針對可變類型屬性,傳送至 CAD 工具的值是在物件「資訊頁」中看到的顯示值。顯示值使用「屬性處理」偏好設定與「類型及屬性」設定,但不支援使用資料公用程式進行彩現的複雜顯示自訂。
僅在沒有可用來插入參數的自訂伺服器端委派 CustomModeledAttributesDelegate 時,才能使用此功能 (請參閱接下來「自訂委派」部份的內容)。
針對關聯零件:
此功能支援具有「擁有者」、「提供圖像」、「圖像」及「提供內容」的「CAD 文件」相關零件。
所選零件版本與「CAD 文件」的資訊頁相關零件表類似。
如果相同零件的多個版本修訂與「CAD 文件」相關,會傳回每個零件的最新版本修訂。
如果將系統配置為允許多個版次關聯,且伺服器端偏好設定「作業」 > 「自動關聯」 > 「允許 CAD 文件建立多個零件」設定為,則可以傳回多個零件。在此情況下,會以分隔格式傳回每個相關零件的資訊。使用的分隔符號由伺服器端偏好設定「Workgroup Manager 用戶端」 > 「多個相關物件的自訂系統屬性分隔符號」定義。
針對相關 ECN:
如果「CAD 文件」的版本修訂作為「產生物件」參與「變更通知」,則會將有關 ECN 的屬性傳送至 CAD 參數。
如果「CAD 文件」版本修訂參與多個「變更通知」,則使用的分隔符號由伺服器端偏好設定「Workgroup Manager 用戶端」 > 「多個相關物件的自訂系統屬性分隔符號」定義。
不會列出已拒絕的 ECN。
針對「推進請求」:
當「CAD 文件」版本參與「推進請求」時,會將有關「推進請求」的屬性傳送至 CAD 參數。
如果「CAD 文件」版本參與多個「推進請求」,則使用的分隔符號由伺服器端偏好設定「Workgroup Manager 用戶端」 > 「多個相關物件的自訂系統屬性分隔符號」定義。
不會列出已拒絕的「推進請求」。
自訂委派
Windchill 提供伺服器端委派,在下載時可用來將參數插入 SOLIDWORKS 零件。可以使用此機制從伺服器將資訊傳送到 SOLIDWORKS,在此可以像任何其他 SOLIDWORKS 參數一樣使用 (例如將資訊放在工程圖表單上)。以 PTCPROI 開頭的參數被視為保留的系統參數,不能透過自訂來傳播。若將它們新增到自訂中,下載服務會予以忽略。
* 
如果您將系統配置為使用自訂委派,則不會使用在伺服器端偏好設定「Workgroup Manager 用戶端」 > 「對應自訂系統屬性與檔案內容」中定義的屬性。只有 PTC 委派會檢查該偏好設定。
下載時會將自訂參數提供給用戶端,但不會在執行 Windchill 作業 (例如入庫) 之後在 CAD 應用程式工作階段中更新它們。例如,如果將自訂參數的值指派為 CAD 文件編號,則在下載時會將其值提供給用戶端。如果稍後 CAD 文件重新編號,就不會自動更新 SOLIDWORKS 工作階段或用戶端快取中的值。可以使用 Windchill 服務委派機制來進行自訂。
下列步驟解釋自訂流程:
1. 在不同於 PTC 類別的客戶特定位置 (例如 <WT_HOME>\com\acme) 中建立實行介面 ModeledAttributesDelegate 的 Java 類別。介面定義如下:
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. PTC 提供的自訂系統屬性預設可在 DefaultModeledAttributesDelegate 中找到。但是,site.xconf 檔案 (位於 <Windchill> 中) 可變更為指向伺服器中的自訂服務:
使用類別路徑取代 com.ptc.windchill.uwgm.proesrv.c11n.DefaultModeledAttributesDelegate 的值 (也就是使用類別的路徑來取代 serviceClass)。例如:
<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>
使用 xconfmanager 工具將變更套用至 service.properties 檔案 (執行 xconfmanager -p)。
3. 重新啟動應用伺服器。
這是否有幫助?