TA的每日心情 | 开心 昨天 06:36 |
---|
签到天数: 15 天 [LV.4]偶尔看看III
管理员
- 积分
- 1308
|
- // minimal error checking for code brevity
- void createMlineStyle()
- {
- AcDbLinetypeTable* pTable = NULL;
- AcDbObjectId id;
- AcDbDatabase* pDb = curDoc()->database();
- // open ByLayer linetypetablerecord for use in MLineStyle later
- pDb->getLinetypeTable(pTable, AcDb::kForRead);
- if((pTable->getAt(L"ByLayer", id)) != Acad::eOk)
- {
- acutPrintf(L"\nlinetype ByLayer not found.");
- return;
- }
- pTable->close();
- AcDbDictionary* pDict = NULL;
- // open MLStyleDictionary (its sored in the NOD)
- Acad::ErrorStatus es = pDb->getMLStyleDictionary(pDict, AcDb::kForRead);
- if(es != Acad::eOk)
- {
- acutPrintf(L"\nCan't open mline style dictionary for read.");
- return;
- }
- const ACHAR mlineStyleName[] = L"test";
- AcDbMlineStyle* ps = NULL;
- // does MLStyle "test" already exist?
- es = pDict->getAt(mlineStyleName, (AcDbObject*&)ps, AcDb::kForWrite);
- // If it doesn't exist, create it
- if(es != Acad::eOk)
- {
- ps = new AcDbMlineStyle;
- AcDbObjectId mId;
- ps->initMlineStyle();
- pDict->upgradeOpen();
- pDict->setAt(mlineStyleName, ps, mId);
- }
- pDict->close();
- // set MLStyle attributes and elements
- es = ps->setName(mlineStyleName);
- AcCmColor cm; cm.setColorIndex(256);
- int a=0, b=0;
- es = ps->addElement(a, -0.25, cm, id);
- assert(es == Acad::eOk);
- es = ps->addElement(b, 0.25, cm, id);
- assert(es == Acad::eOk);
- ps->close();
- acutPrintf(L"\nMline style: %s created.", mlineStyleName);
- }
复制代码 |
|