Initializing the Z-axis value to zero
Moderators: SDS, support, admin
Initializing the Z-axis value to zero
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.
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?
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");
}
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
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:
Mikhail
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);
}
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Initializing the Z-axis value to zero
thanks for the awesome information.support wrote: ↑13 Nov 2020, 01:57Hello,
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:MikhailCode: 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); }