cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Create a soft ECN from a soft ECR?

sdrzewiczewski
7-Bedrock

Create a soft ECN from a soft ECR?

I want to have a soft type ECR when it hits a certain state to auto-create a soft type ECN. Has anybody done anything similar to this? Any pointers would be appreciated.

6 REPLIES 6

I have, Here's how. This may not be the only way to do it but it works effectively. You pass in your soft type's logical identifier as the "cnType" parameter.

public static WTChangeOrder2 createECN(WTChangeRequest2 request, String cnType) {
if(cnType == null) cnType = "wt.change2.WTChangeOrder2";
WTChangeOrder2 retObj = null;
try {
// Set the creator
wt.session.SessionMgr.setPrincipal(request.getCreator().getName());

Task createECNTask = new Task("/custom/createChangeOrder.xml");

Vector processors = new Vector();
processors.add(wt.util.WTProperties.getLocalProperties().getProperty("wt.federation.ie.VMName"));
createECNTask.setProcessors(processors);

createECNTask.setUsername(request.getCreator().getName());
createECNTask.setParam("title", "CO-" + request.getNumber() + "-" + request.getName() + " Implementation");
createECNTask.setParam("containerObid", " + request.getContainer().getPersistInfo().getObjectIdentifier());
createECNTask.setParam("obid", " + request);
createECNTask.setParam("type", cnType);
createECNTask.invoke();

Group returnGroup = createECNTask.getGroup("changeOrder");
String obid = (String) returnGroup.getAttributeValue(0, "obid");

Persistable pers = DocumentUtility.getObjectFromObid(obid);
if(pers instanceof WTChangeOrder2) retObj = (WTChangeOrder2) pers;
} catch (WTException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
} catch (IEException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return retObj;
}

And if you need it, here's DocumentUtility.getObjectFromObid()

public static Persistable getObjectFromObid(String obid) throws WTException {
if (obid.indexOf("@") > -1) {
String[] obidParts = obid.split(":");
if (obidParts.length > 3) {
obid = obidParts[0] + ":" + obidParts[1] + ":" + obidParts[2];
}
}
ReferenceFactory rf = new ReferenceFactory();
WTReference ref = rf.getReference(obid);
return ref.getObject();
}

And finally here's the createChangeOrder.xml task:
<%@page language="java"%>
<%@taglib uri=" prefix="ie"%>
<%
String windchill = wt.util.WTProperties.getLocalProperties().getProperty("wt.federation.ie.VMName");
String title = (String) getContextGroup("FORM").getAttributeValue(0, "title");
String desc = (String) getContextGroup("FORM").getAttributeValue(0, "desc");
String obid = (String) getContextGroup("FORM").getAttributeValue(0, "obid");
String containerObid = (String) getContextGroup("FORM").getAttributeValue(0, "containerObid");
String type = (String) getContextGroup("FORM").getAttributeValue(0, "type");
if(type == null) type = "WTChangeOrder2";
if(desc == null) desc = title;
if(title.length() > 70) title = title.substring(0, 70);
%>

<ie:webject name="Query-Objects" type="OBJ">
<ie:param name="INSTANCE" data="&lt;%=" windchill=" %=">"/>
<ie:param name="ATTRIBUTE" data="name,obid" delim=","/">
<ie:param name="GROUP_OUT" data="container"/">
<ie:param name="OBJECT_REF" data="&lt;%=" containerobid=" %=">" />
<ie:param name="AUTHORIZATION" data="${@server[]authorization[0]}"/">
<ie:param name="TYPE" data="wt.inf.container.WTContainer"/">
<ie:param name="SESSION_ID" data="${session[]SESSION_ID[0]}"/">
</ie:webject>
<ie:webject name="Create-Objects" type="ACT">
<ie:param name="INSTANCE" data="&lt;%=" windchill=" %=">"/>
<ie:param name="ATTRIBUTE" data="name,obid" delim=","/">
<ie:param name="GROUP_OUT" data="changeOrder"/">
<ie:param name="AUTHORIZATION" data="${@server[]authorization[0]}"/">
<ie:param name="TYPE" data="&lt;%=" type=" %=">"/>
<ie:param name="CONTAINER_REF" data="${container[0]obid[0]}"/>
<ie:param name="FIELD" data="name='&lt;%=title" %=">" />
<ie:param name="FIELD" data="description='&lt;%=desc" %=">" />
</ie:webject>
<ie:webject name="Create-Links" type="OBJ">
<ie:param name="INSTANCE" data="&lt;%=" windchill=" %=">"/>
<ie:param name="FROM_OBJECT_REF" data="&lt;%=obid" %=">" />
<ie:param name="GROUP_IN" data="changeOrder"/>
<ie:param name="AUTHORIZATION" data="${@server[]authorization[0]}"/">
<ie:param name="CONTAINER_REF" data="${container[0]obid[0]}"/>
<ie:param name="TYPE" data="wt.change2.AddressedBy2"/">
</ie:webject>
<ie:webject name="Return-Groups" type="GRP">
<ie:param name="GROUP_IN" data="*"/">
</ie:webject>


Now, I'm sure there's a way to do this directly through the API without the webject, but this works effectively without spending a decade trying to understand Windchill's poorly documented API.

-Thomas R. Busch
Sr. Software Developer
Stryker Instruments
(269) 323-7700 x4014
tom.busch@stryker.com<">mailto:tom.busch@stryker.com>

I'm editing some of my Pro/E config.pro settings to work within my
PDMLink environment. For example, I was able to change the designation
of my start part by changing



template_solidpart P:\u\form\pro\startprt.prt

to

template_solidpart
wtpub://windchill.toro.com/Libraries/Standards/startprt.prt



However, the pro_format_dir setting (to know where to get the drawing
formats from) doesn't seem to working. I've changed



pro_format_dir P:\u\form\pro

to

pro_format_dir wtpub://windchill.toro.com/Libraries/Standards



I've followed what was shown in the "Using Pro/ENGINEER with Windchill"
guide, but when I go to apply a drawing format to a new drawing, it
doesn't find my formats, it instead browses me to the default format
("System Formats") directory.



Thanks, John

This electronic message including any attachments ("Message") may contain information that is privileged, confidential and/or exempt from disclosure under trade secret and other applicable law. If you are not the intended recipient, notify the sender immediately, permanently delete all copies of this Message, and be aware that examination, use, dissemination, duplication or disclosure of this Message is strictly prohibited.

We've always used the server name, not the address.

For example our Windchill server name is: TMC Windchill so the config option would be:

pro_format_dir wtpub://TMC Windchill/Libraries/CAD Standards

Thank you to everyone for your responses. I've got it working now. The
trick was that when I define my server in Pro/E (Tools -> Server
Manager), the "Name" that I give the server has to match the URL of the
server, which in my case say is windchill.toro.com. I had been just
giving a random name such as "Test", or "Windchill" or "WC" when I
registered the server in Pro/E.



Thanks, John





#####################

John Mattson

Principal Systems Engineer

The Toro Company

Bloomington, MN 55420

(952) 887-8603

-










This has been a problem for us when we've replaced server hardware. Would like to know how to use an alias rather than the actual machine name if possible. Without being able to do this, one has to power down the old hardware before bring up the new.

This looks very nice and easy to understand, even for me! If I have any
questions I'll let you know.



One thing I have done in my few info*engine task is to create a
get-properties webject for the VMName, and then pass that in to the
other webjects instance value



<ie:webject name="Get-Properties" type="MGT">

<ie:param name="AUTHORIZATION" data="${@SERVER[]authorization[]}"/">

<ie:param name="ATTRIBUTE" data="wt.federation.ie.VMName"/">

<ie:param name="GROUP_OUT" data="properties"/">

</ie:webject>



<ie:webject name="Update-Objects" type="ACT">

<ie:param name="INSTANCE"&lt;br"/>data="${properties[0]wt.federation.ie.VMName[0]}" valueSeparator=";"
delim=";" />

.

.

.

.






Announcements


Top Tags