马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
//打开图层表,打开方式为只写 s9 I, D" l w( F, r6 F7 S. O
AcDbLayerTable * pLayerTable;
/ D; a A ]5 A2 _acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite); //初始化层表记录对象,并设定图层名称“NewLayer”* f% t1 g1 Y& p1 z: T9 r
AcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;5 V# H$ f( X/ a" Z3 R$ [5 V4 X3 a
pLayerTableRecord->setName(L”NewLayer”); //图层的其他属性(例如颜色、线形等)都用默认值' ?7 T3 D" n: I. O3 a; k
//将新建的图层表记录添加到图层表中,并将图层表记录的ID
+ ?' T# M1 n0 F1 ]/ j# @//保存到pLayerId中,作为函数的返回值/ a7 j6 d6 }5 H% \, e( e1 m
AcCmColor color; // AcCmColor是ACAD颜色管理类5 H' H1 O+ Z- b) n" l A
color.setColorIndex(1); //红色
( C1 d, @, w: t2 o/ a(color.setRGB (0,0,0) ! ~2 _9 T( ~; H6 O8 b, k- Z, n
pLayerTableRecord->setColor(color);9 [/ p. I7 N# G
AcDbObjectId pLayerId;' ]0 f0 t7 J# t# g; C
pLayerTable->add(pLayerId,pLayerTableRecord);
; v3 m, ~+ i- q' {1 ]) tpLayerTable->close();
# u9 [: J0 ]! J ^* l- D. LpLayerTableRecord->close(); 示例:创建两个图层:; |6 v2 u1 d* B0 G/ O; ~
//打开图层表,打开方式为只写
4 t2 H& z9 Y3 K5 F& F! `AcDbLayerTable * pLayerTable;! s- P, g- d# _0 }1 N
AcDbLayerTableRecord * pLayerTableRecord ;
- q' f% F1 D: _AcCmColor color;// AcCmColor是ACAD颜色管理类
6 \+ e; R$ T8 G- y7 a% lAcDbObjectId pLayerId;7 J* u( o& `: V/ ~6 ~# L- ]
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);& h0 c, a' g5 W
//初始化层表记录对象,并设定图层名称“结-1”
; P2 s- r. j( x6 rpLayerTableRecord = new AcDbLayerTableRecord;
1 P, {: Y% U, t3 g1 w4 j' N$ r5 K( ~& xpLayerTableRecord->setName(_T(“结-1″));+ v8 |8 r" |( U7 u
color.setColorIndex(5);
3 ~6 F, `! t4 m6 p& s: |pLayerTableRecord->setColor(color); O6 \+ E9 }/ u- u0 h: T' ?/ {
pLayerTable->add(pLayerId,pLayerTableRecord);6 b- ?# I; @/ C$ _- a* @4 U
pLayerTableRecord->close();$ P$ q5 E8 X1 S4 N/ F+ ]1 U3 B3 k
//设定图层名称“结-2”' t4 U ^& V# S6 b! M
pLayerTableRecord = new AcDbLayerTableRecord;
' n; h0 u$ y/ V1 ?! OpLayerTableRecord->setName(_T(“结-2″));/ T! t, L3 g+ s5 z
color.setColorIndex(1);9 _( w. F0 v Y9 @, A
pLayerTableRecord->setColor(color);
. \& d/ W3 j0 `* n. |' I, ]) npLayerTable->add(pLayerId,pLayerTableRecord);
, S# s% V; |' L4 B9 G; q: K: VpLayerTableRecord->close();; e3 G' t2 h0 R! |, C
pLayerTable->close();
2 y* `2 k# j' i& \; @$ @' Q参考:http://www.colinchou.com/archives/236
( I( ]1 ^: v- p( A0 {8 g |