How to Check if a Block is Inside a Polyline

How to Check if a Block is Inside a Polyline

csharp_dev
Contributor Contributor
223 Views
1 Reply
Message 1 of 2

How to Check if a Block is Inside a Polyline

csharp_dev
Contributor
Contributor

I'm building an application that needs to run both in interactive AutoCAD and in headless/cloud environments such as the Design Automation API or accoreconsole.exe.

 

In AutoCAD, users may place blocks inside a polyline, I need to programmatically determine whether a block is completely within a polyline.

 

Since I can't use built-in methods like SelectWindowPolygon or SelectCrossingPolygon in headless mode, I've tried the following approaches:

1. Bounding Box Method:
I created a bounding box using the minimum and maximum points of the block and checked whether this box is completely inside the polyline. However, in some cases, the bounding box extends beyond the polyline even though the block visually appears to be inside it.

2. Base Point Method:
I checked whether the base point of the block is inside the polyline. But in some cases, the base point is outside, even though the block visually appears inside the polyline.

 

My Question:
Is there any reliable way to get the actual minimum and maximum points that represent the visible extent of a block? Or are there any other methods/commands that can help determine whether a block is inside a polyline, especially in a headless/cloud environment?

 

Any suggestions or guidance would be greatly appreciated. Thank you!

0 Likes
224 Views
1 Reply
Reply (1)
Message 2 of 2

_gile
Consultant
Consultant

Hi,

You can check if the center of the block extents is inside the polyline and if there's no intersection between the block and the polyline.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub