QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

查看: 2062|回复: 0
收起左侧

[原创] 【ARX 一步一步开发CAD】01-新建图层

[复制链接]
发表于 2013-12-8 19:01:47 | 显示全部楼层 |阅读模式 来自: 中国江苏南京

马上注册,结识高手,享用更多资源,轻松玩转三维网社区。

您需要 登录 才可以下载或查看,没有帐号?注册

x

//打开图层表,打开方式为只写' S# P2 K) R) D9 b
AcDbLayerTable * pLayerTable;5 d1 I1 T1 _1 T, Z' u+ \9 w: o; o
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);

//初始化层表记录对象,并设定图层名称“NewLayer”1 K6 v4 b4 b5 h1 y
AcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;6 ]2 L' d/ E. a  M, r3 _; i6 ~
pLayerTableRecord->setName(L”NewLayer”);

//图层的其他属性(例如颜色、线形等)都用默认值$ R% D- f/ x2 D% d( x) M
//将新建的图层表记录添加到图层表中,并将图层表记录的ID
4 Q* h/ l% X! V% U: v, B* t# ?//保存到pLayerId中,作为函数的返回值/ H/ M1 b7 M  x9 H" x: p
AcCmColor color; // AcCmColor是ACAD颜色管理类* O) S& w; _, i$ s$ f9 T5 u
color.setColorIndex(1); //红色
  t" v5 c! E5 U* ^1 q; a6 x(color.setRGB (0,0,0). O0 u* ^: Y( u' r0 s  P) a+ ^# a
pLayerTableRecord->setColor(color);
  v, c5 k: E9 s& fAcDbObjectId pLayerId;
" m0 H6 W( m4 b' ~' hpLayerTable->add(pLayerId,pLayerTableRecord);3 P8 `% i4 ]3 Z4 W
pLayerTable->close();. k) |( w4 R% g' g+ i* r/ ^
pLayerTableRecord->close();

示例:创建两个图层:7 [/ p$ p; o- c) a1 D  p
//打开图层表,打开方式为只写9 ~! [& I1 ~& P/ [) k0 x; o& I* p
AcDbLayerTable * pLayerTable;
% f5 _$ S3 Q3 J) x  W/ dAcDbLayerTableRecord * pLayerTableRecord ;# n) i" N0 O- S  _, m; i: @. N! _9 `
AcCmColor color;// AcCmColor是ACAD颜色管理类
1 Y( k1 L, u' S: J0 O' SAcDbObjectId pLayerId;
+ r( x+ R, q7 q( R+ p6 j, OacdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);' K/ H: J% g7 Y
//初始化层表记录对象,并设定图层名称“结-1”
: s, w3 i8 k% \9 W; b' ]pLayerTableRecord = new AcDbLayerTableRecord;
2 |* Y  X9 n$ }pLayerTableRecord->setName(_T(“结-1″));, F: p* A$ e6 m0 a' j
color.setColorIndex(5);, o% u$ T% ]2 e5 R  J% U0 |
pLayerTableRecord->setColor(color);
5 c* E4 t3 v% J8 z+ h' i" |pLayerTable->add(pLayerId,pLayerTableRecord);5 x2 M$ [: [% t- X# G7 R, t+ v, g5 o
pLayerTableRecord->close();
8 P5 B; N$ L" S5 G; ]: l//设定图层名称“结-2”
8 |% b% f0 |% Y4 m  I( B; }7 ipLayerTableRecord = new AcDbLayerTableRecord;
3 ~8 r# N5 L1 ?( l: A% opLayerTableRecord->setName(_T(“结-2″));
0 w. O6 K% `, h  X  Y9 e( o8 V8 bcolor.setColorIndex(1);  ]- L6 o- t! I6 t/ h: X
pLayerTableRecord->setColor(color);. n, a8 A! D& J6 w$ g# M
pLayerTable->add(pLayerId,pLayerTableRecord);* ]$ L% q" S; w( _' P5 x2 m6 j9 ?
pLayerTableRecord->close();
8 d  g# M* B) J! H% V: ipLayerTable->close();


* J8 z4 s' R. `# G* A3 m参考:http://www.colinchou.com/archives/236
& s4 H' S0 \! a+ j9 R
发表回复
您需要登录后才可以回帖 登录 | 注册

本版积分规则


Licensed Copyright © 2016-2020 http://www.3dportal.cn/ All Rights Reserved 京 ICP备13008828号

小黑屋|手机版|Archiver|三维网 ( 京ICP备2023026364号-1 )

快速回复 返回顶部 返回列表