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 PTC Community Badges. Engage with PTC and see how many you can earn! X

How to modify the symbolic variable text in a drawing using protoolkit?

YL_10750932
10-Marble

How to modify the symbolic variable text in a drawing using protoolkit?

     I don't know what to do. Here is my code, the function ProDtlsyminstdataVartextsSet() returns the PRO_TK_BAD_INPUTS. It confused me.

ProDtlsyminst sym_inst;
ProDtlsyminstdata data;
ProDtlvartext text;
/*initialize...*/
stutas = ProDtlvartextAlloc((wchar_t*)L"test", (wchar_t*)L"2.5", &text);
status = ProDtlsyminstDataGet(&sym_inst, PRODISPMODE_SYMBOLIC, &data);
status = ProDtlsyminstdataVartextsSet(data, &text);
status = ProDtlsyminstModify(&sym_inst, data);

 

ACCEPTED SOLUTION

Accepted Solutions

Oh, I solved it! Here is my code. 

void modifySymInstence(ProDtlsyminst &sym_inst, ProDtlvartext &var_text)
{
	ProError status;
	ProDtlsyminstdata data;
	ProDtlvartext *text;
	ProLine prompt, prompt_target, value;
	int size;
	status = ProDtlsyminstDataGet(&sym_inst, PRODISPMODE_SYMBOLIC, &data);
	status = ProDtlsyminstdataVartextsCollect(data, &text);
	ProArraySizeGet(text, &size);
	for (int i = 0; i < size; i++)
	{
		status = ProDtlvartextDataGet(text[i], prompt, value);
		status = ProDtlvartextDataGet(var_text, prompt_target, value);
		if (wcharToString(prompt) != wcharToString(prompt_target))
			continue;
		text[i] = var_text;//It solved my problem
	}

	status = ProDtlsyminstdataVartextsSet(data, text);
	status = ProDtlsyminstErase(&sym_inst);
	status = ProDtlsyminstModify(&sym_inst, data);
	status = ProDtlsyminstShow(&sym_inst);
	ProDtlvartextFree(*text);
}

 

View solution in original post

2 REPLIES 2

Oh, I solved it! Here is my code. 

void modifySymInstence(ProDtlsyminst &sym_inst, ProDtlvartext &var_text)
{
	ProError status;
	ProDtlsyminstdata data;
	ProDtlvartext *text;
	ProLine prompt, prompt_target, value;
	int size;
	status = ProDtlsyminstDataGet(&sym_inst, PRODISPMODE_SYMBOLIC, &data);
	status = ProDtlsyminstdataVartextsCollect(data, &text);
	ProArraySizeGet(text, &size);
	for (int i = 0; i < size; i++)
	{
		status = ProDtlvartextDataGet(text[i], prompt, value);
		status = ProDtlvartextDataGet(var_text, prompt_target, value);
		if (wcharToString(prompt) != wcharToString(prompt_target))
			continue;
		text[i] = var_text;//It solved my problem
	}

	status = ProDtlsyminstdataVartextsSet(data, text);
	status = ProDtlsyminstErase(&sym_inst);
	status = ProDtlsyminstModify(&sym_inst, data);
	status = ProDtlsyminstShow(&sym_inst);
	ProDtlvartextFree(*text);
}

 

But I have a new problem. When my program modifies the variable text of the symbol inside the red rectangle, it prompts me to select the direction of the normal. How to select it automatically?

YL_10750932_0-1701759258889.png

 

Announcements


Top Tags