Code Red > .NET

Check if Nested or Not

(1/2) > >>

nobody:
Want people to select an entity (polylines/lines/arcs) whether it's in an xref or not.  I can't think of any other way except prompting for a point "near" then testing to see if it's nested if it returns a valid object ID. Is there a better way? 

Jeff H:
Not sure I follow exactly what your asking and why you need to prompt for a point near it but here is an example where command prompts for selecting an object in an xref then opens the xrefs and zooms to it.

It checks the ObjectId.Database.UnmangedObject matches the current Database.UnmanagedObject.

--- Code - C#: ---        private static Handle? hnd = null;        [CommandMethod("zoomxref")]        public void zoomxref()        {            hnd = null;            var pneo = new PromptNestedEntityOptions("\nSelect xref object");            var pner = Ed.GetNestedEntity(pneo);            if (pner.Status != PromptStatus.OK)            {                return;            }             var id = pner.ObjectId;            if (id.Database.UnmanagedObject == Db.UnmanagedObject)            {                Ed.WriteLine("Select xref object");                return;            }             foreach (ObjectId conId in pner.GetContainers())            {                if (conId.Database.UnmanagedObject == pner.ObjectId.Database.UnmanagedObject)                {                    id = conId;                }             }             using (Transaction trx = Doc.TransactionManager.StartTransaction())            {                var ent = id.GetEntity();                hnd = ent.Handle;                trx.Commit();            }             var doc = Application.DocumentManager.Open(pner.ObjectId.Database.Filename, false);            doc.SendStringToExecute("zoomxrefobject ", true, false, false);         }          [CommandMethod("zoomxrefobject", CommandFlags.NoHistory)]        public void zoomxrefobject()        {            if (!hnd.HasValue) return;            var id = Db.GetObjectId(false, (Handle)hnd, 0);            var ss = SelectionSet.FromObjectIds(new ObjectId[] { id });            Ed.Command("_Zoom", "_Object", ss, "");        }   

nobody:
Thanks!

nobody:
Strangly enough...I did not think to even try at first...but the prompt nested entity thing worked for my object that wasn't an xref or block XD  Had no idea it would bahhahaa

Keith Brown:
Jeff,


Can you explain why you would use the UnmanagedObject property of the Database vs just comparing Databases?  Is it more correct?

Navigation

[0] Message Index

[#] Next page

Go to full version