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

List the files from all workspaces in Windchill using Jlink

Highlighted
Level 6

List the files from all workspaces in Windchill using Jlink

How to list the files from the other workspaces (i.e. from all the Workspaces which are not loaded in the session) from windchill using JLink?

2 REPLIES 2

Re: List the files from all workspaces in Windchill using Jlink

When you are registered to Windchill  in this case, so far I know , you can list objects using some construct like this below:

 

 

 

   public static void test_list()

   {

// will find all objects in WS

 

/***IlinkUser

http://ilinkuser-training.ptc.com:80/ilinkuser/

wtws://IlinkUser/TEST/drw0001.drw

wtws://IlinkUser/TEST/top.prt **/

 
String aliasedURLPath = "wtws://" + host + "/" + workspace_name + "/";
try {
 stringseq FileList = pfcGlobal.GetProESession().ListFiles ("*.*",FileListOpt.FILE_LIST_ALL,aliasedURLPath);
  int num_file = FileList.getarraysize ();
  MsgBox msg1 = new MsgBox(null,"arraysize"," FileList num  ="+ num_file + "  aliasedURLPath = " +  aliasedURLPath );
   msg1.show();
  Log.write("=======================================");
 for(int i =0 ; i< num_file;i++)
  Log.write("NUM:<" + i +">  NAME = " + FileList.get(i));
 Log.write("=======================================");

        }
     catch (jxthrowable x)
     {
       Log.write("Error catched " + x);
       x.printStackTrace();
     }
}

So but you need here the host and the workspace names

So to mange it  you can try the following steps:

1.)The method pfcSession.BaseSession.ListServers returns a list of
servers registered in this session.

2.) for each server you can use GetAlias method to get the server alias

3.) for each server you can get / or cast to the extended Interface Serverlocation and get the method CollectWorkspaces() . This call will return a list of the WorkspaceDefinitions:

The interfacepfcServer.WorkspaceDefinition contains the name and context of the workspace. The method pfcServer.ServerLocation.CollectWorkspaces returns an array of all workspaces / additionally to the current registered workspace

4.) for each workspace definition you can call the method GetWorkspaceName()

5.) I am not sure if this step is required but want to mention it - so here you need to register each server form the list (in steps 1. and 2.)using at least one o fthe workspaces from the workspace list - here the api -> BaseSession::RegisterServer 

6.) call the adapted code from example above "test_list" where you set the host = server name(step 2.) and workspace name( from Step 4.) 

 

So I could not guarantee that all mentioned points should work because I did test only the example code but not the suggested steps 1-5)

But I hope this could be helpful for you to implement your intention.

 

Re: List the files from all workspaces in Windchill using Jlink

Dear Gokul ,

 

I hope there is not a direct solution on this .You have to get the each workspace and set the Workspace as a Working Directory .You can list all the files from the Directory Session.ListFiles() method.

 

But If you have a N number of workspace it took lot of time to set each workspace as Working Directory to list the files.So the only way to list files is Session.ListFiles()

 

Feel free to ask ..

 

Thanks REgards,

Dinesh