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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

WTPart Number Driven by CAD Attribute

pwilliams-3
11-Garnet

WTPart Number Driven by CAD Attribute

Is it possible to have the WTPart Number equal an attribute from the cad doc? Can this be configured in the OIR for the part?

Thanks,
Patrick Williams
2 REPLIES 2

Hey Patrick,


I think you are looking for the preference Operations\Auto Associate\Auto Associate Numbering Parameter.


-Vaughn

AL_ANDERSON
5-Regular Member
(To:pwilliams-3)

Patrick and PTC Users:

Our use case is somewhat different, but the same techniques could be used.
We needed to keep a CAD doc designated parameter for part number (IBA)
equal to it's Windchill file name after applying some rules, and it's name
equal to the WTPart name. And while making no assumptions about which
gets created first and allowing for all possible events that could throw
things out of sync (Save-As, Renames, Revisions, Uploads, Checkins,....),
an OIR wouldn't handle those all those cases, so we created a service in
which the listener gets notified to check and update the CAD doc values
whenever needed.

Here's the slide from the PPT for what's happening (I had to take out some
graphics of our drawings)...




Here's some of the listener registration code...
//
// For existing documents
// Add event listener using
ServiceEventListenerAdapter and override the notify method for POST_MODIFY
events
//
getManagerService().addEventListener(
new ServiceEventListenerAdapter(this
.getConceptualClassname()) {
public void notifyVetoableEvent(Object event)
throws WTException {
Object targetObject =
((PersistenceManagerEvent)event).getEventTarget();

if ( targetObject instanceof EPMDocument )
{
// Upload of EPMDocument, or
checkin of plus modified EPMDocument, or name change on WTPartMaster
ParamUpdater.updateEPMDocument( (WTObject)
targetObject, ParamUpdater.Event.UPLOAD_OR_CHECKIN );
} else if ( targetObject instanceof
WTPartMaster ) {
ParamUpdater.updateEPMDocument(
(WTObject) targetObject, ParamUpdater.Event.MODIFIED_WTPART );
} else if ( targetObject instanceof
EPMDocumentMaster ) {
ParamUpdater.updateEPMDocument(
(WTObject) targetObject, ParamUpdater.Event.RENAME);
}
}
},
PersistenceManagerEvent.generateEventKey
(PersistenceManagerEvent.POST_MODIFY) // triggers when saved,
uploaded, checkin
);

//
// For new EPMDocuments
// Add event listener using
ServiceEventListenerAdapter and override the notify method for POST_STORE
events
//
getManagerService().addEventListener(
new ServiceEventListenerAdapter(this
.getConceptualClassname()) {
public void notifyVetoableEvent(Object event)
throws WTException {
Object targetObject =
((PersistenceManagerEvent)event).getEventTarget();

if ( targetObject instanceof EPMDocument
&&
WorkInProgressHelper.isCheckedOut(
(EPMDocument)targetObject ) == false ) {
//
// A commonspace
"save as" and not a checkout
//`
ParamUpdater.updateEPMDocument( (WTObject)
targetObject, ParamUpdater.Event.SAVE_AS );
} else if ( targetObject instanceof
WTPartMaster ) {
ParamUpdater.updateEPMDocument( (WTObject)
targetObject, ParamUpdater.Event.NEW_WTPART );
}
}
},
PersistenceManagerEvent.generateEventKey
(PersistenceManagerEvent.POST_STORE) // triggers when new objects
stored
);


The name Identity update code...

public static boolean updateEPMDocument( WTObject object,
Event event ) {
.
.
.
try {
SessionHelper.manager.setAdministrator();

//
// Update Name Identity
//
EPMDocumentMasterIdentity master_identity
=
(EPMDocumentMasterIdentity) epmDocMaster.getIdentificationObject();
master_identity.setName(newName);
epmDocMaster = (EPMDocumentMaster)
IdentityHelper.service.changeIdentity(epmDocMaster, master_identity);
epmDocMaster = (EPMDocumentMaster)
PersistenceHelper.manager.save(epmDocMaster);
epmDocMaster = (EPMDocumentMaster)
PersistenceHelper.manager.refresh(epmDocMaster);

} catch (Exception e) {
CADLogger.severe("Name update failed for "
+
epmDocMaster.getNumber() + ", currentName= [" +
currentName + "] newName=[" + newName + "]");
} finally {
SessionContext.setContext(prev);
}
.
.
.
}

Al Anderson






Top Tags