Active Contributor
Posts: 42
Registered: ‎11-06-2012
Message 1 of 4 (592 Views)

JIG multiple entities

592 Views, 3 Replies
03-26-2013 01:37 AM

Hi Pro,


How to Jig multiple entities such as insert a block and add a line.



*Expert Elite*
Posts: 2,078
Registered: ‎04-29-2006
Message 2 of 4 (583 Views)

Re : JIG multiple entities

03-26-2013 02:10 AM in reply to: xdbk07



You can build a class which derives from DrawJig.


Here's a little example to drag multiple entities. The entites passed to DragEntitiesJig instance have to be opened within a transaction.


    class DragEntitiesJig : DrawJig
        Point3d basePoint, dragPoint;
        IEnumerable<Entity> ents;

        public DragEntitiesJig(IEnumerable<Entity> ents, Point3d basePoint)
            this.basePoint = basePoint;
            this.ents = ents;

        protected override bool WorldDraw(WorldDraw draw)
            WorldGeometry wGeom = draw.Geometry;
            Matrix3d disp = Matrix3d.Displacement(this.basePoint.GetVectorTo(this.dragPoint));
            foreach (Entity ent in this.ents)
            return true;

        protected override SamplerStatus Sampler(JigPrompts prompts)
            JigPromptPointOptions options = new JigPromptPointOptions("\nSecond point: ");
            options.BasePoint = this.basePoint;
            options.UseBasePoint = true;
            options.Cursor = CursorType.RubberBand;
            options.UserInputControls = UserInputControls.Accept3dCoordinates;
            PromptPointResult ppr = prompts.AcquirePoint(options);
            if (ppr.Value.IsEqualTo(this.dragPoint))
                return SamplerStatus.NoChange;
            this.dragPoint = ppr.Value;
            return SamplerStatus.OK;


Gilles Chanteau
Posts: 1,398
Registered: ‎04-09-2008
Message 3 of 4 (582 Views)

Re: JIG multiple entities

03-26-2013 02:14 AM in reply to: xdbk07
*Expert Elite*
Posts: 1,569
Registered: ‎10-08-2008
Message 4 of 4 (540 Views)

Re: JIG multiple entities

03-26-2013 12:59 PM in reply to: xdbk07

Here is code example very limited tested on A2010

see if this works,keep in mind, to change Clone method jn

DeepCloneObjects if your entities have Xdata embedded

        // based on Kean Walmsley example (jig mtext)
        public void MoveCopyJig()
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database db = HostApplicationServices.WorkingDatabase;
            Editor ed = doc.Editor;
                using (Transaction tr = doc.TransactionManager.StartTransaction())
                    SelectionSet sset = ed.GetSelection().Value;
                    Point3d basept = ed.GetPoint("\nBase point: ").Value;
                    IEnumerable<Entity> objs = sset.GetObjectIds().Select(x => (Entity)tr.GetObject(x, OpenMode.ForRead)).ToArray();
                    BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                    foreach (Entity e in objs)
                        Entity c = (Entity)e.Clone();// you may want to use DeepCloneObjects instead
                        tr.AddNewlyCreatedDBObject(c, true);


                    PromptSelectionResult psr = ed.SelectImplied();

                    // drag our jig

                    if (psr.Status == PromptStatus.OK)
                        // jig whole selection

                        PromptPointResult ppr =
                            "\nSpecify displacement point: ",
                            delegate(Point3d pt, ref Matrix3d mat)
                                // If no change has been made, say so
                                if (basept == pt)
                                    return SamplerStatus.NoChange;
                                    // Otherwise we return the displacement
                                    // matrix for the current position
                                    mat = Matrix3d.Displacement(basept.GetVectorTo(pt)
                                return SamplerStatus.OK;

                        // Assuming it works, transform our MText
                        // appropriately

                        if (ppr.Status == PromptStatus.OK)
                            // Get the final translation matrix

                            Matrix3d mat = Matrix3d.Displacement(basept.GetVectorTo(ppr.Value)

                            foreach (Entity en in objs)
                        // Finally we commit our transaction
            catch (System.Exception ex)



You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community