Author Topic: Reading and Saving Attribute values. ala DBX..  (Read 10734 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8728
  • AKA Daniel
Re: Reading and Saving Attribute values. ala DBX..
« Reply #15 on: August 24, 2009, 08:39:59 AM »
here is an ARX version, probably not any faster since IO is the time consuming item.

Code: [Select]
  static void ArxBlockEx_doit(void)
  {
    clock_t start, end;
    double diff;
    start = clock();

    for(int i = 0 ; i < 500; i++)
    {   
      std::auto_ptr<AcDbDatabase> pDb (new AcDbDatabase(false , true));
      pDb->readDwgFile(_T("C:\\Test20090823.dwg"),  _SH_DENYNO ,false);
      GetAttributesBench_doit(&(*pDb), _T("BBL_V8"));
      pDb->closeInput(true);
    }
    end = clock();
    diff = ((double)(end - start)) / CLOCKS_PER_SEC;
    acutPrintf( _T("\n%2.3f seconds\n"), diff);
  }


  static void GetAttributesBench_doit(AcDbDatabase *pDatabase, const CString &name)
  {
    Acad::ErrorStatus es;
    std::wofstream out(_T("C:\\Test20090823.txt"));

    AcDbBlockTablePointer pBlockTable(pDatabase,AcDb::kForRead);

    if(pBlockTable.openStatus() != eOk) return;
    if(!pBlockTable->has(name)) return;

    AcDbObjectId blkid;
    if(pBlockTable->getAt(name,blkid) != eOk) return;

    AcDbBlockTableRecordPointer pTableRecord(blkid,AcDb::kForRead);
    if(pTableRecord.openStatus() != eOk) return;

    if (pTableRecord->hasAttributeDefinitions() == Adesk::kTrue)
    {
      AcDbObjectIdArray blockReferenceIds;
      pTableRecord->getBlockReferenceIds(blockReferenceIds);

      for(int i = 0 ; i < blockReferenceIds.length() ; i++)
      {
        AcDbObjectPointer<AcDbBlockReference> pBlockReference
          (blockReferenceIds[i] , AcDb::kForRead,Adesk::kFalse);

        out << "\n";
        std::auto_ptr<AcDbObjectIterator>
          pAttributeIterator(pBlockReference->attributeIterator());

        for (pAttributeIterator->start();
            !pAttributeIterator->done();
            pAttributeIterator->step())
        {

          AcDbObjectPointer<AcDbAttribute> pAttribute
            (pAttributeIterator->objectId(),AcDb::kForRead);

          if(pAttribute.openStatus() == eOk)
            out << "("<<  pAttribute->tag() << "." << pAttribute->textString() << ")";
        }
      }
    }
    out.close();
  }

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Reading and Saving Attribute values. ala DBX..
« Reply #16 on: August 24, 2009, 06:11:25 PM »
Times on a machine I'm using at the moment:

Lisp = 44.594 secs.
C# Original = 27.140625 secs
C# New = 22.203125 secs

New code:

Code: [Select]
///.>>
            StringBuilder sb = new StringBuilder();

 //..<<
}

Interesting huh?

yep .. I'll have a look tonight at home Glenn.

Thanks for the input.

//.......

Dan,
Which arx build is that for ?
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.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8728
  • AKA Daniel
Re: Reading and Saving Attribute values. ala DBX..
« Reply #17 on: August 24, 2009, 06:13:36 PM »
Sorry, for 07 - 09  x32

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Reading and Saving Attribute values. ala DBX..
« Reply #18 on: August 24, 2009, 08:33:04 PM »
Sorry,  ...

:)

Don't be.

[geek]
I have the technology.
[/geek]

would have liked to test in 2010, but heh !  :wink:
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.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8728
  • AKA Daniel
Re: Reading and Saving Attribute values. ala DBX..
« Reply #19 on: August 24, 2009, 08:42:35 PM »
Sorry,  ...

:)

Don't be.

[geek]
I have the technology.
[/geek]

would have liked to test in 2010, but heh !  :wink:


64 or 32 bit?   :laugh:

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Reading and Saving Attribute values. ala DBX..
« Reply #20 on: August 24, 2009, 08:43:14 PM »

32 this week :)
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.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8728
  • AKA Daniel
Re: Reading and Saving Attribute values. ala DBX..
« Reply #21 on: August 24, 2009, 08:54:35 PM »
here is both and the solution.

What is interesting is that 2010x64 is a third slower than 07x32 at this operation

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Reading and Saving Attribute values. ala DBX..
« Reply #22 on: August 25, 2009, 06:27:35 AM »
Thanks Dan, I'll have a play on the weekend.
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.