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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Error PRO_TK_CANT_ACCESS is returned for ProSelbufferSelectionAdd function

sharon.barber
1-Newbie

Error PRO_TK_CANT_ACCESS is returned for ProSelbufferSelectionAdd function

Hello,

I am getting PRO_TK_CANT_ACCESS error for ProSelbufferSelectionAdd function.
I am trying to open a dxf file, collect Dtlentities and select few using ProSelbufferSelectionAdd.
Following is the code, I am trying to use (I have modified it to select first Dtlentity).



ProError status = PRO_TK_NO_ERROR;

ProMdl model;
ProPath dxf_path;
ProName dxf_name;
ProSelection sel;
ProDtlentity *ent_arr = NULL;
int iSize;

// Prompt user to open a dxf file
status = ProFileOpen(NULL, L"*.dxf", NULL, NULL, NULL, NULL, dxf_path);
status = ProFilenameParse(dxf_path, NULL, dxf_name, NULL, NULL);

// Create a new 2d Pro/ENGINEER model using dxf file
status = Pro2dImportCreate(PRO_DXF_FILE, dxf_path, dxf_name, PRO_MDL_DRAWING,
PRO_B_FALSE, PRO_B_FALSE, PRO_B_TRUE, &model);

// Collect drawing entities
status = ProDrawingDtlentitiesCollect((ProDrawing)model, NULL, PRO_VALUE_UNUSED, &ent_arr);

// Check size of drawing entity array
status = ProArraySizeGet((ProArray)ent_arr, &iSize);

if(status == PRO_TK_NO_ERROR && iSize > 0)
{
// Try to select first drawing entity
status = ProSelectionAlloc(NULL, &ent_arr[0], &sel);
status = ProSelbufferSelectionAdd(sel); // PRO_TK_CANT_ACCESS is returned here
status = ProArrayFree ((ProArray*)&ent_arr);
}


Help documentation mentions "PRO_TK_CANT_ACCESS - There is no Object/Action selection tool active."

Other thing I have observed is that after executing code mentioned above, if control is returned to Pro/E and again ProSelbufferSelectionAdd is used, then it executes without any error and entity can be seen selected in drawing.

Any suggestions/ comments are appreciated.

Thanks,

Regards,

Amar Junankar
Imagecom, Inc.
www.aspire3d.com


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
2 REPLIES 2
FV
17-Peridot
17-Peridot
(To:sharon.barber)

Hello all,

Amar,

I would try to use ProObjectwindowCreate, ProWindowCurrentSet and ProWindowActivate after Pro2dImportCreate.

HIH.

Feliks.

In Reply to Amar Junankar:

Hello,

I am getting PRO_TK_CANT_ACCESS error for ProSelbufferSelectionAdd function.
I am trying to open a dxf file, collect Dtlentities and select few using ProSelbufferSelectionAdd.
Following is the code, I am trying to use (I have modified it to select first Dtlentity).



ProError status = PRO_TK_NO_ERROR;

ProMdl model;
ProPath dxf_path;
ProName dxf_name;
ProSelection sel;
ProDtlentity *ent_arr = NULL;
int iSize;

// Prompt user to open a dxf file
status = ProFileOpen(NULL, L"*.dxf", NULL, NULL, NULL, NULL, dxf_path);
status = ProFilenameParse(dxf_path, NULL, dxf_name, NULL, NULL);

// Create a new 2d Pro/ENGINEER model using dxf file
status = Pro2dImportCreate(PRO_DXF_FILE, dxf_path, dxf_name, PRO_MDL_DRAWING,
PRO_B_FALSE, PRO_B_FALSE, PRO_B_TRUE, &model);

// Collect drawing entities
status = ProDrawingDtlentitiesCollect((ProDrawing)model, NULL, PRO_VALUE_UNUSED, &ent_arr);

// Check size of drawing entity array
status = ProArraySizeGet((ProArray)ent_arr, &iSize);

if(status == PRO_TK_NO_ERROR && iSize > 0)
{
// Try to select first drawing entity
status = ProSelectionAlloc(NULL, &ent_arr[0], &sel);
status = ProSelbufferSelectionAdd(sel); // PRO_TK_CANT_ACCESS is returned here
status = ProArrayFree ((ProArray*)&ent_arr);
}


Help documentation mentions "PRO_TK_CANT_ACCESS - There is no Object/Action selection tool active."

Other thing I have observed is that after executing code mentioned above, if control is returned to Pro/E and again ProSelbufferSelectionAdd is used, then it executes without any error and entity can be seen selected in drawing.

Any suggestions/ comments are appreciated.

Thanks,

Regards,

Amar Junankar
Imagecom, Inc.
www.aspire3d.com

Hello Feliks,

Thanks for your suggestion.

I tried using ProObjectwindowCreate, ProWindowCurrentSet and ProWindowActivate after Pro2dImportCreate (also tried creating window first, then retrieve model and display it).
However, ProSelbufferSelectionAdd still throws PRO_TK_CANT_ACCESS error.
I am thinking somehow ProE Object/Action selection tool doesn't become active for new model till control is passed to ProE. Once control is passed to ProE, then ProSelbufferSelectionAdd works fine.

Thank you again for your reply.

Regards,

Amar Junankar
Imagecom, Inc.

Top Tags