7.Windchill -- 抓取指定部件的属性

  1. 在如下目录结构中创建一个测试类
    在这里插入图片描述
  2. 测试类代码如下
//测试类要实现 RemoteAccess 接口才能使用 Windchill 系统的类和方法               

public class TestPart implements Serializable, RemoteAccess {
    private static final long serialVersionUID = -3357315878052833848L;

    public static void main(String[] args) throws Exception {
        if (!RemoteMethodServer.ServerFlag) {
            Class[] cls = {String[].class};
            Object[] obj = {args};
            try {
                RemoteMethodServer.getDefault().invoke("main",
                        TestPart.class.getName(), null, cls, obj);
            } catch (RemoteException | InvocationTargetException e) {
                e.printStackTrace();
            }
            return;
        }
        //windchill ext.plm.test.TestPart
        /**
         * ext.plm.test.TestPart -- 测试类的路径
         *
         * 使用 Windchill Shell 输入指令:windchill ext.plm.test.TestPart 部件ID
         * 就能执行该测试类的main方法,并将部件ID作为参数传进来,然后执行下面两条代码,将结果输出到 Windchill Shell 的窗口中
         */
        WTPart part = CtPartUtil.getPartByNumber(args[0]);
        System.out.println(">>>>>>>" + part.getNumber());
        System.out.println(">>>>>>>" + part.getName());
        System.out.println(">>>>>>>" + part.getViewName());
        System.out.println(">>>>>>>" + part.getView());
        System.out.println(">>>>>>>" + part.getIdentity());
        System.out.println(">>>>>>>" + part.getAuthoringLanguage());
        System.out.println(">>>>>>>" + part.getFlexTypeIdPath());
        System.out.println(">>>>>>>" + part.getOrganizationUniqueIdentifier());
        System.out.println(">>>>>>>" + part.getFolderPath());
        System.out.println(">>>>>>>" + part.getCabinetName());
    }
}
  1. 编译该测试类,编译后的文件会自动映射到 Windchill 系统中的 codebase 目录(codebase 目录相当于 idea 项目中的 src 目录)下,不行就手动将代码粘贴到 Windchill 系统中的 codebase目录下,路径为:D:\ptc\Windchill_11.0\Windchill\codebase
  2. 重启 Windchill 系统
  3. 在 Windchill Shell 中输入指令 – windchill ext.plm.test.TestPart 部件ID
    就能执行该测试类的main方法,并将部件ID作为参数传进去,将结果输出到 Windchill Shell 的窗口中
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值