Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Hi team
I have a doubt regarding how to calculate the smallest distance between edges using the toolkit. This is specifically for a sheet metal part.
Does anyone know how to accurately calculate the edge-to-edge distances or if there’s any workaround available for this? Any help or guidance would be greatly appreciated.
I've attached the image for your reference.
Hello,
from the Creo/Toolkit documentation:
The function ProSelectionWithOptionsDistanceEval() evaluates the distance between two items. You can evaluate distance between surfaces, edges, entities, vertices, curves, datums, and so on. The initial selection of the item is used to guess the type of geometry. In case of error types PRO_TK_BAD_INPUTS or PRO_TK_BAD_CONTEXT, the output argument p_result is set to -1.0 and all parameters are set to 0.0.
The input arguments option1 and option2 are analogous to Options in the Measure dialog box in Creo Parametric user interface. You can specify PRO_B_TRUE if you want to turn on the following options for the selected items:
The output arguments return the following values:
Hope that helps.
Hi @FabianWolf
I appreciate your response.
I was able to get the surface edges, but now I'm stuck trying to identify nearby edges. In the attached image, there is one rectangular and one circular extrude cut. I want to categorize them—such as identifying which edges belong to the rectangular cut and which to the circular cut—and determine if the edges of the rectangle and circle are closely located within the model.
If you know of any workaround or a better approach, please let me know. I've attached my code for your reference please take a look.
I assume your callback function contour_visit is called twice. First call for the contour of the rectangular and second call for the contour of the circular extrude.
I assume your EdgeVisitInputData is a struct that shall be used for gathering data. You can add a member like std::vector<ContourData> contours, that will gather all the edges for each contour. The type ContourData might hold a member int contour_id (optional) and an array like std:vector<ProModelitem> edges, that will hold all edges belonging to the corresponding contour.
Then you have all the edges separated into two lists. Now you can browse the lists via two nested for loops and calculate the distance for each edge out of first list and all the edges out of the second list. Provide a variable that memorizes the shortest distance until the loops are done.
To get the ProSelection input arguments for ProSelectionWithOptionsDistanceEval, use ProSelectionAlloc on basis of the ProModelitems representing the edges. I guess you are just doing this approach in the context of a sheetmetal part, so ProAsmcomppath is not relevant (set NULL).
Hope that helps.
Hi @FabianWolf
Good Morning, hmm I'm not sure okay let me try, i appreciate your response.
regards
Aravind