Author Topic: Checking and loading linetypes in .Net ObjectARX  (Read 1593 times)

0 Members and 1 Guest are viewing this topic.

cannorth

  • Guest
Checking and loading linetypes in .Net ObjectARX
« on: November 30, 2011, 10:29:50 AM »
Hello,

   I'd like to know how to write code that would check if a linetype exists and if it doesn't, then it will load the linetype from a .lin file.

Thanks,

cannorth

LE3

  • Guest
Re: Checking and loading linetypes in .Net ObjectARX
« Reply #1 on: November 30, 2011, 10:42:02 AM »
no sample i have available in .net but this is what i have used in arx - hth:
Code - C++: [Select]
  1. Acad::ErrorStatus loadLinetype(const ACHAR *entryName, const ACHAR *filename = _T("acad.lin"))
  2. {
  3.         Acad::ErrorStatus es;
  4.         AcDbLinetypeTable* pTable;
  5.         AcDbObjectId recordId;
  6.         es = acdbCurDwg()->getLinetypeTable(pTable, AcDb::kForRead);
  7.         if ((es = pTable->getAt(entryName, recordId)) != Acad::eOk);
  8.         {
  9.                 es = pTable->close();
  10.                 es = acdbCurDwg()->loadLineTypeFile(entryName, filename);
  11.         }
  12.         return es;
  13. }
  14.  
  15. // and from your entry point... load your linetypes.
  16.         virtual AcRx::AppRetCode On_kLoadDwgMsg (void *pkt) {
  17.                 AcRx::AppRetCode retCode =AcRxArxApp::On_kLoadDwgMsg(pkt) ;
  18.                
  19.                 AcApDocument* pDoc;
  20.                 pDoc = acDocManager->curDocument();
  21.  
  22.                 pDoc->pushDbmod();
  23.  
  24.                 const ACHAR* items[] = { _T("BORDER"), _T("CENTER"), _T("DASHED"), _T("DASHDOT"), _T("HIDDEN"), _T("PHANTOM") };
  25.                 std::vector<const ACHAR*, std::allocator<const ACHAR*>> v (items, items + sizeof items / sizeof *items);
  26.                 for (int i = 0; i < v.size(); i++) loadLinetype(v.at(i)); v.clear();
  27.                
  28.                 pDoc->popDbmod();
  29.  
  30.                 return (retCode) ;
  31.         }
  32.  
« Last Edit: December 04, 2011, 11:32:32 AM by le »