- UID
- 5043
- 积分
- 1347
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-5-13
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 LoveArx 于 2016-8-13 15:05 编辑
见下面代码:
![](source/plugin/imc_colorcode/images/loading.gif) -
- // 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);
- }
|
|