Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

Using pro_compute_interference

ProE_toolkit

New member
I'm trying to call this function in my TOOLKIT program so that I can compute the local interference between two parts.


When the program run it seems to crash when it hits the 'status = pro_compute_interference(sel, 0, intf_surfs, n_surfs)'.


How does one properly call 'pro_compute_interference'? I used <ProE install>/protoolkit/protkdoc/samples/UgGeomInterferCheck_ c for reference.


Here is the relevant part of mycode:


#include "pro_interf.h"


ProError user_part_interference ()


{


int status;


Select3d *sel;


Prohandle *intf_surfs, i;


int n_surfs;





fprintf (logfile, "ProError sel d: %d \t\n",sel);


status = pro_compute_interference(sel, 0, intf_surfs, n_surfs);print_status("pro_compute_interference");


return (PRO_TK_NO_ERROR);


}





Backround from the api:
Function pro_compute_interference







Description


Measures the interference between the two specified parts. This function returns a list of surface handles that represent the total volume of interference between two parts. This data does not change upon regeneration, file management erase, and so on.


Note that the function does not reallocate theinterf_volume_surfsarray each time. To free the volume, use thepro_interference_volume_release()function.

Synopsis

#include <pro_interf.h>

int
pro_compute_interference
(


Select3dsel_recs[2]



/* (In)


The two parts whose interference you want to check (sel_type == SEL_3D_PART).


*/


Pro_interf_typeinterference_type



/* (In)


The interference type.


*/


Prohandle**interference_surf_arr



/* (Out)


The total volume of interference. This is an array of surface handles, or NULL if there is no interference. The surfaces returned are in the coordinates of the top-level assembly.


*/


int*n_surfs



/* (Out)


The number of surfaces in the volume.


*/

)

Returns






Success

PRODEV_NO_ERROR

Error

An appropriate error constant fromprodev_error.h
 
Well...you didn't fill out the most important input variable to the function. You need to have a valid Select3D array. This means that you need to have the user select the parts that you want to compute the interference for. Call ProSelect().
 
I usually run my app with the two pre-selected parts;I will insteadcall ProSelect() and see what happens.<?:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" />


WhenIrun the printf statementitoutputs numerical value for 'sel' value. Isuspect I'm passing a valid Select3D array. I will update with what happenswith ProSelect().


Here is the code from the UgGeomInterferCheck_ c:


/*========================================================== ======*\


FUNCTION : user_part_interference


PURPOSE : Computes the interference between two parts.


\*========================================================== ======*/


ProError user_part_interference ()


{


int status;


Select3d *sel;


Prohandle *intf_surfs;


int n_surfs, i;


wchar_t w_str[5];


char str[100], a_str[5];


double volume;


FILE *fp;


char fname[PRODEV_NAME_SIZE+4];


wchar_t w_fname[PRODEV_NAME_SIZE+4];


Prohandle p_model;


ProFileName msg_fil;


p_model = pro_get_current_object();


ERROR_CHECK("user_part_interference","pro_get_current_object",


(p_model == NULL));


if (p_model == NULL) return (PRO_TK_E_NOT_FOUND);


ProStringToWstring( msg_fil, "msg_uggeom.txt" );


status = ProMessageDisplay (msg_fil, "USER %0s", "Select two parts");


ERROR_CHECK("user_part_interference","ProMessageDisplay",status);


if (pro_select ("part", 2, &sel, 0, 0) <= 1)


return (PRO_TK_GENERAL_ERROR);


/*---------------------------------------------------------- ------*\


Compute the interference between the two parts.


\*---------------------------------------------------------- ------*/


status = pro_compute_interference (sel, 0, &intf_surfs,


&n_surfs);


ERROR_CHECK("user_part_interference","pro_compute_interference",


(status != PRODEV_NO_ERROR));


if (status != PRODEV_NO_ERROR)


return (PRO_TK_GENERAL_ERROR);


if (n_surfs == 0)


{


status = ProMessageDisplay (msg_fil, "USER %0s",


"No interference was detected.");


ERROR_CHECK("user_part_interference","ProMessageDisplay",status);


return (PRO_TK_NO_ERROR);


}


ProTKSprintf (str, "%d interference surfaces found. Display? [Y]:",


n_surfs);


status = ProMessageDisplay (msg_fil,"USER %0s", str);


ERROR_CHECK("user_part_interference","ProMessageDisplay",status);


if (!ProMessageStringRead (4, w_str))


{


ProWstringToString (a_str, w_str);


if (a_str[0] != 'y' || a_str[0] != 'Y')


return (PRO_TK_NO_ERROR);


}


user_gen_filename (p_model, ".intf", fname);


if ((fp = PTApplsUnicodeFopen (fname, "w")) == NULL)


return (PRO_TK_GENERAL_ERROR);


ProTKFprintf (fp, "Interference in ");


user_dump_mdl (fp, p_model);


ProTKFprintf (fp, "\n\n");


.


.


.


.


return (PRO_TK_NO_ERROR);


}


I wanted to include the file above in my #include files and call the function, but I had issue with link errors with ERROR_CHECK and other obscure link errors.
 
Thanks a lot Patrik Williams! I got it working, I needed the following piece of code:


pro_select ("part", 2, &sel, 0, 0);
 

Sponsor

Articles From 3DCAD World

Back
Top