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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

how to read Workspace model

Aravind98
11-Garnet

how to read Workspace model

Hi guys

 

Good Morning

is there any Api call is available for reading or retrieving the model from the windchill workspace?

Please let me know if you know any other Possibilities.

 

regards

Aravind

1 ACCEPTED SOLUTION

Accepted Solutions
RPN
17-Peridot
17-Peridot
(To:Aravind98)

Then use ProFileList

 

Workspace you may enter wtws:// 

For the CommonSpace try to enter the url, I never tested this, but this could work, You will get files and folders back.

View solution in original post

9 REPLIES 9
RPN
17-Peridot
17-Peridot
(To:Aravind98)

Use the url you see in the Browser, afik

 

wtws://

extern ProError ProFilesList (ProPath directory_path,
ProLine filter,
ProFileListOpt listing_option,
ProPath **p_file_name_array,
ProPath **p_subdir_name_array);
/*
Purpose: Lists the files in the specified directory. You can pass specific
filters to get files with those extensions only.

Input Arguments:

directory_path - The directory in which to look for
the files to be listed. If this is NULL,
the files from the current directory will be
listed.

filter - The user-supplied filter string for file
extensions. Each filter must be separated
by a comma. For example, "*.prt,*.txt"
(converted to a wide-character string).
Each individual element in the filter must
be less than PRO_NAME_SIZE characters.

listing_option - Specifies whether all versions or only the
latest versions are being requested, and whether or
not the list should be sorted alphabetically.

<b>Note: </b>Passing any of _INST options
in Wildfire 4.0 M100 and earlier will have the same
effect as passing PRO_FILE_LIST_LATEST.

Output Arguments:

p_file_name_array - The array of files found. You must preallocate
this array using <b>ProArrayAlloc()</b>; if you
reuse the array, new elements will be appended to
the existing elements unless you reset the array
size to 0 with ProArraySizeSet.

p_subdir_name_array - The array of all subdirectories found,
regardless of whether they match the filter.
You must preallocate this array using
<b>ProArrayAlloc()</b>; if you reuse the array,
new elements will be appended to the existing
elements unless you reset the array size to 0 with
ProArraySizeSet.

Return Values:

PRO_TK_NO_ERROR - The function successfully returned the files.
PRO_TK_BAD_INPUTS - One or more of the input arguments are invalid.
PRO_TK_INVALID_DIR - Invalid directory.

See Also:
ProArrayAlloc()

 

 

to read 

 

extern ProError ProMdlFiletypeLoad (ProPath full_path,
ProMdlfileType type,
ProBoolean ask_user_about_reps,
ProMdl *p_handle);
/*
Purpose: Retrieves the specified model and initializes the handle.
<p>
The function retrieves the model
into memory, but neither displays the model nor
makes it the current model. Differs from ProMdlnameRetrieve
in that the caller can specify the location of the model
in addition to its name.
<p>
If retrieving an assembly, and errors occur in regeneration,
the assembly will include suppressed features. The function
ProSolidRetrievalErrorsGet identifies if errors occurred.


Input Arguments:
full_path - The full path of the model to be retrieved,
including the name, and optionally the location
and extension.
type - The type of the model to retrieve, or PRO_MDLFILE_UNUSED
if full_path includes an extension.
ask_user_about_reps - If TRUE, the Open Rep dialog may be presented,
allowing the user to specify which simplified
representation of the model should be retrieved.

Output Arguments:
p_handle - The handle to the retrieved model

 

Aravind98
11-Garnet
(To:RPN)

Hi RPN
thanks for your response 
but i need to get or read all the model in windchill, is that possible?

RPN
17-Peridot
17-Peridot
(To:Aravind98)

If you have the model name and type like box.drw, just open it.

 

Search order is

  1. Session
  2. Workspace
  3. Common Space

The last could be current working folder and your search path info, but with Windchill you should not have this.

 

So just open/read the file, if not found you will get a relevant return status from the function call.

Aravind98
11-Garnet
(To:RPN)

no i don't know the model names, just i want to read all the model from workspace.

RPN
17-Peridot
17-Peridot
(To:Aravind98)

Then use ProFileList

 

Workspace you may enter wtws:// 

For the CommonSpace try to enter the url, I never tested this, but this could work, You will get files and folders back.

Aravind98
11-Garnet
(To:RPN)

ok, I'll try.

Thank you 😊

Aravind98
11-Garnet
(To:RPN)

Hi @RPN 
it's Working, Thank you

status = ProBrowserAuthenticate(username, password);
status = ProServersCollect(&aliases);
status = ProArraySizeGet(aliases, &num_servers);
for (i = 0; i < num_servers; i++)
{
status = ProServerUnregister(aliases[i]);
}
ProPath serv;
ProStringToWstring(serv, (char*)workspace.c_str());
ProPath URL;
ProStringToWstring(URL, (char*)serverurlw3.c_str());
ProName wsName;
ProStringToWstring(wsName, (char*)wsNamestr.c_str());
 
status = ProServerRegister(serv, URL, wsName, &aliased_url);
 
status = ProServerActivate(serv);
 
ProPath* p_file_name_array;
ProPath* p_subdir_name_array;
//string da = ".asm,.prt,*.drw";
string da = "*.drw";
ProName namme;
ProStringToWstring(namme, (char*)da.c_str());
status = ProArrayAlloc(0, sizeof(ProPath), 1, (ProArray*)&p_file_name_array);
status = ProArrayAlloc(0, sizeof(ProPath), 1, (ProArray*)&p_subdir_name_array);
status = ProFilesList(aliased_url, namme, PRO_FILE_LIST_LATEST, &p_file_name_array, &p_subdir_name_array);
status = ProArraySizeGet((ProArray*)p_file_name_array,&files);
 
for (i = 0; i < files; i++)
{
char _path[PRO_PATH_SIZE];
ProWstringToString(_path, p_file_name_array[i]);
wstring substring = //"Your Server URL";
wstring result = p_file_name_array[i];
string sPath(result.begin(), result.end());
partPaths.push_back(sPath);
 
size_t pos = result.find(substring);
 
if (pos != wstring::npos) {
result.erase(pos, substring.length());
}
string _name(result.begin(), result.end());
partNames.push_back(_name);
}

It looks like you have some responses from some community members. If any of these replies helped you solve your question please mark the appropriate reply as the Accepted Solution. 
Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.
Regards,
Andra

Hi @achirila 

 

yeah sure, I've not tried it yet.  

 

regards

Aravind 

Top Tags