Skip to main content
1-Visitor
May 28, 2019
Question

Part constraints

  • May 28, 2019
  • 2 replies
  • 1716 views

Hi,

I use the following code to get the constraint of selected component in assembly

ProError status;
	ProSelection* sels;
 int n_sels = 1;
	ProFeature *feat;
	ProAsmcomppath path;
	ProAsmcomp *AsmComp;
	ProAsmcompconstraint *constr;
 
 status = ProSelect("part", n_sels, NULL, NULL, NULL, NULL, &sels, &n_sels);
 if(status != PRO_TK_NO_ERROR || n_sels == 0) return status;
	status = ProSelectionAsmcomppathGet(sels[0],&path);
	status = ProFeatureInit(path.owner,path.table_num,feat);		
	status = ProAsmcompConstraintsGet((ProAsmcomp *)feat,&constr);

 return status;

but I get error PRO_TK_INVALID_TYPE (-18)

Kindly help me

2 replies

RPN
18-Opal
May 28, 2019

Select a Feature or a component, check that you get the correct feature ID.

Manjunath1-VisitorAuthor
1-Visitor
May 29, 2019

@RPN , I tried to retrieve the ID of selected component, its returning correct value. But I coudn't  get constraints

FV_01
May 29, 2019

@Manjunath wrote:

Hi,

I use the following code to get the constraint of selected component in assembly

ProError status;
	ProSelection* sels;
 int n_sels = 1;
	ProFeature *feat;
	ProAsmcomppath path;
	ProAsmcomp *AsmComp;
	ProAsmcompconstraint *constr;
 
 status = ProSelect("part", n_sels, NULL, NULL, NULL, NULL, &sels, &n_sels);
 if(status != PRO_TK_NO_ERROR || n_sels == 0) return status;
	status = ProSelectionAsmcomppathGet(sels[0],&path);
	status = ProFeatureInit(path.owner,path.table_num,feat);		
	status = ProAsmcompConstraintsGet((ProAsmcomp *)feat,&constr);

 return status;

but I get error PRO_TK_INVALID_TYPE (-18)

Kindly help me


ProFeatureInit(path.owner, path.table_num, feat) makes absolutely no sense... the second argument is wrong because instead of an id you are using a count... you also had declared 'feat' as a pointer to the ProFeature - which is also wrong because ProFeatureInit would need sizeof(ProFeature) for its output argument instead of sizeof(ProFeature*)...

Take a look at UgAsmcompConstraint.c in protoolkit installation directory.

ProSelectionModelitemGet is all you need if you have a selection object.

'path.comp_id_table...' and so on is what you'll need to pass to ProFeatureInit if that the route you want to go.tttt.png