马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
//打开图层表,打开方式为只写1 d9 {) P7 g1 `1 F9 m
AcDbLayerTable * pLayerTable;5 _7 A; T7 H- C+ d; Z
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite); //初始化层表记录对象,并设定图层名称“NewLayer”: b3 h& J% g3 Y, Z! X
AcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;6 B t/ y6 d5 q4 m" \
pLayerTableRecord->setName(L”NewLayer”); //图层的其他属性(例如颜色、线形等)都用默认值5 C8 Z- N# Z P- G
//将新建的图层表记录添加到图层表中,并将图层表记录的ID* |3 Y' t8 G: l* N. j/ R
//保存到pLayerId中,作为函数的返回值
* C# P* o1 `- ^AcCmColor color; // AcCmColor是ACAD颜色管理类- B% J0 p0 ~# @, Z& C
color.setColorIndex(1); //红色
0 a* v) Y/ ?( p(color.setRGB (0,0,0) 7 [( |' {4 A' w2 [
pLayerTableRecord->setColor(color);
6 H4 L( i; L1 [7 n2 X1 p4 L) OAcDbObjectId pLayerId;! U- b( D: [; h* @, _
pLayerTable->add(pLayerId,pLayerTableRecord);
0 f3 p- t3 `4 U3 d. mpLayerTable->close();) z' J& B1 H( M
pLayerTableRecord->close(); 示例:创建两个图层: Z4 b6 h" ^' H8 k& {. r/ h8 B- Z. N
//打开图层表,打开方式为只写
: j6 o5 _ j1 M( }8 l6 K+ G3 zAcDbLayerTable * pLayerTable;7 w+ J5 U0 m" E4 }9 R! Y" z1 M
AcDbLayerTableRecord * pLayerTableRecord ;4 B% {" K5 b& q- k( K* B
AcCmColor color;// AcCmColor是ACAD颜色管理类
7 p5 `1 x8 C! `1 ?( J- f3 wAcDbObjectId pLayerId;" S0 Y0 q* G2 }7 k9 i
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);
/ {5 m' {: [# c4 P; Z//初始化层表记录对象,并设定图层名称“结-1”1 K+ W3 l, i; K% _" t: q
pLayerTableRecord = new AcDbLayerTableRecord;
4 o- F% c: ~1 X# L- {" cpLayerTableRecord->setName(_T(“结-1″));
& K8 F! X6 U9 Y/ L/ M5 K( Wcolor.setColorIndex(5);
0 S7 k6 B" Y9 T& i* r1 E8 \( jpLayerTableRecord->setColor(color);/ ?, @# U* d# B2 l4 U1 l
pLayerTable->add(pLayerId,pLayerTableRecord);; O. N" z2 l* C1 h% N" N+ n: u
pLayerTableRecord->close();
: {2 x" U) h! n1 f//设定图层名称“结-2”
3 i+ s3 N$ J2 h9 T4 {0 ~, Q1 wpLayerTableRecord = new AcDbLayerTableRecord;
% ]. @! L$ J6 ApLayerTableRecord->setName(_T(“结-2″));4 L T, @# G* A( w. g/ l1 y& R
color.setColorIndex(1);: p' s' D; b, o; ]
pLayerTableRecord->setColor(color);6 `/ \$ p' z7 R# C
pLayerTable->add(pLayerId,pLayerTableRecord);, t; s* a, s8 n5 I
pLayerTableRecord->close();8 m' q3 x2 l, f5 _+ c0 ?
pLayerTable->close();
/ |. O2 Q! q! _参考:http://www.colinchou.com/archives/2362 O( \; G$ o4 C) s
|