70001528 Get the objects being copied or moved

Article 70001528
Type HowTo
Product Engine
Version 7
Date Added 5/6/2019
Fixed 8.8002.0.4 (5/6/2019)
Submitted by KiSoo Song


I would like to get the new position of the objects that are being coppied or moved before the end of the copy/move action so I can do some culculations if the new position is valid etc. How can I do this?


You can use the OnActionDraw event when the actions is ActionGetTranfromSelection and use the GetMatrix of the action and there check the objects like :

void doc_OnActionDraw(object sender, object action, bool isHideMode, ref bool cancel)
     if (action != null && action is VectorDraw.Professional.CommandActions.ActionGetTranfromSelection)
         VectorDraw.Professional.CommandActions.ActionGetTranfromSelection trans = action as VectorDraw.Professional.CommandActions.ActionGetTranfromSelection;
         vdSelection sel = trans.Layout.Document.Selections.FindName("VDRAW_PREVIOUS_SELSET");// sel contains the object that are moved/copied/rotated etc.
         if (sel == null || sel.Count == 0) return;
         // this.Text = sel.Count.ToString(); /// for debugging
         Matrix mat = trans.GetMatrix(); // this is the matrix that is applied to the source object by the action
         foreach (vdFigure item in sel)
             vdFigure tempfig = item.Clone(item.Document) as vdFigure; // get a coly of this object being transformed (copied/moved etc)
             tempfig.Transformby(mat);    // transform this with the action’s GetMatrix
             // this tempfig is the temporary figure rendered by action copy/move etc
             // using this tempfig object you can do your calid position check, using bounding box etc

Send comments on this topic.