private TCComponentItem createOperation(String itemName,String itemType) { //obejct_name itemType try { TCSession session = (TCSession)AIFUtility.getCurrentApplication().getSession(); TCComponentItemType typeComponent =(TCComponentItemType) session.getTypeComponent(itemType); String itemId = typeComponent.getNewID(); TCComponentItem create = typeComponent.create(itemId, null, itemType, itemName, "", null); TCComponentForm tcForm = BaseUtils.getTCForm(create); //获取ItemRevision表单 BaseUtils.getTCForm 自行封装 tcForm.setProperty("y2_SerialNum", itemId); //设置部分属性 SimpleDateFormat sdf = session.askTCDateFormat(); //获取日期格式化 tcForm.setProperty("y2_CreateDate",sdf.format(new Date())); tcForm.save(); //save to folder InterfaceAIFComponent targetComponent = AIFUtility.getTargetComponent(); TCComponentFolder folder = null; if(targetComponent instanceof TCComponentFolder) { folder =(TCComponentFolder)targetComponent; folder.add("contents", create); }else { TCComponentUser user = session.getUser(); folder = user.getNewStuffFolder(); folder.add("contents", create); }return create; } catch (TCException e) { e.printStackTrace(); return null; } }
标签:RAC,create,Item,Teamcenter,session,folder,null,tcForm,itemType From: https://www.cnblogs.com/paylove/p/17706340.html