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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Part constraints

Manjunath
12-Amethyst

Part constraints

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

3 REPLIES 3
RPN
17-Peridot
17-Peridot
(To:Manjunath)

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

Manjunath
12-Amethyst
(To:RPN)

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

FV
17-Peridot
17-Peridot
(To:Manjunath)


@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 

 

Top Tags