70002827 HowTo Picking and manage a sub entity of a vdInsert object

Article 70002827
Type HowTo
Product Engine
Date Added 1/20/2026 12:00:00 AM
Fixed 11.5.20 (1/20/2026 12:00:00 AM)
Submitted by Yasin Ozdel

Summary

Howto Picking and manage a sub entity of a vdInsert object

Solution

The following code will pick a sub entity of an insert and move it.

//select an item of a vdInsert object, extruct it as a single vdFigure ,add to document model entities and begin a cmdmove command
 doc.Prompt("Pick sub entitiy");
 gPoint pt = doc.ActionUtility.getUserPoint() as gPoint;
 doc.Prompt(null);
 if (pt == null) return;
 Point pixpt = doc.World2PixelMatrix.Transform2GDIPoint(pt);
 vdArray InnerEntities = null;
 vdArray InnerMatrixList = null;

 doc.ActiveLayOut.GetInnerEntitiesListFromPoint(null, pixpt, doc.GlobalRenderProperties.PickSize,out InnerEntities, out InnerMatrixList, false);
 //The InnerEntities returns the entities crossing the pick box in the order from most inner to outer most
 //For example if you pick over a line that belongs to the block of the insert
 //the first item in the InnerEntities will be the line and the second will be the vdInsert object

 //the InnerMatrixList is an array of inner entites matrix in same order, that if applied to the returned figure it will be transformed from entity ECS to World coordinate system.
 if (InnerEntities == null) return;
 vdFigure topmost = InnerEntities.Last() as vdFigure;
 vdInsert ins = topmost as vdInsert;
 if (ins == null) return;
 //get the first figure in the InnerEntities (inner most)
 vdFigure fig = InnerEntities[0].Clone(doc) as vdFigure;

 //do matrix tranformation to get the figure in the world CS
 Matrix figecs = InnerEntities[0].ECSMatrix;//get the selected entity ecs matrix
 Matrix fig_world2ecs_matrix = figecs.GetInvertion();
 fig.Transformby(fig_world2ecs_matrix);//transorm the figure to its ECS matrix
 fig.Transformby(InnerMatrixList[0]);//finally transorm the figure to the World Coordinate System


 //add the clone entity to the model entities
 doc.Model.Entities.AddItem(fig);

 //begin a move command for the new entity and from the pick point
 bool suc = doc.CommandAction.CmdMove(fig, pt, null);

Send comments on this topic.