Skip to main content
1-Visitor
June 13, 2019
Solved

toolkit problem with table function ProDwgtableCelltextGet

  • June 13, 2019
  • 2 replies
  • 2210 views

Hi all,

I have a problem that I can't get my head around ... 

My toolkit is simply exporting a table into something similar to a CSV but customize to our needs, it works fine when I run it on a drawing where the table (9 columns) as multiple lines (assembly drawing). The problem occurs when I run it on a drawing with a similar table but that as only one line (9 columns). The major difference between both table, that I can see, is that the one for assembly as a repeat region including all columns, as for the second case the repeat region is only on certain cells. The first one as text in the first three columns, then some empty. In the case of the single line table I have text from the fourth column.

So base on the description of the function I am using "ProDwgtableCelltextGet" I should get one of these two results:

image.png

	//Write BOM table text to a text file with delimiter
	char* MyTextChar = NULL;
	char* SepTxt = "|";

	ShowMessage(" Number of columns : %d .... Number of rows : %d", NbrOfCols, NbrOfRows);
	for (size_t i = 1; i <= NbrOfRows; i++)
	{
		char LineTxt[100];
		char NewTxt[50];

		strncpy(LineTxt, "", sizeof(LineTxt));
		strncpy(NewTxt, "", sizeof(NewTxt));

		for (size_t ii = 1; ii <= NbrOfCols; ii++) {
			ProWstring **CellText;
			ShowMessage("Position; Col = %d , Row = %d", ii, i);

			error = ProDwgtableCelltextGet(CurrTbl, ii, i, ProParamMode(1), CellText);
			if (error != PRO_TK_NO_ERROR) {
				ShowMessage(" Error with ProDwgtableCelltextGet. Errorr = %s", GetProErrorDesc(error));
				// Error = insert a space
				strncpy(NewTxt, "", sizeof(NewTxt));
				strncat(NewTxt, SepTxt, (sizeof(NewTxt) - strlen(NewTxt)));
			}

The understanding is that if there's nothing in the cell the "error" should equal "PRO_TK_GENERAL_ERROR" and it works fine for multiple line table, but for unknown reason when I run it on a single line table it crashes on the line where I use "ProDwgtableCelltextGet" and simply does a Fatal Error in CREO.

 

Any idea???

I was able to pin point this function as the problem by have messages displayed in the trail file at different steps until I got to this function.

 

Thanks

Best answer by AlexCote

Finally figures out that the problem seems to be the table, as the toolkit works fine in similar case on different format ... 

2 replies

AlexCote1-VisitorAuthorAnswer
1-Visitor
June 13, 2019

Finally figures out that the problem seems to be the table, as the toolkit works fine in similar case on different format ... 

7-Bedrock
November 18, 2019

Hi @AlexCote. Thanks for sharing this  code. I'm still new with using Toolkit. Can you please share with me the step by step that you followed to get to the solution you provided. I would like to take a drawing total weld parameter value and push it to a weld assembly parameter. Your response will be appreciated.

RPN
18-Opal
June 13, 2019

For what it’s worth...

 

tk_status = ProDwgtableCellNoteGet( (ProModelitem*) &p_table,cur_col,cur_row,&note);
if (tk_status == PRO_TK_E_NOT_FOUND) {
		return tk_status;
}
tk_status = ProDtlnoteDataGet (&note,NULL,PRODISPMODE_NUMERIC,&note_data);
tk_status = ProDtlnotedataLinesCollect (note_data, &p_lines);
tk_status = ProArraySizeGet ((ProArray)p_lines, &n_lines);
for (j = 0; j < n_lines; j++) {
 tk_status = ProDtlnotelineTextsCollect (p_lines[j], &p_texts);
 tk_status = ProArraySizeGet ((ProArray)p_texts, &n_texts);
 for (k = 0; k < n_texts; k++)	{

	tk_status = ProDtlnotetextStringGet (p_texts[k], line_string);
 ProWstringToString (line, line_string);

	/* Here you have the content char or wchar */

 tk_status = ProDtlnotetextFree (p_texts[k]);

}
 tk_status = ProArrayFree ((ProArray*)&p_texts);
 tk_status = ProDtlnotelineFree (p_lines[j]);
}
tk_status = ProArrayFree ((ProArray*)&p_lines);