QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

全站
6天前
查看: 2032|回复: 0
收起左侧

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

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

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

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

x

//打开图层表,打开方式为只写
+ a+ g4 F% \1 kAcDbLayerTable * pLayerTable;
4 N2 w3 w& r8 k  b3 z) s* J% Q. ~; ?acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);

//初始化层表记录对象,并设定图层名称“NewLayer”  @4 T+ v# `4 y2 \5 R8 |1 u5 e( _) x
AcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;3 L1 C! D) i! K& l1 ~. ]
pLayerTableRecord->setName(L”NewLayer”);

//图层的其他属性(例如颜色、线形等)都用默认值; Z# d7 T: ~  d
//将新建的图层表记录添加到图层表中,并将图层表记录的ID, A3 I8 C. P  t7 i4 q8 Y
//保存到pLayerId中,作为函数的返回值8 S: n8 }' p8 G5 H& g
AcCmColor color; // AcCmColor是ACAD颜色管理类
* }% Y8 P# O5 }color.setColorIndex(1); //红色
! N: _% q4 r* X0 {( ~1 E/ @* C3 E(color.setRGB (0,0,0)0 ]$ D% i* I0 A& ]9 Q
pLayerTableRecord->setColor(color);6 Z6 C% ~6 [" F5 b6 j( j' O
AcDbObjectId pLayerId;( n" _9 e$ Z/ T) J. N- N
pLayerTable->add(pLayerId,pLayerTableRecord);
3 q( T  }; F) K  j* x+ T9 J  spLayerTable->close();
) H( G4 m( Y' `/ a7 S2 k2 \  IpLayerTableRecord->close();

示例:创建两个图层:( l2 U7 C" e: k2 F: h8 B
//打开图层表,打开方式为只写# v4 a* ?2 u% M: b% C$ [
AcDbLayerTable * pLayerTable;
# s: [, }) m9 E8 N6 D5 L) m( nAcDbLayerTableRecord * pLayerTableRecord ;/ J. c* p, E) l4 B8 R0 G  F) x
AcCmColor color;// AcCmColor是ACAD颜色管理类; N& U* g- l, i
AcDbObjectId pLayerId;
3 i2 T" b$ a4 \! p! j  \acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);$ h* t% r' X! r7 P2 k2 c( e
//初始化层表记录对象,并设定图层名称“结-1”  ^3 @/ D8 |5 i8 [9 @6 g
pLayerTableRecord = new AcDbLayerTableRecord;/ u" w- [: F5 d: m
pLayerTableRecord->setName(_T(“结-1″));& y& Y/ e7 i6 m9 X) b/ U, f0 A4 t# D
color.setColorIndex(5);
2 {4 b( z3 ~6 b# ^. G1 gpLayerTableRecord->setColor(color);% S) p: \3 P# d
pLayerTable->add(pLayerId,pLayerTableRecord);
6 M  O3 L: Q3 T4 m9 XpLayerTableRecord->close();
4 [/ r  p& j; d- V* k( ~6 k) o2 N//设定图层名称“结-2”2 q0 {3 P2 f! Q, b
pLayerTableRecord = new AcDbLayerTableRecord;
% {, g' D% r  k6 l2 f: n# S/ d" HpLayerTableRecord->setName(_T(“结-2″));
6 m  g& m# ~  vcolor.setColorIndex(1);0 }: _1 F: v0 f% ?( Q0 h
pLayerTableRecord->setColor(color);% T8 k8 x" `; X# Z' ~. @) l6 f
pLayerTable->add(pLayerId,pLayerTableRecord);; L, C9 G$ O  K: i
pLayerTableRecord->close();. p6 }& E4 a7 U  k7 v9 a
pLayerTable->close();


  b& X( C" P5 j参考:http://www.colinchou.com/archives/236
. S* Z( M. @+ I) d1 V2 A' e
发表回复
您需要登录后才可以回帖 登录 | 注册

本版积分规则


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

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

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