Windchill二次开发常用API

2026/4/23 17:12:27

1. 1.根据零件名称/编码 得到该零件

2. wt.clients.prodmgmt.WTPartHelper.findPartByName(name) ; 3. wt.clients.prodmgmt.WTPartHelper.findPartByNumber(number); 4. 2.根据WTpart得到WTparMaster 5. WtPart wtpart;

6. WTPartMaster wtmaster=(WTPartMster)part.getMaster(); 7. 3.获取codebase下配置文件wt.properties属性信息

8. WTProperties wtproperties = WTProperties.getLocalProperties(); 9. String wthome = wtproperties.getProperty(\

//codebase的文件夹路径 10. 11.

4.获取part被借用的所有父部件 QueryResult qr=

wt.part.WTPartHelper.service.getUsedByWTParts(WTPartMster wtMaster); 12.

注:此方法得到的结果为该part被使用情况的全部父部件,包括了Design视图及Manufacturing视图 更包括了父部件使用part的所有修订版本,打印出来可以看到会有相同的部件编号,不同的修订版本. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24.

5.根据OID 获取Wtpart

wt.fc.WTReference partRef = new WTPart wtpart=(WTPart)partRef; 6.得到零件最新版本

WTPart wtpart= (WTPart) 7.通过过滤得到零件最新版本

QuerySpec querysearch = new QuerySpec(WTPartMaster.class); //查询所有的WTPartMaster QueryResult queryresult =

LatestConfigSpec latestconfigspec = new LatestConfigSpec(); //根据WTPartMaster查询所有最新版本的零部件 QueryResult allWTPart =

wt.fc.ReferenceFactory().getReference( oid );

VersionControlHelper.getLatestIteration(part);

PersistenceHelper.manager.find(querysearch);

ConfigHelper.service.filteredIterationsOf(queryresult,latestconfigspec) 25. 26. 27.

8.查询某用户某段时间范围内创建的零件

QuerySpec qs = new QuerySpec(WTPart.class); qs.appendSearchCondition(new

SearchCondition(WTPart.class,WTPart.CREATE_TIMESTAMP, true, new AttributeRange(begintime, endtime)));//删选条件 时间范围内 28. 29.

qs.appendAnd();//一定要加上 不然下一个条件不能删选

qs.appendSearchCondition(new SearchCondition(WTPart.class,

30. \

SearchCondition.EQUAL,PersistenceHelper.getObjectIdentifier(name)));//删选条件 用户 31. 32.

QueryResult qr = PersistenceHelper.manager.find(qs); //今后持续更新

1.根据零件名称/编码 得到该零件 wt.clients.prodmgmt.WTPartHelper.findPartByName wt.clients.prodmgmt.WTPartHelper.findPartByNumb2.根据WTpart得到WTparMaster WtPart wtpart; WTPartMaster wtmaster=(WTPartMster)part.getMaste3.获取codebase下配置文件wt.properties属性信息 WTProperties wtproperties = WTProperties.getLoca String wthome = wtproperties.getProperty(\4.获取part被借用的所有父部件 QueryResult qr= wt.part.WTPartHelper.service.ge 注:此方法得到的结果为该part被使用情况的全部父部件,5.根据OID 获取Wtpart wt.fc.WTReference partRef = new wt.fc.ReferenceFa WTPart wtpart=(WTPart)partRef;6.得到零件最新版本 WTPart wtpart= (WTPart) VersionControlHelper.get7.通过过滤得到零件最新版本 /** * 根据用户名得到用户 * @param name 用户名 * @throws WTException * return WTUser */ public static WTUser getUserFromName(String name) throws WTException { Enumeration enumUser = OrganizationServicesHelper.manager.findUser(WTUser.NAME, name); WTUser user = null; if (enumUser.hasMoreElements()) user = (WTUser) enumUser.nextElement(); if (user == null) { enumUser = OrganizationServicesHelper.manager.findUser(WTUser.FULL_NAME, name); if (enumUser.hasMoreElements()) user = (WTUser) enumUser.nextElement(); }

if (user == null) {

throw new WTException(\系统中不存在用户名为'\的用户!\ }

return user; } }

10.windchill 中查询,高级查询,基本查询 QuerySpec qs = new QuerySpec();//构造

Int index = qs.appendClassList(WTPart.class,true);//添加查询类型,获取类型索引,第2个参数表示“要查询的类型、表”

WhereExpression where = new SearchCondition(WTPart.class, WTPart.xx, “=”, xx);//泛型在WC API中的使用

//获取查询条件数目

If(qs.getConditionCount()>0 && qs.getWhere().endsWith(“\ {

qs.appendAnd(); }

//添加查询条件

qs.appendWhere(where, new int[]{index});

//** 以下是联合查询的API范例。LINK关系//ROLEA、ROLEB的INDEX被使用到。 int linkIndex = qs.appendClassList(XXLink.class, false); qs.appendJoin(linkIndex, xxLink.RoleA, index_A); qs.appendJoin(linkIndex, xxLink.RoleB, index_B);

//添加“生命周期”查询条件

LifeCycleConfigSpec lcsp = new LifeCycleConfigSpec(); lcsp.setLifeCycleState(State.toState(state)); qs = lcsp.appendSearchCriteria(qs); //执行查询

QueryResult qr = PersistenceHelper.manager.find(qs); //过滤出最新小版本

LatestConfigSpec lcs = new LatestConfigSpec(); qr = lcs.process(qr); /**

* 根据WTPartMaster对象获得最新的WTPart * @param partmaster WTPartMaster对象 * @return 最新的WTPart * @throws WTException */

public static WTPart getLastPart(WTPartMaster partmaster) throws WTException{ WTPart part=null; if(partmaster==null){ return part; }

ConfigSpec configSpec=ConfigHelper.service.getDefaultConfigSpecFor(WTPart.class); QueryResult qr=ConfigHelper.service.filteredIterationsOf(partmaster, configSpec); if(qr!=null){

while(qr.hasMoreElements()){ part=(WTPart) qr.nextElement(); } }

return part; }


Windchill二次开发常用API.doc 将本文的Word文档下载到电脑
搜索更多关于: Windchill二次开发常用API 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219