70002126 Create an xCliped Insert from a user's selection rectangle

Article 70002126
Type HowTo
Product Engine
Version 8
Date Added 1/3/2022 12:00:00 AM
Fixed 9.9003.0.4 (1/3/2022 12:00:00 AM)
Submitted by Mario Pellegrino


Create an xCliped Insert from a user's selection rectangle


The following code will
1) Ask the user for a rectangle
2) Perform a selection using the user’s rect
3) Create a block with the selected cloned entities
4) Create a polyline with the user’s rect in order to use it for clip figure for the insert
5) Create an insert for this block and also set it’s clipBoundary figure
6) Create a new Document with this Insert and then export this Document as test.dwg

                vdSelection selset = new vdSelection("test");
                Box retrect = null;
                doc.Prompt("Pick a rectangle that contains the entities you want to clip:");
                VectorDraw.Actions.StatusCode sc = doc.ActionUtility.getUserRectViewCS(null, out retrect);
                if (sc != StatusCode.Success) return;
                gPoints pts = new gPoints(); pts.AddRange(retrect);
                bool ret = selset.Select(RenderSelect.SelectingMode.CrossingWindowPolygon, pts);
                if (selset.Count > 0)
                    vdBlock blk = new vdBlock(doc, "xclipBlock");
                    foreach (vdFigure  item in selset)
                    vdInsert Insert = new vdInsert(doc);
                    Insert.Block = blk;
                    vdPolyline xClipPolyline = new vdPolyline (doc,pts);
                    Insert.ClipBoundary = xClipPolyline;
                    vdSelection NewSel = new vdSelection("SelectionForCopy");
                    NewSel.AddItem(Insert, false, vdSelection.AddItemCheck.Nochecking);
                    vdDocumentComponent NewDoc = new vdDocumentComponent();


Send comments on this topic.