Page 1 of 1

CADWipeout

Posted: 18 Jan 2021, 09:54
by Sing
Hello

can you let me know how to create and use a CADWipeout entity to hide entities behind it?

Thank you.

Re: CADWipeout

Posted: 19 Jan 2021, 00:45
by support
Hello,

Please do the following:
  1. Add entities onto a layout or load entities from a drawing file.
  2. Draw a CADWipeout on top of the entities to hide them:

    Code: Select all

    public static void DrawWipeout(CADImage cadImage)
    {
        CADWipeout wipeout = new CADWipeout();
        wipeout.AddPoint(100, 10);
        wipeout.AddPoint(120, 80);
        wipeout.AddPoint(200, 10); 
        cadImage.Converter.Loads(wipeout);
        cadImage.CurrentLayout.AddEntity(wipeout);
    }
    
Mikhail

Re: CADWipeout

Posted: 19 Jan 2021, 05:45
by Sing
Thank you
But it does not work.
and there are some problems as well.

Problems 1. My code changed just a little bit makes a small rectangle (CADWipeout) with a length of 1 mm on each side.
Problems 2. After saving the CADImage as .dwg file by invoking CADImport.Export.CADtoDWG.SaveAsDWG(),
when opening the .dwg file, the collection of CADImage.Converter.Entities do not contain the CADWipeout entity created by the code. However, Autocad 2021 shows me the CADWipeout created and it is a very small size rectangle the same as #1.
Problems 3. If I resize the CADWipeout entity, the application Autodesk Autocad 2021 shutdowns.

Code: Select all


public void DrawWipeout(CADImage cadImage)
{
	CADWipeout wipeout = new CADWipeout();
	wipeout.AddPoint(1616.2307, 7219.5562);
	wipeout.AddPoint(10766.2309, 7219.5562);
	wipeout.AddPoint(10766.2309, 4969.5562);
	wipeout.AddPoint(1616.2307, 4969.5562);
	cadImage.Converter.Loads(wipeout);
	cadImage.CurrentLayout.AddEntity(wipeout);
}

-----------------------------------------------------------------------
CADImport Version: 14.1.0.40930
sgcadexp.dll : Date modified 31st of Jan, 2020
-----------------------------------------------------------------------

Re: CADWipeout

Posted: 21 Jan 2021, 06:44
by Sing
I solved this problem, but I found something strange.
Check the code below.

Code: Select all

CADWipeout wipeout = new CADWipeout();
//
// Don't use method AddPoint().
//
//wipeout.AddPoint(1616.2307, 7219.5562);
//wipeout.AddPoint(10766.2309, 7219.5562);
//wipeout.AddPoint(10766.2309, 4969.5562);
//wipeout.AddPoint(1616.2307, 4969.5562);
//wipeout.AddPoint(1616.2307, 7219.5562);
//
// Set position of wipeout
//
wipeout.Point = new DPoint(-5000, -5000, 0);
//
// Height is not used, so you can assign any number.
// Width is an important property for Wipeout.
// It will be the length of one side of a square.
//
wipeout.Height = 1;
wipeout.Width = 10000;
//
// This is necessary, but I don't know what it is exactly.
//
wipeout.IsUseClipping = true;
wipeout.ClippingBoundaryType = 2;
//
//                | -Y
// -0.5,-0.5 _____|_____  0.5,-0.5
//          |     |     |
//          |     |0,0  |
//  -X -----|-----|-----|------- +X
//          |     |     |
//          |_____|_____|
// -0.5, 0.5      |       0.5, 0.5
//                | +Y
// (^ Point (-0.5,0.5) will be moved to the position of Wipeout.Point)
//
//
// 1. The top and bottom of the y-axis has changed
// 2. The length of a side of the square above is proportional to the length of Wipeout.Width.
// If you add points below to collection ClipPoints, you will see the square with 10000 length of sides.
// wipeout.ClipPoints.Add(new DPoint(.5, .5, 0));
// wipeout.ClipPoints.Add(new DPoint(-.5, .5, 0));
// wipeout.ClipPoints.Add(new DPoint(-.5, -.5, 0));
// wipeout.ClipPoints.Add(new DPoint(.5, -.5, 0));
// wipeout.ClipPoints.Add(new DPoint(.5, .5, 0));
//
wipeout.ClipPoints.Add(new DPoint(.5, .5, 0));
wipeout.ClipPoints.Add(new DPoint(-.5, .5, 0));
wipeout.ClipPoints.Add(new DPoint(-.5, -.5, 0));
wipeout.ClipPoints.Add(new DPoint(.5, -.5, 0));
wipeout.ClipPoints.Add(new DPoint(.5, .5, 0));

cadImage.Converter.Loads(wipeout);
cadImage.CurrentLayout.AddEntity(wipeout);
I hope this code helps someone.

And Mikhail, do you know what the properties Wipeout.IsUseClipping and wipeout.ClippingBoundaryType are?

Re: CADWipeout

Posted: 22 Jan 2021, 21:55
by support
Hello Sing,

Below is the correct code.

Code: Select all

public static void DrawWipeout(CADImage cadImage)
{
    CADWipeout wipeout = new CADWipeout();
    List<DPoint> pts = new List<DPoint>(4);
    pts.Add(new DPoint(5, 5, 0));
    pts.Add(new DPoint(-5, 5, 0));
    pts.Add(new DPoint(-5, -5, 0));
    pts.Add(new DPoint(5, -5, 0));
    DRect box = DRect.BadRect;
    for (int i = 0; i < pts.Count; i++)
        box.Expand(pts[i]);
    wipeout.Point = new DPoint(box.left, box.bottom, 0);
    wipeout.UVector = new DPoint(box.Width, 0, 0);
    wipeout.VVector = new DPoint(0, box.Height, 0);
    wipeout.Size = new DPoint(1, 1, 1);
    wipeout.IsUseClipping = true;
    wipeout.Closed = true;
    wipeout.ClippingBoundaryType = 2;
    wipeout.AddPoint(0.5, 0.5);
    wipeout.AddPoint(0.5, -0.5);
    wipeout.AddPoint(-0.5, -0.5);
    wipeout.AddPoint(-0.5, 0.5);
    cadImage.Converter.Loads(wipeout);
    cadImage.CurrentLayout.AddEntity(wipeout);
}
Thus, at first you should specify the bounding rectangle which then will be used to calculate the insertion point (CADWipeout.Point), U-vector of a single pixel (points along the visual bottom of the image, starting at the insertion point) and V-vector of a single pixel (points along the visual left side of the image, starting at the insertion point).

The property IsUseClipping indicates whether clipping is used, while ClippingBoundaryType specifies clipping boundary type: 1 = Rectangular; 2 = Polygonal.

CADWipeout.AddPoint() method adds clip boundary vertex. For polygonal clip boundary type, three or more vertices must be specified. Polygonal vertices must be listed sequentially.

Mikhail

Re: CADWipeout

Posted: 25 Jan 2021, 01:32
by Sing
Thank you very much, Mikhail

I will try it. I think your code is really helpful for me.