马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
//打开图层表,打开方式为只写
3 S/ E% N6 G/ S% L3 `+ XAcDbLayerTable * pLayerTable;) [2 ?- g- \8 w/ L3 Y n; V
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite); //初始化层表记录对象,并设定图层名称“NewLayer”
" e$ N; K' t3 c' W0 Z. |; LAcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;) e: T1 L" u3 R$ ^
pLayerTableRecord->setName(L”NewLayer”); //图层的其他属性(例如颜色、线形等)都用默认值( F- @" i) b9 F# {# ^/ \
//将新建的图层表记录添加到图层表中,并将图层表记录的ID& C P0 l) Z: h2 ?/ X
//保存到pLayerId中,作为函数的返回值
! w& P- `- c3 u/ cAcCmColor color; // AcCmColor是ACAD颜色管理类9 f$ U! k2 z, ]( W4 O/ r. a
color.setColorIndex(1); //红色% _6 v) h# o" Q
(color.setRGB (0,0,0)
3 a0 d4 x/ I0 H, Z# N! ZpLayerTableRecord->setColor(color);2 t# f4 r$ Y. e- f
AcDbObjectId pLayerId;
% `& G$ S) @2 L" H, k0 {pLayerTable->add(pLayerId,pLayerTableRecord);3 B2 I; S6 L3 _! E8 Y" m$ `
pLayerTable->close();2 I! {0 d+ A! D5 J1 x* Y7 ?0 ?
pLayerTableRecord->close(); 示例:创建两个图层:
& s2 `! j& @1 z0 u! {& V6 }5 A//打开图层表,打开方式为只写; S$ }9 y2 d5 Q
AcDbLayerTable * pLayerTable;
, K5 ?( U! j# Y' @+ k) O8 cAcDbLayerTableRecord * pLayerTableRecord ;
, {: |; G3 m4 eAcCmColor color;// AcCmColor是ACAD颜色管理类
* Y+ v8 m2 N/ Z0 NAcDbObjectId pLayerId;. h0 K3 ?' s2 l0 r, N1 |4 y
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);+ Z7 ?5 `6 b6 }7 W+ Q6 c6 j; M2 x* u
//初始化层表记录对象,并设定图层名称“结-1”
: X9 u; |% j, `. cpLayerTableRecord = new AcDbLayerTableRecord;
! ]' W0 C9 S0 e& W* o2 X) G9 E* \$ LpLayerTableRecord->setName(_T(“结-1″));) c3 `' x$ F4 T& G) X( Y
color.setColorIndex(5);! F H& s: z4 O- P8 ~3 m1 W
pLayerTableRecord->setColor(color);
3 Z6 D; J6 t* K* }. [+ k3 mpLayerTable->add(pLayerId,pLayerTableRecord);
u. `( h Q3 Y1 ApLayerTableRecord->close();
5 }! M, b6 x& ~6 w0 ?//设定图层名称“结-2”% R) B9 ~1 ^! z, P
pLayerTableRecord = new AcDbLayerTableRecord;. ~: j6 P& ^- D4 E' U! N' S
pLayerTableRecord->setName(_T(“结-2″));
O$ M+ j9 i& o8 f9 u! N, P# b0 M2 X$ @color.setColorIndex(1);
$ Q! E! t6 a- u3 t1 E& }8 K4 tpLayerTableRecord->setColor(color);8 d, k G# M+ D' n
pLayerTable->add(pLayerId,pLayerTableRecord);7 g& W$ Y9 o* X3 F" V* C' C
pLayerTableRecord->close();; O" b: z7 p' L) S3 S# q
pLayerTable->close(); 4 p; ?5 p+ }* R( F4 L
参考:http://www.colinchou.com/archives/236) `, h% ^ ?# |5 }% w
|