Exemple #1
0
        GetSnoopSet()
        {
            try {
                Snoop.ObjIdSet objSet = new Snoop.ObjIdSet("*A");   // TBD: how to deal with named sets? ... later...

                // select the graphic objects they want
                PromptSelectionOptions selOpts = new PromptSelectionOptions();
                selOpts.MessageForAdding = "Select graphical objects for test (or RETURN for none)";
                Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

                PromptSelectionResult res = ed.GetSelection(selOpts);
                if (res.Status == PromptStatus.OK)
                {
                    foreach (ObjectId objId in res.Value.GetObjectIds())     // set these as the original, let dialog add the rest
                    {
                        objSet.AddToSet(objId);
                    }
                }
                else if (res.Status == PromptStatus.Error)
                {
                    ;       // empty selection set
                }
                else
                {
                    return(null);
                }

                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Select non-graphical objects by browsing, right-click on item, choose \"Add to Snoop Set\".");

                using (TransactionHelper trHlp = new TransactionHelper(MgdDbg.Utils.Db.GetCurDwg())) {
                    trHlp.Start();

                    Snoop.Forms.Database form = new Snoop.Forms.Database(trHlp.Database, trHlp);
                    // temporarily hook up the snoop set to the snoop browse dialogs.
                    m_snoopObjSet = objSet;

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        trHlp.Commit();
                        return(objSet);
                    }
                    else
                    {
                        trHlp.Abort();
                        return(null);
                    }
                }
            }
            finally {
                m_snoopObjSet = null;   // reset to null for next invocation
            }
        }