Determine if entity is outside clip boundary

Determine if entity is outside clip boundary

Anonymous
Not applicable
1,020 Views
5 Replies
Message 1 of 6

Determine if entity is outside clip boundary

Anonymous
Not applicable

Hi,

If anyone know how to determine if an entity in a clipped block reference is outside clip boundary that mean they are not shown in drawing? The inverted clip boundary maybe ignored. 

Thanks!

0 Likes
1,021 Views
5 Replies
Replies (5)
Message 2 of 6

ActivistInvestor
Mentor
Mentor

@Anonymous wrote:

Hi,

If anyone know how to determine if an entity in a clipped block reference is outside clip boundary that mean they are not shown in drawing? The inverted clip boundary maybe ignored. 

Thanks!


Unfortunately, that is not a simple problem to solve. The clipping happens at the primitive/display geometry level. To do it, you have to analyze an exploded copy of each entity in the block reference, and compare it to the clipping boundary. For curve-based entities, or entities that decompose into same, you would use IntersectWith() to detect an intersection with the boundary, and a BRep-based point containment test against the boundary to determine if non-intersecting curves are inside or outside of it.

0 Likes
Message 3 of 6

Anonymous
Not applicable

Thank you for your time. I'm planning to use draw overrule to circle that are inside a block reference. I though that I can get the clip boundary of the block then check if the circle is completely inside the clip boundary. but seem it is a really heavy task.

Because AutoCAD Regen drawing is much faster so that I wondering if AutoCAD saved some property that let AutoCAD itself know when they do regenerating drawing.

Thanks!

 

0 Likes
Message 4 of 6

ActivistInvestor
Mentor
Mentor

@Anonymous wrote:

Thank you for your time. I'm planning to use draw overrule to circle that are inside a block reference. I though that I can get the clip boundary of the block then check if the circle is completely inside the clip boundary. but seem it is a really heavy task.

Because AutoCAD Regen drawing is much faster so that I wondering if AutoCAD saved some property that let AutoCAD itself know when they do regenerating drawing.

Thanks!

 


If you open AcExportLayout.dll and AcExportLayoutEx.dll in reflector or some other similar too and look at the code, you will see how complicated the problem is. Export Layout resorts to API spoofing to clip custom objects against the viewport boundary. API spoofing involves creating versions of the WorldGeometry, ViewportGeometry, and many related classes, and then calling WorldDraw() on the object that's being clipped. The spoofed versions of those APIs simply examines the calls to the methods of those classes to capture the raw geometry generated by the object being clipped. It's an interesting solution to the problem but also an incredibly complicated one.

Message 5 of 6

Anonymous
Not applicable

Thanks, I will look at these, hope I can get the idea.

0 Likes
Message 6 of 6

JamesMaeding
Advisor
Advisor

I have routines that do such overlap detection. The subject comes up in many areas of civil engineering.

The functions are not trivial, and you have to decide on several things when items are really close to touching.

Even if you make the routines to test for intersection, that may be too slow on clip boundaries with say 500 segments.

So you will want to do some kind of bounding box optimization to eliminate crossing tests when say a circle is inside the boundary but its bounding box does not cross any boundary segment boxes. Pick a point on the circle and test if inside or outside the boundary, do not test if the circle hits every segment as it obviously won't.

My routines run fast enough to trim thousands of triangles and the difference between optimization and not is 100 fold in speed.

I'm sure they could be sped up more too, but the point is no optimization will be ugly when running on a lot of stuff with complex boundary.


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

0 Likes