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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Create a folder automatically Windchill 10.1

ptc-4995365
1-Visitor

Create a folder automatically Windchill 10.1

Hi,



There is a way to automatically create a folder in a product if this isn't exist?, by customization or configuration.



Thanks for the info that can provide me

3 REPLIES 3
avillanueva
22-Sapphire II
(To:ptc-4995365)

Are you talking about a load file? That can be done. Customization sure, that should be easy. There is an API for that. What is the trigger for creating a folder?
gnatesan
4-Participant
(To:ptc-4995365)

The below code snippet helps your requirement...little modification is
required.


public static void creatDirectory(String array[], WTContainerRef
containerRef){


String path = ((WTContainer)
containerRef.getObject()).getDefaultCabinet().getFolderPath();

if(array != null){
int len = array.length;

Folder folder = null;

for(int i = 0; i < len; i++){

try {

folder = FolderHelper.service.getFolder(path, containerRef);

path = path + '/' + array[i];

QueryResult result = FolderHelper.service.findSubFolders(folder);


if(!checkFolder(result,array[i])){

FolderHelper.service.createSubFolder(path, containerRef);
}


} catch (WTException e) {

e.printStackTrace();

} } } }


public static boolean checkFolder(QueryResult result, String str){

if(result == null){
return false;
}
while(result.hasMoreElements()){

Object object = result.nextElement();

if(object instanceof SubFolder){

SubFolder subfolder = (SubFolder)object;

if(subfolder.getName().equals(str)){

return true;

}

}
else{
return false;
}

}

return false;
}




Antonio:


The trigger is a process for upload a bunch of documents, already a customization, but if this process does not find the folder throws the document in the root folder, i'm looking for a way to improve it.



Gangadharan:


thanks for the answer, i will try your script

Announcements


Top Tags