Initializing the Z-axis value to zero

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
Sing
Posts: 48
Joined: 12 Apr 2020, 17:39

Initializing the Z-axis value to zero

Post by Sing » 21 Oct 2020, 07:01

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?

support
Posts: 3254
Joined: 30 Mar 2005, 11:36
Contact:

Re: Initializing the Z-axis value to zero

Post by support » 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
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Sing
Posts: 48
Joined: 12 Apr 2020, 17:39

Re: Initializing the Z-axis value to zero

Post by Sing » 18 Feb 2021, 13:44

Thank you!

JackyJoy
Posts: 1
Joined: 06 Sep 2021, 14:33

Re: Initializing the Z-axis value to zero

Post by JackyJoy » 06 Sep 2021, 14:37

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.

Post Reply