QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

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

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

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

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

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

x

//打开图层表,打开方式为只写7 ?0 c  t1 {8 u2 }7 n8 M) k
AcDbLayerTable * pLayerTable;
5 t/ F4 f* _* b$ O6 AacdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);

//初始化层表记录对象,并设定图层名称“NewLayer”
5 b5 t# }/ @( ?& zAcDbLayerTableRecord * pLayerTableRecord = new AcDbLayerTableRecord;
+ Z, L5 j5 x& z# UpLayerTableRecord->setName(L”NewLayer”);

//图层的其他属性(例如颜色、线形等)都用默认值
/ c( G% Z& }! ]1 s  X2 N- L//将新建的图层表记录添加到图层表中,并将图层表记录的ID( b" b% d8 I0 I. h7 y7 r! S
//保存到pLayerId中,作为函数的返回值& H' f" r( l- E" ]8 W4 h' S* C
AcCmColor color; // AcCmColor是ACAD颜色管理类! T3 h7 ?* `4 m3 D" j8 t
color.setColorIndex(1); //红色* X8 Z7 i  W2 D$ e1 M" c
(color.setRGB (0,0,0)7 E* l6 e# C* j9 w) c
pLayerTableRecord->setColor(color);& v3 Q2 O; _& ^! w
AcDbObjectId pLayerId;3 z3 K& @& S& D# Z2 v
pLayerTable->add(pLayerId,pLayerTableRecord);, ^/ q& f& s' @, p6 l# z' {
pLayerTable->close();
0 Q! B" f8 @! H7 npLayerTableRecord->close();

示例:创建两个图层:
: j4 M8 O3 o( o* ?! J//打开图层表,打开方式为只写
9 i& }2 |. q. }- }: IAcDbLayerTable * pLayerTable;
& r# `5 X; r9 C0 k" o8 k; \' V/ Y1 sAcDbLayerTableRecord * pLayerTableRecord ;
& F% g) K) Y! W; |# CAcCmColor color;// AcCmColor是ACAD颜色管理类" R4 R2 |: k- R( K# [6 }" }
AcDbObjectId pLayerId;$ r8 a$ B4 ?. I/ ^
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);
; \1 u6 H3 }/ ~4 v0 y- y//初始化层表记录对象,并设定图层名称“结-1”# }9 u! [8 ]3 C3 F" x  p+ z
pLayerTableRecord = new AcDbLayerTableRecord;  P  r1 B: s4 Q6 b6 p
pLayerTableRecord->setName(_T(“结-1″));+ X+ I2 f  f# p$ F. L. c
color.setColorIndex(5);
8 D7 Z. A* s! V; qpLayerTableRecord->setColor(color);! R% o1 v4 T$ x
pLayerTable->add(pLayerId,pLayerTableRecord);
/ ^0 R3 O' J+ G4 u7 QpLayerTableRecord->close();
' h# T4 d4 I& }2 Q0 S; C//设定图层名称“结-2”2 o# \% Z+ ]; S" n3 C, p
pLayerTableRecord = new AcDbLayerTableRecord;6 |1 y( {$ H8 ~* V+ A' V% @! R* ~
pLayerTableRecord->setName(_T(“结-2″));) b! o$ N# L+ Q7 L2 Q/ K
color.setColorIndex(1);
& `& Q" D* |$ B; h$ t% ]pLayerTableRecord->setColor(color);
/ r! G% k4 G* O' M: FpLayerTable->add(pLayerId,pLayerTableRecord);) I  y/ u9 r. A+ l6 v7 X: m3 i
pLayerTableRecord->close();
. C; s) h# Z. c7 s/ f) A9 ypLayerTable->close();


9 c2 [' T) P* z: y参考:http://www.colinchou.com/archives/236
; \# c' A2 h" u) r1 }1 ^
发表回复
您需要登录后才可以回帖 登录 | 注册

本版积分规则


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

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

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