Winchill 获取发布结构子对象WTPart

String oid1="OR:wt.part.WTPart:261597138";
        WTPart part=(WTPart)GenericUtil.REF_FACTORY.getReference(oid1).getObject();
        out.print(part.getIdentity()+"<br/>");
        QueryResult qr=WTPartHelper.service.getUsesWTParts(part, GenericUtil.LATEST_CONFIG_SPEC);
        out.print(qr.size()+"<br/>");
        while(qr.hasMoreElements()){        
            Persistable[] p=(Persistable[])qr.nextElement();
            out.print(p[1].getIdentity()+"<br/>");

        }

红色字体需注意:

通常我们会用Persistable p=(Persistable)qr.nextElement();去接受参数,此时系统会报错,显示如下:

Persistable[] p=(Persistable[])qr.nextElement();数组接收显示成功,进一步打印数组内容:

数组第二个为我们要获取的WTPart对象。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章