Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
Hello,
I am about to connect to the Windchill server by using ProToolkit written in C.
I would like to register new connection to the Windchill server, then create a workspace and commit .asm abd .prt files in to the workspace.
So far, I have this piece of code:
ProName server_alias;
ProStringToWstring(server_alias, "Toolkit_TEST_SERVER");
char* server_url = "http://host_name/Windchill";
status = ProServerUnregister(server_alias);
status = ProBrowserAuthenticate(uname, pwrd);
ProPath server_url_w;
wchar_t* aliased_url;
wchar_t* workspace_name = L"test-002_15_11_2021";
status = ProStringToWstring(server_url_w, "http://host_name/Windchill");
This is giving me an error:
status = ProServerRegister(server_alias, server_url_w, workspace_name, &aliased_url);
status = PRO_TK_INVALID_DIR(-15)
For me it is also odd to provide a name of the workspace, that I am about to create later on?
ProServerWorkspaceData workspaces;
wchar_t* context_name = L"DA.test-002";
status = ProServerworkspacedataAlloc(context_name, workspace_name, &workspaces);
status = ProServerWorkspaceCreate(NULL, workspaces);
status = ProServerActivate(server_alias);
Can you help me to resolve this issue? Is this right order to create a workspace and push the files to it? Please, advise me the best approach.
Solved! Go to Solution.
I think, in ProServerRegister you need use a name of existing "default" workspace (each product, library has workspace by default). After that you can create new one and switch to it.
I think, in ProServerRegister you need use a name of existing "default" workspace (each product, library has workspace by default). After that you can create new one and switch to it.
If I use the defaul one, then it works.
In the next steps I got another error message:
wchar_t* context_name = L"DA.test-002";
status = ProServerworkspacedataAlloc(context_name, workspace_name, &workspaces);
status = ProServerWorkspaceCreate(NULL, workspaces);
PRO_TK_CANT_WRITE(-17) - Cannot create a workspace on this server
I am using wcadmin rights.
What a reason for that?
Maybe, new registered server not active?
Try to use status = ProServerActivate(server_alias); before ProServerWorkspaceCreate. Or set server_alias in ProServerWorkspaceCreate as first argument.
status = ProServerActivate(server_alias)
wchar_t* context_name = L"DA.test-002";
status = ProServerworkspacedataAlloc(context_name, workspace_name, &workspaces);
status = ProServerWorkspaceCreate(NULL, workspaces);
it dodn't help by changing the order and replacing NULL by server_alias;
status = ProServerRegister(server_alias, server_url_w, workspace_name, &aliased_url);
status = ProServerActivate(server_alias);
status = ProServerworkspacedataAlloc(context_name, workspace_name, &workspaces);
status = ProServerWorkspaceCreate(server_alias, workspaces);
status = PRO_TK_CANT_WRITE(-17)
any other thoughts?
Windchill user (with login you use) can create workspace? Test this manually.
Yes, I am using wcadmin and can create a workspace ("test")
1) use ProServerWorkspacesCollect to get all workspaces
2) check
ProServerworkspacedataNameGet()
ProServerworkspacedataContextGet()
3) ProServerContextsCollect
Maybe, you don't has assess right or pas not correct name of the context
I tried as you suggested:
1)
status = ProServerWorkspacesCollect(server_alias, &listdata);
2)
status = ProArraySizeGet(listdata, &num_workspaces);//gives around 255 items
for (unsigned int a = 0; a < num_workspaces; a = a + 1)//loop over workspace items
{
status = ProServerworkspacedataNameGet(listdata[a], &def_ws_name);
int len = bytesInWCharStr(def_ws_name);
str = new char[len];
memset(str, 0, len);
wcstombs(str, def_ws_name, len);
if (strcmp("test", str) == 0)//find item that I created manually
{
dataitem = listdata[a];
status = ProServerworkspacedataContextGet(dataitem, &context_name);//get context name gives "DA.test-002"
}
}
3)
status = ProServerContextsCollect(server_alias, &data);
status = ProArraySizeGet(data, &num_contexts);//gives around 237 items
This looks to be okay. I am able to see the items and loop over them.
I don‘t under your order.
from the header file:
To automate registration of servers
in interactive mode, use the standard config.fld setup to preregister the
servers. To ensure that the servers are not preregistered when running
Creo Parametric in batch non-graphics mode, set the environment var