Author Topic: Programmatically determine 'Isolate Objects State' (lamp icon)?  (Read 6903 times)

0 Members and 1 Guest are viewing this topic.

pedroantonio

  • Guest
Can I determine through vb.net if currentlly opened drawing contains Isolated objects (Isolated or Hidden)
which is in AutoCAD Environment visible through icon: bottom right lamp, color: red?

huiz

  • Swamp Rat
  • Posts: 919
  • Certified Prof C3D
Re: Programmatically determine 'Isolate Objects State' (lamp icon)?
« Reply #1 on: May 19, 2012, 06:20:20 AM »
I'm not sure if there is a variable to see if there are hidden objects. But you can search the entities to see if there are entities with the property visible = false.
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

pedroantonio

  • Guest
Re: Programmatically determine 'Isolate Objects State' (lamp icon)?
« Reply #2 on: May 19, 2012, 06:42:00 AM »
But how the Autocad knows that?
I have just tested it and if I set some objects visible=false Autocad is smart enough to know that he is not doing it (the lamp stays yellow).
So i think that he sets some variable or counter to know when he (Autocad) has don that. Or not  :|

BlackBox

  • King Gator
  • Posts: 3770
Re: Programmatically determine 'Isolate Objects State' (lamp icon)?
« Reply #3 on: May 19, 2012, 07:10:19 AM »
Methinks you are confusion the Entity Visible = False with freezing/turning off a layer.
"How we think determines what we do, and what we do determines what we get."

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Programmatically determine 'Isolate Objects State' (lamp icon)?
« Reply #4 on: May 19, 2012, 07:19:49 AM »
Have a look in the Named Object Dictionary ..

Something like acad_objectisolation or somesuch.

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

huiz

  • Swamp Rat
  • Posts: 919
  • Certified Prof C3D
Re: Programmatically determine 'Isolate Objects State' (lamp icon)?
« Reply #5 on: May 19, 2012, 07:34:28 AM »
Methinks you are confusion the Entity Visible = False with freezing/turning off a layer.

Ah, I thought it was used for isolation. Did not test it though.
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

pedroantonio

  • Guest
Re: Programmatically determine 'Isolate Objects State' (lamp icon)?
« Reply #6 on: May 19, 2012, 02:27:46 PM »
Kerry thanks for this tip. Now after I see this dictionary: "ACAD_OBJECTISOLATION"
how to access this dictionary to read .count or something that will gave me a idea if isolated objects are in drawing?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Programmatically determine 'Isolate Objects State' (lamp icon)?
« Reply #7 on: May 19, 2012, 08:00:35 PM »
This may get you started.
At this stage I don't know exactly what the returned ResultBuffer data means.

I think the first list reflects the instance count for the command when run consecutively ....


Code - C#: [Select]
  1.  
  2. // (C) CodeHimBelonga Kdub@theSwamp 2012.05.20  
  3. //
  4.  
  5. using Autodesk.AutoCAD.ApplicationServices;
  6. using Autodesk.AutoCAD.DatabaseServices;
  7. using Autodesk.AutoCAD.EditorInput;
  8. using Autodesk.AutoCAD.Runtime;
  9. using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
  10.  
  11. [assembly: CommandClass(typeof (IsolateTest.MyCommands))]
  12.  
  13. namespace IsolateTest
  14. {
  15.     public class MyCommands
  16.     {
  17.         [CommandMethod(globalName: "Doit", flags: CommandFlags.Modal)]
  18.         public void MyCommand()
  19.         {
  20.             Document doc = AcadApp.DocumentManager.MdiActiveDocument;
  21.             Database db  = doc.Database;
  22.             Editor ed    = doc.Editor;
  23.             const string KEY   = "ACAD_OBJECTISOLATION";
  24.  
  25.             var data = new ResultBuffer();
  26.  
  27.             using (Transaction tr = db.TransactionManager.StartTransaction())
  28.             {
  29.                 var nod =
  30.                     (DBDictionary) tr.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead);
  31.  
  32.                 if ((nod == null) || (!nod.Contains(KEY)))
  33.                 {
  34.                     ed.WriteMessage("\nNo Data attached to NOD");
  35.                     return;
  36.                 }
  37.  
  38.                 var xrecord = (Xrecord) tr.GetObject(nod.GetAt(KEY), OpenMode.ForRead);
  39.  
  40.                 data = xrecord.Data;
  41.  
  42.                 tr.Commit();
  43.             }
  44.             ed.WriteMessage("\nData: " + data.ToString());
  45.         }
  46.     }
  47. }
  48.  


Quote
Command:
Command: netload

Command: doit

No Data attached to NOD
Command:
Command:
Command: ISOLATEOBJECTS
Select objects: Specify opposite corner: 2 found

Select objects:

Command: doit

Data: ((70,0)(70,-1))
Command:
Command:
Command: UNISOLATEOBJECTS
1 object(s) unisolated.

Command:
Command:
Command: HIDEOBJECTS
Select objects: 1 found

Select objects: 1 found, 2 total

Select objects:

Command: doit

Data: ((70,2)(70,-1))
Command:
Command:
Command: UNISOLATEOBJECTS
2 object(s) unisolated.
« Last Edit: May 19, 2012, 08:09:14 PM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

BlackBox

  • King Gator
  • Posts: 3770
Re: Programmatically determine 'Isolate Objects State' (lamp icon)?
« Reply #8 on: May 19, 2012, 10:13:20 PM »
Awesome, Kerry. :beer:

BTW - 'codehimbelonga' lmfao
"How we think determines what we do, and what we do determines what we get."

pedroantonio

  • Guest
Re: Programmatically determine 'Isolate Objects State' (lamp icon)?
« Reply #9 on: May 20, 2012, 12:12:16 AM »
Thanks Kerry! This is better then a start. Now its rolling in right direction...
I'm trying it now... ;)
I will post back if I found something...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Programmatically determine 'Isolate Objects State' (lamp icon)?
« Reply #10 on: May 20, 2012, 02:50:44 AM »
I just did a search for ACAD_OBJECTISOLATION on the ADN, hoping for some clarification of the return data.

No luck. Perhaps someone who knows the meaning of the ResultBuffer.Data returned will amble by.

Regards
Kerry
 
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Programmatically determine 'Isolate Objects State' (lamp icon)?
« Reply #11 on: May 20, 2012, 06:21:05 AM »
Hi,

By my side, using A2011 Vanilla, A2012 MEP or A2013 Vanilla, the ISOLATEOBJECTS and/or HIDEOBJECTS create a AEC_ISOLATED_OBJECTS dictionary containing a AEC_ISOLATED_OBJECTS_XRECORD xrecord.
If they're some hidden objects the xrecord contains these objects ObjectId (a (70, -1) TypedValue otherwise).

Code - C#: [Select]
  1. using Autodesk.AutoCAD.ApplicationServices;
  2. using Autodesk.AutoCAD.DatabaseServices;
  3. using Autodesk.AutoCAD.EditorInput;
  4. using Autodesk.AutoCAD.Runtime;
  5. using AcAp = Autodesk.AutoCAD.ApplicationServices.Application;
  6.  
  7. namespace IsolatedObjectDictionary
  8. {
  9.     public class Commands
  10.     {
  11.         [CommandMethod("Test")]
  12.         public void Test()
  13.         {
  14.             Document doc = AcAp.DocumentManager.MdiActiveDocument;
  15.             Database db = doc.Database;
  16.             Editor ed = doc.Editor;
  17.             ObjectIdCollection hidden = GetHiddenObjects(db);
  18.             if (hidden.Count == 0)
  19.             {
  20.                 ed.WriteMessage("\nNone hidden object found");
  21.             }
  22.             else
  23.             {
  24.                 foreach (ObjectId id in hidden)
  25.                 {
  26.                     ed.WriteMessage("\nHidden entity: {0}", id.ObjectClass.Name);
  27.                 }
  28.             }
  29.         }
  30.  
  31.         public ObjectIdCollection GetHiddenObjects(Database db)
  32.         {
  33.             ObjectIdCollection result = new ObjectIdCollection();
  34.             using (Transaction tr = db.TransactionManager.StartTransaction())
  35.             {
  36.                 DBDictionary NOD = (DBDictionary)tr.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead);
  37.                 if (!NOD.Contains("AEC_ISOLATED_OBJECTS"))
  38.                 {
  39.                     return result;
  40.                 }
  41.                 DBDictionary dict = (DBDictionary)tr.GetObject((ObjectId)NOD["AEC_ISOLATED_OBJECTS"], OpenMode.ForRead);
  42.                 Xrecord xrec = (Xrecord)tr.GetObject((ObjectId)dict["AEC_ISOLATED_OBJECTS_XRECORD"], OpenMode.ForRead);
  43.                 foreach (TypedValue tv in xrec.Data)
  44.                 {
  45.                     if (tv.TypeCode == 340)
  46.                     {
  47.                         result.Add((ObjectId)tv.Value);
  48.                     }
  49.                 }
  50.                 return result;
  51.             }
  52.         }
  53.     }
  54. }
  55.  
« Last Edit: May 20, 2012, 06:41:31 AM by gile »
Speaking English as a French Frog

pedroantonio

  • Guest
Re: Programmatically determine 'Isolate Objects State' (lamp icon)?
« Reply #12 on: May 21, 2012, 12:10:11 PM »
I am using acad 2011 vanilla and I dont have AEC_ISOLATED_OBJECTS or AEC_ISOLATED_OBJECTS_XRECORD :(

The only similar that I have is the one from previous post but i dont get it how could that help. It just shows that Isolated mode has been 1 or more times activated...

Any other ideas maybe  :?

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Programmatically determine 'Isolate Objects State' (lamp icon)?
« Reply #13 on: September 25, 2012, 01:07:22 PM »
Looks like using the ISOLATEOBJECTS command also puts AEC_ISOLATEDOBJECTS_XDATA in each objects XDATA.  Anyone know what for?
Revit 2019, AMEP 2019 64bit Win 10

Jeff H

  • Needs a day job
  • Posts: 6151
Re: Programmatically determine 'Isolate Objects State' (lamp icon)?
« Reply #14 on: September 25, 2012, 02:26:30 PM »
Would using a VisibilityOverrule with a counter incrementing and decrementing the count work?
 
Just a thought no idea if would work or if too much overhead.