andresperezcera Posted September 19, 2011 Posted September 19, 2011 The subtract region operation is something i have already done, but what i'm having trouble with is determining when a region is inside another one. Here I attach a sample file: cadtutor forum.dwg The main task is checking regions one by one, then determining whether it as or not another region inside. If it does, subtract the interior one. I don't know how to check if one contains another inside. Help!! Quote
ReMark Posted September 19, 2011 Posted September 19, 2011 Wouldn't the Subtract command fail if that were the case? Quote
andresperezcera Posted September 19, 2011 Author Posted September 19, 2011 Wouldn't the Subtract command fail if that were the case? Not really, if you subtract the region which is inside, it will create a tubular region. I work for a fenestration company, therefore we have to design aluminum profiles; the tubular ones have to include some additional information. But i don't have but a visual way to inspect hundreds of profiles & I'd like to automate most of that work. Quote
SEANT Posted September 19, 2011 Posted September 19, 2011 I’ve had good success by comparing the Bounding Box of one Region to see if it was completely contained within the Bounding Box of another Region. If so then subtract. Which API are you using? Quote
andresperezcera Posted September 19, 2011 Author Posted September 19, 2011 I'm using VBA. It sounds great, didn't think about it. Which API do you use, because comparison methods mean everything in time efficiency. Quote
SEANT Posted September 19, 2011 Posted September 19, 2011 Most of my coding time these days is devoted to .NET, though I have done a fair bit of VBA work over the years. For that particular task (Bounding Box comparison), the .NET API has some enhancements that could be beneficial. That notwithstanding, VBA is well up to the task – accurate and efficient. If the geometry is laid out as in your sample file (i.e.,items are not nested) then I suspect the comparison routine would have minimal impact on code execution. Quote
andresperezcera Posted September 19, 2011 Author Posted September 19, 2011 Yes, they will allways be in such manner. I receive them as polylines, then convert all of them to regions, then find those hollow profiles and obtain all the information I need. I think there is only one case in which bounding box comparison wont work, i'll try to ilustrate it. See attachment: illustrate1.dwg In this sample, a small piece is inserted in the provided groove, for such cases comparing bounding boxes will generate an error, is there any criteria other than bounding box which i can add to prevent this type of error? Quote
SEANT Posted September 19, 2011 Posted September 19, 2011 That is the type of nesting that can throw a wrench in the works. One possible methodology would be to copy all inner regions (regions determined to be contained within a particular outer Region). Subtract each inner, and then check if the Area property has changed for the outer region. If it has changed, erase the copy. Though, I don’t remember exactly how the Region.Boolean Subtract method reacts to calls made on non intersecting entities. It may require an error trap. Quote
andresperezcera Posted September 19, 2011 Author Posted September 19, 2011 Sounds OK. But it seems like something i'd rather do the regular way till i find how to automate. Quote
Joro-- Posted September 20, 2011 Posted September 20, 2011 Hi, It seems to me that once you have the regions initially as polylines it would be easier to determine whether one polyline is inside another. In order one polyline to be totally inside another its area should be bigger. So you can first checkbetween two polylines which area is bigger. Then you can try the .IntersectWith method. Both .Area and .IntersectWith methods are available in VBA. So if .IntersectWith method returns no intersection points then the polyline with smaller area is inside the one with bigger area, unless they don't have any common areas at all. I guess this can then be checked comparing the .GetBoundingBox coordinates. This method is more complex than using the .GetBoundingBox alone, but it is more precise, as in some cases you might have one boundingBox totally within the other, byt the real polylines might be intersecting. Hope this helps Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.