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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

List the files from all workspaces in Windchill using Jlink

Gokulraj26
5-Regular Member

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?

4 REPLIES 4

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.

 

ddhini
14-Alexandrite
(To:Gokulraj26)

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

T_F
16-Pearl
16-Pearl
(To:ddhini)

The method session.ListFiles() is taking to long to get a reply. Is getting more than 40 seconds to have a response. I have only 431 parts in workspace...

Is it normal? Is there any faster way to have the complete list of the documents in workspace?

 

I want to create some automation, for when a user creates a part in a specific assembly, it creates the file with the correct part number. For that, I need to have the list of documents in workspace.

T_F
16-Pearl
16-Pearl
(To:T_F)

Has anyone found the same amount of time, to list all documents in workspace? It really takes to much time to do it.

Has anyone a workaround?

Top Tags