关于Windchill中简单的操作(对象的操作,客制化操作)

关于Windchill中简单的操作(对象的操作,客制化操作)

2023年8月1日发(作者:)

关于Windchill中简单的操作(对象的操作,客制化操作)Windchill10.1中常⽤的操作

⼀,操作对象。1, 根据零件名称/编号得到该零件 rtByName(name); rtByNumber(number);2, 根据WTPart得到WTPartMaster WTPartMasterwtmaster=(WTPartMster)ter();3, 获取codebase下配置⽂件ties属性信息WTPropertieswtproperties = alProperties();String wthome =perty("", ""); //codebase的⽂件夹路径4, 获取Part被借⽤的所有⽗部件 QueryResult qr=dByWTParts(WTPartMster wtMaster);5, 根据OID获取WTPartStringoid = "OR::3089789";ReferenceFactoryrefefence = new ReferenceFactory();Persistablepersistable = erence(oid).getObject(); WTpart part = null; if(persistable instanceof WTPart){ part = (WTPart)persistable; };6, 根据对象查询OIDWTPart part = new WTPart();ReferenceFactoryrefefence = new ReferenceFactory();String partOid = erenceString(part);7, 得到零件最新版本WTPart wtpart= (WTPart) estIteration(part);8, 查询⽤户某段时间内创建的零件QuerySpecqs = new QuerySpec();SearchCondition(newSearchCondition(,_TIMESTAMP,true,newAttributeRange(begintime删选条件时间范围内 And();//⼀定要加上 不然下⼀个条件不能删选 SearchCondition(newSearchCondition(,"",,PersistenceH删选条件QueryResult qr= (qs);9, 获取对象的IBA属性 Map map=null; IBAHolder ibaHolder=null; DefaultAttributeContainer dac=null;

ibaHolder=hAttributeContainerWithoutConstraints(part); dac=(DefaultAttributeContainer)ributeContainer(); AbstractValueViewvalueView[]=ributeValues(); if(!=0){ map=newHashMap(); for (int i = 0; i< ; i++) { AbstractValueViewavv = valueView[i]; StringIBAName=inition().getName(); StringIBAValue=((StringValueDefaultView)avv).getValue(); (IBAName,IBAValue); } }10,修改对象的名称 if(!e().equals(("TName"))) {//修改part的名称。 //propertyMap存储的⼀般属性的集合WTPartMasterIdentity((WTPartMaster)ter(),(String)("TName"),ber(),anization()); }11,获取对象的⼯作流实例 private static WfProcess getRelatedProcess(Persistable p) throws WTException{ WfProcess ret = null; QueryResult qrProcs=ociatedProcesses(p,_RUNNING, null); // 按时间排序,取最新⼀个 if(eElements()) { while (eElements()){ ret = (WfProcess) ement(); } } return ret; }12,重新启动⼀个对象的⼯作流 /** * 启动流程. * * @param newPBO * 流程对象 * @param wfTemplateName * 流程模板名称 * @param wfProcessName * 流程实例名称 * @return * @throws WTException * @throws InvocationTargetException * @throws RemoteException */ public static WfProcessstartWorkFlow(WTObject newPBO, String wfTemplateName, String wfProcessName) throwsWTException { if (!Flag) { StringsMethod = "startWorkFlow"; StringsClass = e(); Class[]types = newClass[] {,,}; Object[]values = newObject[] {newPBO, wfTemplateName, wfProcessName };

try { return (WfProcess)ault().invoke(sMethod, sClass, null, types, values); } catch (Exception e) { tackTrace(); throw new WTException(e); } }

long WORKFLOW_PRIORITY = 0; WfProcessret = null; boolean flag =essEnforced(false); try { WTPropertieswtproperties = alProperties(); WORKFLOW_PRIORITY= ong(perty("tWfProcessPriority","0"));

WTContainerRefcontainerRef = null; if (newPBO instanceof WTContained) { containerRef= ((WTContained) newPBO).getContainerReference(); }

WfProcessDefinitionprocessDefinition =cessDefinition(wfTemplateName,containerRef); ret= Process(processDefinition, null, containerRef); e(wfProcessName); // ority(WORKFLOW_PRIORITY);

ProcessDataprocessData = text(); ue(Y_BUSINESS_OBJECT,newPBO); // eCycleState(newPBO, // e(CmConstants.s)); // ret = (processData, true,tainerReference()); ret= rocessImmediate(ret, processData, WORKFLOW_PRIORITY); } catch (Throwable err) { tackTrace(); throw new WTException(err); } finally { essEnforced(flag); } return ret; }13,获取⼀个零件的BOM结构 private void querySub(WTPartpart,int i) throws WTException{ QueryResultqr = sWTPartMasters(part);//获得所有连接的WTPartUsageLink while(eElements()) { Objectobject = ement();//获得其中⼀个WTPartUsageLink if(object instanceof WTPartUsageLink) { WTPartUsageLinkusagelink = (WTPartUsageLink) object; WTPartMasterchildMaster = (WTPartMaster) s();//获得连接在该WTPartUsageLink下的WTPartMaster try{ QueryResultitqr = sionsOf(childMaster); //从给定的master查找所有版本。其结果是从最近⼀次到第⼀个创建的⼀组有序的版本 WTPartchildPart = null; if(()!=0){ childPart= (WTPart) ement(); } // if(childPart!=null){ // (childPart, i); // } if(sWTPartMasters(childPart).size()!=0){ querySub(childPart,i+1); } }catch (PersistenceException e) { tackTrace(); }catch (WTException e) { tackTrace(); }catch (IOException e) { tackTrace(); } } } }⼆, Windchill中简单的客制化1, 配置系统中不存在的⽣命周期状态名称和⾓⾊1, 找到src/wt/project或者src/wt/lifecycle⽬录。2, 复制或者⾄wtCustom/wt/project或lifecycle⽬录。3, 修改复制过来的⽂件。4, 使⽤Resourcesbuild+⽬录名+⽂件名(不要后缀)+true。5, 使⽤ ant –f codebase/。6, 重启服务,完成添加。

2, 添加操作栏中的操作1, 在你指定的页⾯的地址栏中输⼊&jcaDebug=1,点击操作的那个七星瓢⾍。2, 找到配置该操作的,并且找到配置该操作栏的models,将该models全部复制过来,复制到中,配置你⾃⼰的action。3, 值得注意的是这⾥需要配置两个资源⽂件(⼀个本地的和⼀个常规的)格式如下:本地的(这⾥只演⽰中⽂状态下,其它状态类似) y;;ResourceBundle;

@RBUUID("ctionLableResourceRB")public class StartActionLableResourceRB_zh_CN extends WTListResourceBundle { @RBEntry("你配置的操作名称") public static final String

STARTACTION_DEMO_TITLE= ""; @RBEntry("你配置的操作名称") public static final String

STARTACTION_DEMO_DESCRIPTION= "ption";

@RBEntry("你配置的操作名称") public static final String

STARTACTION_DEMO_TOOLTIP= "p";}常规的:import y;import ;import ResourceBundle;

@RBUUID("ctionLableResourceRB")public classStartActionLableResourceRB extends WTListResourceBundle { @RBEntry("这⾥是你配置操作的英⽂状态下的名称") public static final String

STARTACTION_DEMO_TITLE="";

@RBEntry("这⾥是你配置操作的英⽂状态下的名称") public static final String

STARTACTION_DEMO_DESCRIPTION="ption";

@RBEntry("这⾥是你配置操作的英⽂状态下的名称") public static final String

STARTACTION_DEMO_TOOLTIP="p";

}

注:注意⼀些细节问题,把这两个类的class⽂件拷贝到codebase⽬录下解析:public static final String

STARTACTION_DEMO_TITLE ="";StartAction:你在中配置action的中的type属性值demo:你在中配置action的中的name属性值.4, 接下来配置⽂件,下⾯是中的配置 下⾯是中的配置

解析:对⽐两个⽂件的配置:1, 对于⽂件中的配置最外层的objecttype标签 name属性值与⽂件中配置action的type相对应,class的属性值与你配置在哪个对象下的class名称(⽐如:””);resourceBudle的属性值便是你⾃⼰编写的哪个常规的资源⽂件的名称(包名+类名)。2, ⽂件中的配置内层的action标签 name属性值与你在⽂件中配置action的name相对应。3, ⽂件中的配置内层的action标签中的command标签就是你要执⾏的操作,这⾥配置的是打开⼀个jsp页⾯,其中windowType就是打开⽅式他有”popup”和”page”两种,第⼀种就是打开⼀个新的窗⼝,第⼆种就是在本页⾯上打开。url显然就是你的jsp⽂件的路径。4, ⽂件中的配置内层的action标签中的includeFilter标签顾名思义就是⼀些过滤的操作,就⽐如⼀个编辑⼀个合同号,就得在该对象的状态是已发布才可以进⾏编辑,否则就不可以编辑,这时就要通过这个过滤来控制,⼀个action可以有多个过滤操作。(这部分会在接下来讲解,⼩伙⼦们不要急)。5, 刚刚开始的时候请把includeFilter标签去掉,先来测试看能不能打开你配置的jsp界⾯。

发布者:admin,转转请注明出处:http://www.yc00.com/web/1690873040a451980.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信