马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
//打开图层表,打开方式为只写
+ _3 t1 ?9 P* uAcDbLayerTable * pLayerTable;7 u$ n4 F: Z0 B9 a: l2 G
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite); //初始化层表记录对象,并设定图层名称“NewLayer”
8 d6 r3 `3 s9 f* B5 kAcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;
& L% i& e7 K. B4 B$ `, spLayerTableRecord->setName(L”NewLayer”); //图层的其他属性(例如颜色、线形等)都用默认值
- Y; w% k+ P, |" L4 X4 {9 l//将新建的图层表记录添加到图层表中,并将图层表记录的ID
+ ^( x7 q; U0 M9 B/ L/ T0 c- b% O//保存到pLayerId中,作为函数的返回值. J+ B0 E9 a4 k1 g, s% s
AcCmColor color; // AcCmColor是ACAD颜色管理类
# O7 d" s5 \1 ycolor.setColorIndex(1); //红色
) G( C' u& c. m7 u9 i& [(color.setRGB (0,0,0)
9 C0 {' S8 A& x. y7 l8 P( m! [* ZpLayerTableRecord->setColor(color);$ V5 h S/ Q" c2 \+ R
AcDbObjectId pLayerId;8 \6 G/ P9 S! d2 f
pLayerTable->add(pLayerId,pLayerTableRecord);- `( d2 S) G. }; Y* O% j
pLayerTable->close();
: X3 T' x( c9 Y1 @pLayerTableRecord->close(); 示例:创建两个图层:
- g5 O/ t' ]( G+ G% Z2 n//打开图层表,打开方式为只写! e- @5 g" D5 F5 I' j
AcDbLayerTable * pLayerTable;
# u; |3 k# @0 o" d: [2 _AcDbLayerTableRecord * pLayerTableRecord ;
- u/ T; o+ N8 H& gAcCmColor color;// AcCmColor是ACAD颜色管理类
, V$ n: k' X P/ z' _ e% A- CAcDbObjectId pLayerId;
& q5 D& h! F# qacdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);
1 ?( j9 U1 c* h( Z& Q//初始化层表记录对象,并设定图层名称“结-1”3 J. l# U, e, J( u+ H& w4 g. l1 j
pLayerTableRecord = new AcDbLayerTableRecord;. U. D8 ~* ^8 i8 } C
pLayerTableRecord->setName(_T(“结-1″));
9 q( H! j5 k- H w6 F5 Ucolor.setColorIndex(5);
+ }8 ~% Q* V4 W+ v1 _" r" IpLayerTableRecord->setColor(color);$ }( s2 x8 E+ n. q9 Y
pLayerTable->add(pLayerId,pLayerTableRecord);, D. E+ Y# J& j" |0 r9 \7 Z1 e+ N
pLayerTableRecord->close();( l( F: y6 y" I& | R' ?' v, h. {
//设定图层名称“结-2”
# v8 G5 }; Z" r* y! T& _# ~pLayerTableRecord = new AcDbLayerTableRecord;
* J$ Q. t# ^# y& N1 {& z0 opLayerTableRecord->setName(_T(“结-2″));
* p9 @# y/ {) K) Wcolor.setColorIndex(1);: H2 E; |8 ? Z4 G1 b; B3 N
pLayerTableRecord->setColor(color);
. M- V+ o A3 | \pLayerTable->add(pLayerId,pLayerTableRecord);
- k4 H) x; L$ a6 r! X, K# V9 npLayerTableRecord->close();
' a% Q0 D# m9 g) O* x3 bpLayerTable->close();
" X& A* y0 l3 s* f! j参考:http://www.colinchou.com/archives/236
( I I2 O9 O0 o0 e6 e |