Author Topic: Isolate Objects - Block Being Disobediant  (Read 5444 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8718
  • AKA Daniel
Re: Isolate Objects - Block Being Disobediant
« Reply #15 on: October 28, 2008, 07:41:55 AM »
Does the above explain it Dan? :)

Yes sir, thank you!!!

Code: [Select]
static void CRPDArxIterate_doit(void)
  {
    Acad::ErrorStatus es;
    long ssLength = 0;

    ads_name sel,ent;
    AcDbObjectId objId, entId, tableRecordId;
    AcDbObjectIdArray ids;

    TCHAR* prompt[] = {_T("\nSelect Objects: "), _T("\nRemove Objects: ")};
    TCHAR* mode = _T(":N:$"); //<<<<----------------------------

    if (acedSSGet(mode, prompt, NULL, NULL, sel) != RTNORM) {
      return;
    }

    if (acedSSLength(sel, &ssLength) != RTNORM || ssLength == 0) {
      acedSSFree(sel);
      return;
    }

    for (long i = 0; i < ssLength; i++){
      acedSSName(sel, i, ent);
      acdbGetObjectId(objId, ent);
      ids.append(objId);
    }

    AcDbDatabase *pDatabase = acdbHostApplicationServices()->workingDatabase();

    //++-- Delete me!
    AcDbBlockTableIterator *pBlockTableIterator = NULL;
    AcDbBlockTableRecordIterator *pBlockTableRecordIterator = NULL;

    AcDbBlockTablePointer pBlockTable(pDatabase,AcDb::kForRead);
    pBlockTable->newIterator(pBlockTableIterator);

    for (pBlockTableIterator->start();
        !pBlockTableIterator->done();
         pBlockTableIterator->step())
    {
      pBlockTableIterator->getRecordId(tableRecordId);
      AcDbBlockTableRecordPointer pTableRecord(tableRecordId,AcDb::kForRead);
      if (es == Acad::eOk)
      {
        AcDbBlockTableRecordIterator *pBlockTableRecordIterator = NULL;
        pTableRecord->newIterator(pBlockTableRecordIterator);

        for (pBlockTableRecordIterator->start();
            !pBlockTableRecordIterator->done();
             pBlockTableRecordIterator->step())
        {
          es = pBlockTableRecordIterator->getEntityId(entId);
          if(!ids.contains(entId) && es == Acad::eOk)
          {
            AcDbEntityPointer pEnt(entId,AcDb::kForWrite,Adesk::kFalse);
            pEnt->setVisibility(kInvisible);
          }
        }
      }
    }
    delete pBlockTableIterator;
    delete pBlockTableRecordIterator;
    acedSSFree(sel);
  }

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8718
  • AKA Daniel
Re: Isolate Objects - Block Being Disobediant
« Reply #16 on: October 28, 2008, 07:47:23 AM »
Quote
":N"
This mode option will cause a subsequent call to acedSSNameX() to provide additional information about container blocks and transformation matrices for any entities selected during the acedSSGet() operation. The additional information will only be available for entities selected via graphical selection methods such as Window, Crossing, point pick, etc.


Hugh_Compton

  • Guest
Re: Isolate Objects - Block Being Disobediant
« Reply #17 on: October 28, 2008, 08:01:02 AM »
Hi Glenn

Your routine works brilliantly...I'm not sure what the difference is yet between yours and mine - I'm going to have to look closely. Thanks! :)

Just out of interest as to why I'm doing this....I'm an ACA user - part of ACA is the ability to isolate / hide / show entities (some of my most common day to day commands).  

It works great but I am trying to make a utility to save visibility states (for instance I might have one state where Pumps are isolated so I can call this 'Pumps Only' and quickly get them in view for working on).  
Using Hide & Isolate in ACA is great but we can't save 'states' i.e. to get only the pumps visible I would have to isolate them each time.  

Visual Studio - 2005 Pro (have 2008 but not using yet)
.Net Framework (sorry, never look at this! using windows XP 64 Pro with all updates)
ACA 2009 / (ACAD 2009 for other users in my company)


TonyT

  • Guest
Re: Isolate Objects - Block Being Disobediant
« Reply #18 on: October 29, 2008, 10:53:57 PM »
Code: [Select]
static void CRPDArxIterate_doit(void)
  {

    <snip>

    for (long i = 0; i < ssLength; i++){
      acedSSName(sel, i, ent);
      acdbGetObjectId(objId, ent);
      ids.append(objId);
    }

    <snip>

  }


Tip:

Instead of the above, you can just do this:

Code: [Select]

     AcDbObjectIdArray ids = acedGetCurrentSelectionSet();




It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8718
  • AKA Daniel
Re: Isolate Objects - Block Being Disobediant
« Reply #19 on: October 30, 2008, 12:08:43 AM »
Wonderful! I actually did a search for something like this. The ODA’s DRX SDK has a nice SelectionSet class
with a method that returns an ObjectIdArray. I knew there had to be a better way in ARX.  8-)

Thanks Tony!