コード例 #1
0
 event_PromptForEntityEnding(object sender, PromptForEntityEndingEventArgs e)
 {
     PrintEventMessage(sender, "Prompt For Entity Ending");
     if (m_showDetails)
     {
     }
 }
コード例 #2
0
        OnPromptForEntityEnding(object sender, PromptForEntityEndingEventArgs e)
        {
            if (e.Result.Status == PromptStatus.OK)
            {
                Editor   ed    = sender as Editor;
                ObjectId objId = e.Result.ObjectId;
                Database db    = objId.Database;

                try
                {
                    using (Transaction tr = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
                    {
                        // First get the currently selected object and check whether it's a block reference
                        BlockReference br = tr.GetObject(objId, OpenMode.ForRead) as BlockReference;
                        if (br != null)
                        {
                            // If so, we check whether the block table record to which it refers is actually from an XRef
                            ObjectId         btrId = br.BlockTableRecord;
                            BlockTableRecord btr   = tr.GetObject(btrId, OpenMode.ForRead) as BlockTableRecord;
                            if (btr != null)
                            {
                                if (btr.IsFromExternalReference)
                                {
                                    // If so, then we programmatically select the object underneath the pick-point already used
                                    PromptNestedEntityOptions pneo = new PromptNestedEntityOptions("");
                                    pneo.NonInteractivePickPoint    = e.Result.PickedPoint;
                                    pneo.UseNonInteractivePickPoint = true;

                                    PromptNestedEntityResult pner = ed.GetNestedEntity(pneo);

                                    if (pner.Status == PromptStatus.OK)
                                    {
                                        try
                                        {
                                            ObjectId selId = pner.ObjectId;

                                            // Let's look at this programmatically-selected object, to see what it is

                                            DBObject obj = selId.GetObject(OpenMode.ForRead);

                                            // If it's a polyline vertex, we need to go one level up to the polyline itself

                                            if (obj is PolylineVertex3d || obj is Vertex2d)
                                            {
                                                selId = obj.OwnerId;
                                            }

                                            // We don't want to do anything at all for textual stuff, let's also make sure we
                                            // are dealing with an entity (should always be the case)

                                            if (obj is MText || obj is DBText || !(obj is Entity))
                                            {
                                                return;
                                            }

                                            // Now let's get the name of the layer, to use later

                                            Entity           ent     = (Entity)obj;
                                            LayerTableRecord ltr     = (LayerTableRecord)tr.GetObject(ent.LayerId, OpenMode.ForRead);
                                            string           layName = ltr.Name;

                                            // Clone the selected object

                                            object o     = ent.Clone();
                                            Entity clone = o as Entity;

                                            // We need to manipulate the clone to make sure it works

                                            if (clone != null)
                                            {
                                                // Setting the properties from the block reference helps certain entities get the
                                                // right references (and allows them to be offset properly)
                                                clone.SetPropertiesFrom(br);

                                                // But we then need to get the layer information from the database to set the
                                                // right layer (at least) on the new entity

                                                LayerTable lt = (LayerTable)tr.GetObject(db.LayerTableId, OpenMode.ForRead);
                                                if (lt.Has(layName))
                                                {
                                                    clone.LayerId = lt[layName];
                                                }

                                                // Now we need to transform the entity for each of its Xref block reference containers
                                                // If we don't do this then entities in nested Xrefs may end up in the wrong place

                                                ObjectId[] conts = pner.GetContainers();
                                                foreach (ObjectId contId in conts)
                                                {
                                                    BlockReference cont = tr.GetObject(contId, OpenMode.ForRead) as BlockReference;
                                                    if (cont != null)
                                                    {
                                                        clone.TransformBy(cont.BlockTransform);
                                                    }
                                                }

                                                // Let's add the cloned entity to the current space

                                                BlockTableRecord space = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
                                                if (space == null)
                                                {
                                                    clone.Dispose();
                                                    return;
                                                }

                                                ObjectId cloneId = space.AppendEntity(clone);
                                                tr.AddNewlyCreatedDBObject(clone, true);

                                                // Now let's flush the graphics, to help our clone get displayed

                                                tr.TransactionManager.QueueForGraphicsFlush();

                                                // And we add our cloned entity to the list for deletion

                                                _ids.Add(cloneId);

                                                // Created a non-graphical selection of our newly created object and replace it with
                                                // the selection of the container Xref

                                                IntPtr         ip = (IntPtr)0;
                                                SelectedObject so = new SelectedObject(cloneId, SelectionMethod.NonGraphical, ip);  //?????????????????????????????????
                                                e.ReplaceSelectedObject(so);
                                            }
                                        }
                                        catch (System.Exception ex)
                                        {
                                            BaseObjs.writeDebug(ex.Message + " xRefOffsetApp.cs: line: 259");
                                        }
                                    }
                                }
                            }
                        }
                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " xRefOffsetApp.cs: line: 270");
                }
            }
        }
コード例 #3
0
 private void callback_PromptForEntityEnding(object sender, PromptForEntityEndingEventArgs e)
 {
     WriteLine(String.Format("PromptForEntityEnding"));
 }
コード例 #4
0
 private void callback_PromptForEntityEnding(object sender, PromptForEntityEndingEventArgs e)
 {
     WriteLine(String.Format("PromptForEntityEnding"));
 }
コード例 #5
0
        CollectEvent(object sender, CollectorEventArgs e)
        {
            // cast the sender object to the SnoopCollector we are expecting
            Collector snoopCollector = sender as Collector;

            if (snoopCollector == null)
            {
                Debug.Assert(false);    // why did someone else send us the message?
                return;
            }

            // see if it is a type we are responsible for
            Editor editor = e.ObjToSnoop as Editor;

            if (editor != null)
            {
                Stream(snoopCollector.Data(), editor);
                return;
            }

            PromptOptions promptOpts = e.ObjToSnoop as PromptOptions;

            if (promptOpts != null)
            {
                Stream(snoopCollector.Data(), promptOpts);
                return;
            }

            PromptStringOptionsEventArgs promptStringArgs = e.ObjToSnoop as PromptStringOptionsEventArgs;

            if (promptStringArgs != null)
            {
                Stream(snoopCollector.Data(), promptStringArgs);
                return;
            }

            PromptSelectionOptionsEventArgs promptSelectionArgs = e.ObjToSnoop as PromptSelectionOptionsEventArgs;

            if (promptSelectionArgs != null)
            {
                Stream(snoopCollector.Data(), promptSelectionArgs);
                return;
            }

            PromptSelectionOptions promptSelectionOpts = e.ObjToSnoop as PromptSelectionOptions;

            if (promptSelectionOpts != null)
            {
                Stream(snoopCollector.Data(), promptSelectionOpts);
                return;
            }

            PromptPointOptionsEventArgs promptPointArgs = e.ObjToSnoop as PromptPointOptionsEventArgs;

            if (promptPointArgs != null)
            {
                Stream(snoopCollector.Data(), promptPointArgs);
                return;
            }

            PromptNestedEntityResultEventArgs promptNestResultArgs = e.ObjToSnoop as PromptNestedEntityResultEventArgs;

            if (promptNestResultArgs != null)
            {
                Stream(snoopCollector.Data(), promptNestResultArgs);
                return;
            }

            PromptResult promptResult = e.ObjToSnoop as PromptResult;

            if (promptResult != null)
            {
                Stream(snoopCollector.Data(), promptResult);
                return;
            }

            PromptKeywordOptionsEventArgs promptKeywordArgs = e.ObjToSnoop as PromptKeywordOptionsEventArgs;

            if (promptKeywordArgs != null)
            {
                Stream(snoopCollector.Data(), promptKeywordArgs);
                return;
            }

            PromptIntegerOptionsEventArgs promptIntArgs = e.ObjToSnoop as PromptIntegerOptionsEventArgs;

            if (promptIntArgs != null)
            {
                Stream(snoopCollector.Data(), promptIntArgs);
                return;
            }

            PromptEntityOptionsEventArgs promptEntArgs = e.ObjToSnoop as PromptEntityOptionsEventArgs;

            if (promptEntArgs != null)
            {
                Stream(snoopCollector.Data(), promptEntArgs);
                return;
            }

            PromptDoubleOptionsEventArgs promptDoubleArgs = e.ObjToSnoop as PromptDoubleOptionsEventArgs;

            if (promptDoubleArgs != null)
            {
                Stream(snoopCollector.Data(), promptDoubleArgs);
                return;
            }

            PromptSelectionResult prSelRes = e.ObjToSnoop as PromptSelectionResult;

            if (prSelRes != null)
            {
                Stream(snoopCollector.Data(), prSelRes);
                return;
            }

            SelectionSet selSet = e.ObjToSnoop as SelectionSet;

            if (selSet != null)
            {
                Stream(snoopCollector.Data(), selSet);
                return;
            }

            SelectedObject selObj = e.ObjToSnoop as SelectedObject;

            if (selObj != null)
            {
                Stream(snoopCollector.Data(), selObj);
                return;
            }

            SelectedSubObject selSubObj = e.ObjToSnoop as SelectedSubObject;

            if (selSubObj != null)
            {
                Stream(snoopCollector.Data(), selSubObj);
                return;
            }

            SelectionDetails selDetails = e.ObjToSnoop as SelectionDetails;

            if (selDetails != null)
            {
                Stream(snoopCollector.Data(), selDetails);
                return;
            }

            SelectionRemovedEventArgs selRemovedArgs = e.ObjToSnoop as SelectionRemovedEventArgs;

            if (selRemovedArgs != null)
            {
                Stream(snoopCollector.Data(), selRemovedArgs);
                return;
            }

            SelectionAddedEventArgs selAddedArgs = e.ObjToSnoop as SelectionAddedEventArgs;

            if (selAddedArgs != null)
            {
                Stream(snoopCollector.Data(), selAddedArgs);
                return;
            }

            DraggingEndedEventArgs dragEndArgs = e.ObjToSnoop as DraggingEndedEventArgs;

            if (dragEndArgs != null)
            {
                Stream(snoopCollector.Data(), dragEndArgs);
                return;
            }

            InputPointContext inputPtCntxt = e.ObjToSnoop as InputPointContext;

            if (inputPtCntxt != null)
            {
                Stream(snoopCollector.Data(), inputPtCntxt);
                return;
            }

            Keyword keyword = e.ObjToSnoop as Keyword;

            if (keyword != null)
            {
                Stream(snoopCollector.Data(), keyword);
                return;
            }

            PointFilterEventArgs ptFilterEventArgs = e.ObjToSnoop as PointFilterEventArgs;

            if (ptFilterEventArgs != null)
            {
                Stream(snoopCollector.Data(), ptFilterEventArgs);
                return;
            }

            PointFilterResult ptFilterRes = e.ObjToSnoop as PointFilterResult;

            if (ptFilterRes != null)
            {
                Stream(snoopCollector.Data(), ptFilterRes);
                return;
            }

            PointMonitorEventArgs ptMonitorArgs = e.ObjToSnoop as PointMonitorEventArgs;

            if (ptMonitorArgs != null)
            {
                Stream(snoopCollector.Data(), ptMonitorArgs);
                return;
            }

            PromptAngleOptionsEventArgs promptAngleOptsArgs = e.ObjToSnoop as PromptAngleOptionsEventArgs;

            if (promptAngleOptsArgs != null)
            {
                Stream(snoopCollector.Data(), promptAngleOptsArgs);
                return;
            }

            PromptDistanceOptionsEventArgs promptDistanceOptsArgs = e.ObjToSnoop as PromptDistanceOptionsEventArgs;

            if (promptDistanceOptsArgs != null)
            {
                Stream(snoopCollector.Data(), promptDistanceOptsArgs);
                return;
            }

            PromptDoubleResultEventArgs promptDoubleResArgs = e.ObjToSnoop as PromptDoubleResultEventArgs;

            if (promptDoubleResArgs != null)
            {
                Stream(snoopCollector.Data(), promptDoubleResArgs);
                return;
            }

            PromptFileOptions promptFileOpts = e.ObjToSnoop as PromptFileOptions;

            if (promptFileOpts != null)
            {
                Stream(snoopCollector.Data(), promptFileOpts);
                return;
            }

            PromptForEntityEndingEventArgs promptForEntEndArgs = e.ObjToSnoop as PromptForEntityEndingEventArgs;

            if (promptForEntEndArgs != null)
            {
                Stream(snoopCollector.Data(), promptForEntEndArgs);
                return;
            }

            PromptForSelectionEndingEventArgs promptForSelEndArgs = e.ObjToSnoop as PromptForSelectionEndingEventArgs;

            if (promptForSelEndArgs != null)
            {
                Stream(snoopCollector.Data(), promptForSelEndArgs);
                return;
            }

            PromptNestedEntityOptions promptNestEntOpts = e.ObjToSnoop as PromptNestedEntityOptions;

            if (promptNestEntOpts != null)
            {
                Stream(snoopCollector.Data(), promptNestEntOpts);
                return;
            }

            PromptNestedEntityOptionsEventArgs promptNestEntOptsArgs = e.ObjToSnoop as PromptNestedEntityOptionsEventArgs;

            if (promptNestEntOptsArgs != null)
            {
                Stream(snoopCollector.Data(), promptNestEntOptsArgs);
                return;
            }

            PromptSelectionResultEventArgs promptSelResArgs = e.ObjToSnoop as PromptSelectionResultEventArgs;

            if (promptSelResArgs != null)
            {
                Stream(snoopCollector.Data(), promptSelResArgs);
                return;
            }

            // ValueTypes we have to treat a bit different
            if (e.ObjToSnoop is PickPointDescriptor)
            {
                Stream(snoopCollector.Data(), (PickPointDescriptor)e.ObjToSnoop);
                return;
            }
        }
コード例 #6
0
        Stream(ArrayList data, PromptForEntityEndingEventArgs promptForEntEndArgs)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(PromptForEntityEndingEventArgs)));

            data.Add(new Snoop.Data.Object("Result", promptForEntEndArgs.Result));
        }