60002120 cmdExtend and cmdTrim with selection

Article 60002120
Type Wish
Product Engine
Version 6027
Date Added 1/13/2014 12:00:00 AM
Fixed (1/28/2014 12:00:00 AM)
Submitted by Amancio

Summary

Is it possible in cmdTrim and cmdExtend to pass a collection of objects or ask the user to select multiple entities as ObjectsToTrim and ObjectsToExtend ?

Solution

In the 6028 version new CmdTrim and CmdExtend overload methods were added. Using this methods, the user can select entities as bounding entities used to extend/trim other selected entities with a single click select or single window crossing or polyline crossing selection.

How to use CmdTrim(object, objetc, bool) command.

Parameters

object BoundEntities: A (vdSelection) collection of vdFigures or "USER",null so the user picks the objects to the screen.
object ObjectToTrim: An array of 2 objects(object[]) containing one vdFigure and a gPoint that determines the trim side OR "USER",null so the user picks the object to the screen.
Boolean EdgeTrim: A boolean representing if the extension of the boundary entities is going to be used to calculate the object's trim. This also alters the vdDocument's EdgeExtendTrim global property.

Returns True if at least one trim operation was successful else it returns False

Usage Example CmdTrim
ActiveDocument.CommandAction.CmdTrim(null, null, false); //The user will be instructed to perform certain actions in order to complete trim command.
See below sample code also

User Interface of CmdTrim
Using the CmdTrim command, an Action will be initiated, prompting the user to select the entities to be trimmed.



During this step of the command you can define the boundary entities that will be used in order to trim the entities you want. You can do that by clicking on the entities one by one, using window selection (or cross selection) or polygon selection. To use window selection just click on the empty space of the drawing area, a transparent window will show. Similarly to all the Select commands, if you move your cursor to the right the right the window will be blue, if you move to the left, it will be green. As it is known to most CAD applications, Green window is named "cross window selection" and selects all entities that partially or entirely, lie in the selection area.
In this example we will use the green selection window.




Click once more and the Selection action will be completed. The two polylines passing through the green window will be highlighted indicating that they got selected and these will be the trim bounding entities.




In this step you select the entities and the side of them that will be trimmed. You can select them by one single click or by a window crossing (by clicking in empty spase or entering "w").




Or by drawing a fence polyline that selects the objects and also defines the trimming side.




If you type "e" you change the Edge Trim and also alter the EdgeExtendTrim property of the vdDocument. When this value is ON (true) the trim will be done using the boundary entities AND the extension of them while when this is OFF (false) then the trim doesn't conside the extension of the boundary entities.




You can also press "r" to Erase some unwanted entities during the trim command and of course type "u" to undo the latest trim action performed previously.


By pressing right-click or ESC keyboard key you end the command.

 

Sample Code
The CmdTrim can also be used without user interaction like:

        private void CmdTrim_Demo()
        {
            vdDocument doc = vdFramedControl1.BaseControl.ActiveDocument;
            vdLine lin_t = new vdLine(doc, new gPoint(12, 5), new VectorDraw.Geometry.gPoint(-5, 5));
            doc.Model.Entities.AddItem(lin_t); // this line will be trimed
 
            //Console.WriteLine("line to be trimed handle is: " + lin_t.Handle.ToString());
            vdSelection set_cut = new vdSelection();
            set_cut.SetUnRegisterDocument(doc);
            set_cut.Name = "CUT";
            set_cut.RemoveAll();
            doc.Selections.AddItem(set_cut);
 
            vdLine lin_cut = new vdLine(doc, new gPoint(10, 10), new VectorDraw.Geometry.gPoint(10, 0)); 
            doc.Model.Entities.AddItem(lin_cut); 
            set_cut.AddItem(lin_cut,true,vdSelection.AddItemCheck.Nochecking);
            lin_cut = new vdLine(doc, new gPoint(5, 10), new VectorDraw.Geometry.gPoint(5, 0));
            doc.Model.Entities.AddItem(lin_cut);// add two lines that will be used to trim the lin_t
            set_cut.AddItem(lin_cut, true, vdSelection.AddItemCheck.Nochecking);
 
            //use the two lines in set_cut and trim the lin_t where in the part that point 7,5 is
            doc.CommandAction.CmdTrim(set_cut, new object[] {lin_t, new gPoint(7,5)}, doc.EdgeExtendTrim);
        }

 

 

How to use CmdExtend(object, objetc, bool) command.

Parameters

object BoundEntities: A (vdSelection) collection of vdFigures or "USER",null so the user picks the objects to the screen.
object ObjectToExtend: An array of 2 objects(object[]) containing one vdFigure and a gPoint that determines the extend side OR "USER",null so the user picks the object to the screen.
Boolean EdgeExtend: A boolean representing if the extension of the boundary entities is going to be used to calculate the object's extension. This also alters the vdDocument's EdgeExtendTrim global property.

Returns True if at least one extend operation was successful else it returns False

Usage Example CmdExtend
ActiveDocument.CommandAction.CmdExtend(null, null, false); //The user will be instructed to perform certain actions in order to complete extend command.
See below sample code also

User Interface of CmdExtend
Using the CmdExtend command, an Action will be initiated, prompting the user to select the entities to be extended.



During this step of the command you can define the boundary entities that will be used in order to extend the entities you want. You can do that by clicking on the entities one by one, using window selection (or cross selection) or polygon selection. To use window selection just click on the empty space of the drawing area, a transparent window will show. Similarly to all the Select commands, if you move your cursor to the right the right the window will be blue, if you move to the left, it will be green.




In this step you select the entities and the side of them that will be extended using the previously selected boundary objects. You can select them by one single click like the arc above.




Or by a window crossing (by clicking in empty space or entering "w". Click once more and the Selection action will be completed. The two lines and the arc passing through the green window will be highlighted indicating that they got selected and these will be the extended .




Or by drawing a fence polyline that selects the objects and also defines the extending side.




If you type "e" you change the EdgeExtend and also alter the EdgeExtendTrim property of the vdDocument. When this value is ON (true) the trim will be done using the boundary entities AND the extension of them while when this is OFF (false) then the EXTEND doesn't consider the extension of the boundary entities. Also by pressing "u" you undo the latest extend made by this command and by pressing right-click or ESC keyboard key you end the command.

Sample Code
The CmdExtend can also be used without user interaction like:

        private void CmdExtend_Demo()
        {
            vdDocument doc = vdFramedControl1.BaseControl.ActiveDocument;
            vdLine lin_2_Ext = new vdLine(doc, new gPoint(7.5, 5), new VectorDraw.Geometry.gPoint(3, 5));
            doc.Model.Entities.AddItem(lin_2_Ext); // this line will be extended

            //Console.WriteLine("line to be extended handle is: " + lin_2_Ext.Handle.ToString());
            vdSelection set_bound_ext = new vdSelection();
            set_bound_ext.SetUnRegisterDocument(doc);
            set_bound_ext.Name = "Extend";
            set_bound_ext.RemoveAll();
            doc.Selections.AddItem(set_bound_ext);

            vdLine bound_line = new vdLine(doc, new gPoint(10, 10), new VectorDraw.Geometry.gPoint(10, 0));
            doc.Model.Entities.AddItem(bound_line);
            set_bound_ext.AddItem(bound_line, true, vdSelection.AddItemCheck.Nochecking);
            bound_line = new vdLine(doc, new gPoint(1, 10), new VectorDraw.Geometry.gPoint(1, 0));
            doc.Model.Entities.AddItem(bound_line);// add two lines that will be used to extend the lin_2_Ext
            set_bound_ext.AddItem(bound_line, true, vdSelection.AddItemCheck.Nochecking);

            //use the two lines in set_bound_ext and extend the lin_2_Ext in the part that point 7,5 is
            doc.CommandAction.CmdExtend(set_bound_ext, new object[] { lin_2_Ext, new gPoint(7, 5) }, doc.EdgeExtendTrim);
            //and again, use the two lines in set_bound_ext and extend the lin_2_Ext in the part that point 6,5 is
            doc.CommandAction.CmdExtend(set_bound_ext, new object[] { lin_2_Ext, new gPoint(4, 5) }, doc.EdgeExtendTrim);
        }

Send comments on this topic.