within our growing management app, I'm trying to add a feature in order to check laser templates against original models, which, in short, requires guessing if a user drawn sketch is closed and it's surface.
The sketch is drawn on a part or psm, which can include any kind of elements, it must be closed and it can contain holes. Basically, that sketch should be suitable for an extrusion if all the edges are selected, and I also need to get its area.
From my knowledge, there's no direct way of getting the area from a skecth, so the simpler workflow that I can guess is this:
1-Add a new solid model to the part and make it the active one
2-Add an extrusion with all the sketch elements. If it fails, we know the sketch is not closed. Otherwise:
3-Examine one of the caps of the solid model and get the surface form the Area property
4-Delete the new created model once the info has been collected
Adding a new model is necessary because, otherwise, the new extrusion will interfere with the modeling on the part ,so the value returned by Area won't be correct. Maybe we can try to make the extrusion "far away" from existing geometry, but I think that using a new independent model is more elegant.
Also, this can be accomplished without adding new model, extruding a surface WITH CAPS, but in this case, getting the cap surface is less straightforward. I must check all the faces against the lateral faces or something like that. Also, there's the Murphy-law chance of not being able to generate the extruded surface due to conflicts with another surfaces which get ugly tangencies and so (it would be rare, but bad luck exists!). With all, extruding on a new model sames more safe and independant of whatever the part contains.
In any case, the workflow is a bit ugly. Anyone can imagine a better way of doing this? All the methodology also implies playing with the Dirty flag on the analyzed documents in order to avoid an unnecesary re-saving all the parts (hundreds of them!), since SE doen't know that, after all, we have not changed the part by any means.
I think those extrusion commands must make the checking I need before succesfully working, so maybe there's a hidden access to that checking ready for my needs.
Thanks for your help, hope this can be useful for someone!
Thanks for your answer.
This could be a solution but, most of the time, I have no way of getting a point which lies inside the closed region, since all kind of sketches can be found.
Maybe I can try different points with different criteria until some of them works, but this can be quite slow and not too robust...