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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Translate the entire conversation x

Q: How to change a CAD Document Number

kimndave9
1-Visitor

Q: How to change a CAD Document Number


Surely this is possible - changing a CAD Document Number.

If you have done so, please share.

Dave S.

2 REPLIES 2

I've done this before using this home-brewed method:

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

Sorry, ctrl+enter fail.

This is the method I was referring to:
/**
* Renames and/or renumbers a document.
* - If object is RevisionControlled, this affects the MASTER (which means ALL version are affected).
* - The Mastered or the Identified object must have a setName() and setNumber() in order to actually
* update the name and number. If the method does not exist, a warning will be displayed with a
* stack trace, and the method will continue anyway.
* @param pers - the object to rename/renumber. Should support any RevisionControlled or Identified
* implementation/subclass.
* @param newName - The desired target name. If null, defaults to match current name.
* @param newNumber - The desired target number. If null, defaults to match the current Number.
*
* @throws WTException
* @throws ObjectNoLongerExistsException
*/
public static void changeIdentity(Persistable pers, String newName,
String newNumber) throws WTException, ObjectNoLongerExistsException {

Identified id = null;

if(pers instanceof RevisionControlled) {
RevisionControlled rc = (RevisionControlled) pers;
pers = rc.getMaster();
}
id = (Identified) pers;

IdentificationObject idObj = id.getIdentificationObject();

// Look for the setName method (using reflection because we don't know which subclass it may be
// and it's not part of the interface)
try {
Method setName = idObj.getClass().getMethod("setName", new Class[]{String.class});
setName.invoke(idObj, new Object[]{newName});
} catch (SecurityException e) {
log.error(e.getMessage(), e);
} catch (IllegalArgumentException e) {
log.error(e.getMessage(), e);
} catch (NoSuchMethodException e) {
log.error(e.getMessage(), e);
} catch (IllegalAccessException e) {
log.error(e.getMessage(), e);
} catch (InvocationTargetException e) {
log.error(e.getMessage(), e);
}

// Look for the setNumber method (using reflection because we don't know which subclass it may be
// and it's not part of the interface)
try {
Method setNumber = idObj.getClass().getMethod("setNumber", new Class[]{String.class});
setNumber.invoke(idObj, new Object[]{newNumber});
} catch (SecurityException e) {
log.error(e.getMessage(), e);
} catch (IllegalArgumentException e) {
log.error(e.getMessage(), e);
} catch (NoSuchMethodException e) {
log.error(e.getMessage(), e);
} catch (IllegalAccessException e) {
log.error(e.getMessage(), e);
} catch (InvocationTargetException e) {
log.error(e.getMessage(), e);
}

id = IdentityHelper.service.changeIdentity(id, idObj);
pers = PersistenceHelper.manager.refresh(pers, true, true);
}

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