Page 1 of 1

Initializing the Z-axis value to zero

Posted: 21 Oct 2020, 07:01
by Sing
Hello

When checking if a box of polyline contains a point (DPoint) or rect (DRect) of CADLWPolyline or CADText, I use the 'Contains' method of CADLWPolyline or CADText Entities.

Code: Select all

if (dPolyline.Box.Contains(cadText.Box.Center))
{
	Console.WriteLine("Contained");
}
However, if the Z-axis values ​​are different, you cannot get the correct result.
I do not use Z-axis values. So I would like to initialize the z-axis values of all entities.

Is there a way for it?

Re: Initializing the Z-axis value to zero

Posted: 13 Nov 2020, 01:57
by support
Hello,

You may zero-initialize DRect.z1 and DRect.z2 for the bounding boxes you are checking and then call a DRect.Contains method on the modified DRect objects:

Code: Select all

public bool IsContains2D(DRect box1, DRect box2)
{
    box1.z1 = 0;
    box1.z2 = 0;
    box2.z1 = 0;
    box2.z2 = 0;
    return box1.Contains(box2);
}
Mikhail

Re: Initializing the Z-axis value to zero

Posted: 18 Feb 2021, 13:44
by Sing
Thank you!

Re: Initializing the Z-axis value to zero

Posted: 06 Sep 2021, 14:37
by JackyJoy
support wrote:
13 Nov 2020, 01:57
Hello,

You may zero-initialize DRect.z1 and DRect.z2 for the bounding boxes you are checking and then call a DRect.Contains method on the modified DRect objects:

Code: Select all

public bool IsContains2D(DRect box1, DRect box2)
{
    box1.z1 = 0;
    box1.z2 = 0;
    box2.z1 = 0;
    box2.z2 = 0;
    return box1.Contains(box2);
}
Mikhail
thanks for the awesome information.