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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Prepare Pipe LineStock Parameter

RPN
17-Peridot
17-Peridot

Prepare Pipe LineStock Parameter

Hello, I'm not able to set LineStock Parameter with multiple values. If I use the following code, the BEND_ANGLE values are NOT set, and after this call, it is not longer possible to modify the line stock values in Creo manually. Technical Support seems not capable to give an answer. Here my Code, tk_linestockparam_Single_Debug() is an helper, code not here but the debug output.

 

For testing have an assembly open, including one linestock, the code uses the name MYLINESTOCK.

 

If somebody has an idea 🤗

 

 

/*
Here the struct info

typedef struct _pro_lnstk_param_memb_
{
  ProName            name;
  ProParamvalue      value;
  
} ProLnstkParamMemb;


typedef enum 
{
  PROLNSTKPRM_SINGLE,
  PROLNSTKPRM_MULTIPLE
  
} ProLnstkParamType;


typedef struct _pro_lnstk_param_
{
  ProName            name;
  ProLnstkParamType  param_type;
  union {
           ProParamvalue         value;
           ProLnstkParamMemb    *members;
        } lnstk_param_value;
} ProLnstkParam;

*/

 

 

 

 

 

 

ProError
GetLineStockByName_Test (
	ProSolid		model,
	char*			InputName,
	ProLnstk 		*LineStock

)

{


// Creo
	ProError		 tk_status;                         
	char 			 LineStockName[PRO_NAME_SIZE];
	ProLnstk 		*LineStocks;

//Runtime
	int			rval			= PRO_TK_E_NOT_FOUND;
	int			array_size		= 0;
	int			i				= 0;


	tk_status = ProAssemblyLnstksCollect( (ProAssembly) model, &LineStocks);		

	tk_status = ProArraySizeGet (LineStocks, &array_size);							

	for (i = 0; i < array_size ; i++) {

		ProWstringToString(LineStockName,LineStocks[i].name);

		if ( strcmp(LineStockName,InputName) ) {

			continue;
		}

		rval= PRO_TK_NO_ERROR;

		*LineStock = LineStocks[i];

		break;

	}

	ProArrayFree ((ProArray*)&LineStocks);										


	return rval;




}

// Static Test Values
static double BendAngleVals[] = { 90.0, 45.0, 60.0, 30.0};

ProError
MyLnstkParametersSet_Test3 ()


{

	ProError			tk_status;          
	ProParamvalueType	param_value_type;
	ProParamvalue		param_value;

	ProLnstk 			 LineStock;
	ProLnstkParam 		*LnstkParams;
	ProLnstkParam		 LnstkParam;
	ProLnstkParamMemb	*LnstkParamMembers;
	ProLnstkParamMemb	 LnstkParamMember;

	ProMdl				model;


	ProParamvalue		 Paramvalue;

	int					i;
	int					nValues;
	double				dVal;

	TK_DEBUG00("in MyLnstkParametersSet_Test3");

	tk_status = ProMdlCurrentGet (&model);

	if (tk_status == PRO_TK_E_NOT_FOUND) {

		return tk_status;
	}


// MYLINESTOCK or any other name here must be within the active assembly

	tk_status = GetLineStockByName_Test (model,"MYLINESTOCK" ,&LineStock);	

	if (tk_status == PRO_TK_E_NOT_FOUND) {

		return tk_status;

	}


	tk_status = ProArrayAlloc (0, sizeof (ProLnstkParam), 1, (ProArray*)&LnstkParams);

	//
	// Alloc an Array at LnstkParam.lnstk_param_value.members
	//

	tk_status = ProArrayAlloc (0, sizeof (ProLnstkParamMemb), 1, (ProArray*)&LnstkParam.lnstk_param_value.members);		REPORT_TK_CALL("MyLnstkParametersSet_Test3()","ProArrayAlloc()",tk_status,tk_status != PRO_TK_NO_ERROR);


	LnstkParam.name[0] = '\0';

	TK_DEBUG01("Configure form Obj LnstkParam Name '%s'","BEND_ANGLE");

	ProStringToWstring(LnstkParam.name,"BEND_ANGLE");

	LnstkParam.param_type				= PROLNSTKPRM_MULTIPLE;


	for ( i = 0 ; i < 4 ; i++ ) {

		dVal = BendAngleVals[i];

		TK_DEBUG01 ("add value %6.3f",dVal);

		LnstkParamMember.name[0] = '\0';

		TK_DEBUG00("ProParamvalueSet in LnstkParamMember");

		tk_status = ProParamvalueSet(&LnstkParamMember.value, (void*)&dVal, PRO_PARAM_DOUBLE);	

		TK_DEBUG00("ProArrayObjectAdd to LnstkParamMembers");

		//
		// Now add this member
		//

		tk_status = ProArrayObjectAdd ((ProArray*)&LnstkParam.lnstk_param_value.members, PRO_VALUE_UNUSED , 1, &LnstkParamMember);	REPORT_TK_CALL("MyLnstkParametersSet_Test3()","ProArrayObjectAdd()",tk_status,tk_status != PRO_TK_NO_ERROR);

		tk_status = ProArraySizeGet(LnstkParam.lnstk_param_value.members, &nValues);

		TK_DEBUG01("ProArraySizeGet LnstkParam.lnstk_param_value.members  nValues %d",nValues);

	}

//	tk_linestockparam_Single_Debug(LnstkParam);


	tk_status = ProArrayObjectAdd ((ProArray*)&LnstkParams, PRO_VALUE_UNUSED, 1, &LnstkParam);	REPORT_TK_CALL("MyLnstkParametersSet_Test3()","ProArrayObjectAdd()",tk_status,tk_status != PRO_TK_NO_ERROR);


	tk_status = ProArraySizeGet(LnstkParams, &nValues);

	TK_DEBUG01("ProArraySizeGet LnstkParams  nValues %d",nValues);



	TK_DEBUG00("Call ProLnstkParametersSet()");

	tk_status = ProLnstkParametersSet( &LineStock,LnstkParams);							REPORT_TK_CALL("MyLnstkParametersSet_Test3()","ProLnstkParametersSet()",tk_status,tk_status != PRO_TK_NO_ERROR);

	TK_DEBUG00("Call ProArrayFree()");

	tk_status = ProArrayFree( (ProArray*)&LnstkParam.lnstk_param_value.members );												REPORT_TK_CALL("MyLnstkParametersSet_Test3()","ProArrayFree()",tk_status,tk_status != PRO_TK_NO_ERROR);

	tk_status = ProArrayFree( (ProArray*)&LnstkParams );												REPORT_TK_CALL("MyLnstkParametersSet_Test3()","ProArrayFree()",tk_status,tk_status != PRO_TK_NO_ERROR);



	return PRO_TK_NO_ERROR;
} 


Here the Debug Out


# 11:37:23 in MyLnstkParametersSet_Test3
# 11:37:23                                          MyLnstkParametersSet_Test3()          ProArrayAlloc()                      0
# 11:37:23 Configure form Obj LnstkParam Name 'BEND_ANGLE'
# 11:37:23 add value 90.000
# 11:37:23 ProParamvalueSet in LnstkParamMember
# 11:37:23 ProArrayObjectAdd to LnstkParamMembers
# 11:37:23                                          MyLnstkParametersSet_Test3()          ProArrayObjectAdd()                  0
# 11:37:23 ProArraySizeGet LnstkParam.lnstk_param_value.members  nValues 1
# 11:37:23 add value 45.000
# 11:37:23 ProParamvalueSet in LnstkParamMember
# 11:37:23 ProArrayObjectAdd to LnstkParamMembers
# 11:37:23                                          MyLnstkParametersSet_Test3()          ProArrayObjectAdd()                  0
# 11:37:23 ProArraySizeGet LnstkParam.lnstk_param_value.members  nValues 2
# 11:37:23 add value 60.000
# 11:37:23 ProParamvalueSet in LnstkParamMember
# 11:37:23 ProArrayObjectAdd to LnstkParamMembers
# 11:37:23                                          MyLnstkParametersSet_Test3()          ProArrayObjectAdd()                  0
# 11:37:23 ProArraySizeGet LnstkParam.lnstk_param_value.members  nValues 3
# 11:37:23 add value 30.000
# 11:37:23 ProParamvalueSet in LnstkParamMember
# 11:37:23 ProArrayObjectAdd to LnstkParamMembers
# 11:37:23                                          MyLnstkParametersSet_Test3()          ProArrayObjectAdd()                  0
# 11:37:23 ProArraySizeGet LnstkParam.lnstk_param_value.members  nValues 4
# 11:37:23 +++++++++++++++++++++++
# 11:37:23 ps_linestockparam_Single_Debug
# 11:37:23 +++++++++++++++++++++++
# 11:37:23 PRO_PARAM_DOUBLE is 50
# 11:37:23 PRO_PARAM_STRING is 51
# 11:37:23 PRO_PARAM_INTEGER is 52
# 11:37:23 PRO_PARAM_BOOLEAN is 53
# 11:37:23 PROLNSTKPRM_SINGLE is 0
# 11:37:23 PROLNSTKPRM_SINGLE is 1
# 11:37:23 ParamName is                 'BEND_ANGLE'
# 11:37:23 linestockparamtype   1 SINGLE is 0 MULTIPLE is 1
# 11:37:23 LinestockParamType is PROLNSTKPRM_MULTIPLE
# 11:37:23 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# 11:37:23 tk_status 0 nValues in members 4
# 11:37:23 k 0 member Name ''
# 11:37:23 Type Get tk_status 0 for member Name '' paramValueType 50
# 11:37:23 Value is PRO_PARAM_DOUBLE 50
# 11:37:23 param str value[0] '90.000000000'
# 11:37:23 k 1 member Name ''
# 11:37:23 Type Get tk_status 0 for member Name '' paramValueType 50
# 11:37:23 Value is PRO_PARAM_DOUBLE 50
# 11:37:23 param str value[1] '45.000000000'
# 11:37:23 k 2 member Name ''
# 11:37:23 Type Get tk_status 0 for member Name '' paramValueType 50
# 11:37:23 Value is PRO_PARAM_DOUBLE 50
# 11:37:23 param str value[2] '60.000000000'
# 11:37:23 k 3 member Name ''
# 11:37:23 Type Get tk_status 0 for member Name '' paramValueType 50
# 11:37:23 Value is PRO_PARAM_DOUBLE 50
# 11:37:23 param str value[3] '30.000000000'
# 11:37:23 Done ps_linestockparam_Single_Debug()
# 11:37:23 -------------------------------------
# 11:37:23                                          MyLnstkParametersSet_Test3()          ProArrayObjectAdd()                  0
# 11:37:23 ProArraySizeGet LnstkParams  nValues 1
# 11:37:23 Call ProLnstkParametersSet()
# 11:37:23                                          MyLnstkParametersSet_Test3()          ProLnstkParametersSet()              0
# 11:37:23 Call ProArrayFree()
# 11:37:23                                          MyLnstkParametersSet_Test3()          ProArrayFree()                       0
# 11:37:23                                          MyLnstkParametersSet_Test3()          ProArrayFree()                       0

 

 

 

 

 

 

ACCEPTED SOLUTION

Accepted Solutions
RPN
17-Peridot
17-Peridot
(To:jchelle)

Hello Jean Claude,

I must apologize, I oversaw an eMail from Michael Wunder. He corrected my sample code, and this fixed the issue.

It is required to tag the member with the same name. I checked it on extract, and got always a blank value. Now the code is working, thanks to support and Mr. Wunder👍 

 

ProStringToWstring(LnstkParam.name,"BEND_ANGLE");

	LnstkParam.param_type				= PROLNSTKPRM_MULTIPLE;


	for ( i = 0 ; i < 4 ; i++ ) {

		dVal = BendAngleVals[i];

		TK_DEBUG01 ("add value %6.3f",dVal);

		LnstkParamMember.name[0] = '\0';
// It is required to tag the member with the same name
		ProStringToWstring(LnstkParamMember.name,"BEND_ANGLE");

 

View solution in original post

3 REPLIES 3
jchelle
16-Pearl
(To:RPN)

Dear member,  

 

Thank you for posting this question regarding LINESTOCK parameter file. As  mentioned in the Creo Help documentation :   "A line stock is a set of parameters that define material, grade, outside diameter, and other parameters of pipeline segments. Piping stores the parameters in the line stock feature. Before you create a pipeline, you must define a line stock. You can assign different line stocks to different line segments of the same pipeline because they may have different outside diameters, materials, and grades. Keep in mind that the system determines a pipeline’s physical (solid) shape based on the line stock from which it actually derived the pipe. You can edit line stock parameters using the LineStock dialog box, and you can add user-defined attributes to the list. You can also read and write a line stock to a .stk file. You can set up a library of line stocks that you can retrieve to route a particular pipeline. "  

 

Regarding the User defined parameters BEND_ANGLE is a valid parameter with MIN_BEND_ANGLE and MAX_BEND_ANGLE 

 

Please review Creo Help for Line Stock Parameter Files and Report Table Parameters Applicable to Piping and let us know if this help.  

 

 

Best regards

Jean Claude

RPN
17-Peridot
17-Peridot
(To:jchelle)

Hello Jean Claude,

I must apologize, I oversaw an eMail from Michael Wunder. He corrected my sample code, and this fixed the issue.

It is required to tag the member with the same name. I checked it on extract, and got always a blank value. Now the code is working, thanks to support and Mr. Wunder👍 

 

ProStringToWstring(LnstkParam.name,"BEND_ANGLE");

	LnstkParam.param_type				= PROLNSTKPRM_MULTIPLE;


	for ( i = 0 ; i < 4 ; i++ ) {

		dVal = BendAngleVals[i];

		TK_DEBUG01 ("add value %6.3f",dVal);

		LnstkParamMember.name[0] = '\0';
// It is required to tag the member with the same name
		ProStringToWstring(LnstkParamMember.name,"BEND_ANGLE");

 

jchelle
16-Pearl
(To:RPN)

Dear member,

 

Thank you for confirming the resolution with the information from Michael, our Toolkit expert.

 

We will close this discussion.

 

If you appreciated the community service , do not hesitate to use it again in the future.

 

kind regards

Jean Claude

Announcements


Top Tags