Skip to main content
1-Visitor
February 26, 2019
Solved

Dimension Visit to find a dimension by name

  • February 26, 2019
  • 1 reply
  • 1667 views

Hi All,

 

I use ProSolidDimensionVisit(), to get a dimension names "Test" from a part. And I need to add flexibility in Assembly. I use the following code, in this case it takes only first dimension. Kindly throw some light how to find the dimension with name.

ProError dim_visit(ProDimension* dimension,ProError status,ProAppData data)

ProName d_name;
char dim_name[PRO_NAME_SIZE];

status = ProModelitemNameGet(dimension,d_name);
ProWstringToString(dim_name,d_name);

if (strcmp(dim_name,"Test") == 0)
{
return status;
}

return PRO_TK_CONTINUE;
Best answer by GabrielZaha

There are two things that you need to pay attention.

First: to get the dimension name you need to use ProDimensionSymbolGet function.

Second is the return of the visiting function. Anything other than PRO_TK_NO_ERROR will make the ProSolidDimensionVisit function to stop. In the example you posted the return is set to PRO_TK_CONTINUE wich will make the visiting stop.

I guess what you are looking for is something like this:

ProError dim_visit(ProDimension* dimension,ProError status,ProAppData data)
{
	ProName d_name;
	char dim_name[PRO_NAME_SIZE];

	status = ProDimensionSymbolGet(dimension,d_name);
	ProWstringToString(dim_name,d_name);

	if (strcmp(dim_name,"Test") == 0)
	{
		//do something here
		return PRO_TK_CONTINUE;
	}

	return PRO_TK_NO_ERROR;
}

1 reply

14-Alexandrite
February 26, 2019

There are two things that you need to pay attention.

First: to get the dimension name you need to use ProDimensionSymbolGet function.

Second is the return of the visiting function. Anything other than PRO_TK_NO_ERROR will make the ProSolidDimensionVisit function to stop. In the example you posted the return is set to PRO_TK_CONTINUE wich will make the visiting stop.

I guess what you are looking for is something like this:

ProError dim_visit(ProDimension* dimension,ProError status,ProAppData data)
{
	ProName d_name;
	char dim_name[PRO_NAME_SIZE];

	status = ProDimensionSymbolGet(dimension,d_name);
	ProWstringToString(dim_name,d_name);

	if (strcmp(dim_name,"Test") == 0)
	{
		//do something here
		return PRO_TK_CONTINUE;
	}

	return PRO_TK_NO_ERROR;
}
Manjunath1-VisitorAuthor
1-Visitor
February 28, 2019

@GabrielZaha , its working tnx for the info..