You are always drawing on the active layer. When you make a layer active,you create new objects on that layer. If you make a different layer active,any new objects you create is assigned that new active layer and uses its color and linetype. You cannot make a layer active if it is froZen.
我们总是在活动图层绘制图形。当将某个图层设为活动图层后,新创建的对象就在这个图层上。如果又将别的图层设为活动图层,之后创建的新对象就在这个新活动图层上并使用该图层的颜色和线型。不能将冻结的图层设为活动图层。
To make a layer active,use the Clayer property of the Database object or the CLAYER system variable. For example:
将图层设为活动图层,使用Database对象的Clayer属性,或者使用系统变量CLAYER。详见下面的示例代码:
Make a layer current through the database 通过数据库将图层设为当前图层
This example sets a layer current through the Database object with the Clayer property.
本例使用Database对象的Clayer属性将图层设为当前图层。
VB.NET
imports autodesk.autoCAD.Runtime
imports autodesk.autoCAD.applicationservices
imports autodesk.autoCAD.DatabaseServices
<CommandMethod("SetLayerCurrent")> _
Public Sub SetLayerCurrent()
'' Get the current document and database
Dim acDoc As document = Application.documentManager.MdiActivedocument
Dim acCurDb As Database = acDoc.Database
'' Start a transaction
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
'' Open the Layer table for read
Dim acLyrTbl As Layertable
acLyrTbl = acTrans.Getobject(acCurDb.LayertableID,_
OpenMode.ForRead)
Dim sLayername As String = "Center"
If acLyrTbl.Has(sLayername) = True Then
'' Set the layer Center current
acCurDb.Clayer = acLyrTbl(sLayername)
'' Save the changes
acTrans.Commit()
End If
'' dispose of the transaction
End Using
End Sub
C#
using autodesk.autoCAD.Runtime;
using autodesk.autoCAD.applicationservices;
using autodesk.autoCAD.DatabaseServices;
[CommandMethod("SetLayerCurrent")]
public static voID SetLayerCurrent()
{
// Get the current document and database
document acDoc = Application.documentManager.MdiActivedocument;
Database acCurDb = acDoc.Database;
// Start a transaction
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
// Open the Layer table for read
Layertable acLyrTbl;
acLyrTbl = acTrans.Getobject(acCurDb.LayertableID,OpenMode.ForRead) as Layertable;
string sLayername = "Center";
if (acLyrTbl.Has(sLayername) == true)
{
// Set the layer Center current
acCurDb.Clayer = acLyrTbl[sLayername];
// Save the changes
acTrans.Commit();
}
// dispose of the transaction
}
}
VBA/ActiveX Code Reference
ThisDrawing.ActiveLayer = ThisDrawing.Layers("Center")
Make a layer current with the CLAYER system variable 使用系统变量CLAYER设置当前图层
This example sets a layer current with the CLAYER system variable.
本例使用CLAYER系统变量设置当前图层。
VB.NET
Application.SetSystemVariable("CLAYER","Center")
C#
Application.SetSystemVariable("CLAYER","Center");
VBA/ActiveX Code Reference
ThisDrawing.Setvariable "CLAYER","Center"
总结以上是内存溢出为你收集整理的03-05 创建和编辑AutoCAD实体(五) 使用图层、颜色和线型(1)使用图层(1-3)全部内容,希望文章能够帮你解决03-05 创建和编辑AutoCAD实体(五) 使用图层、颜色和线型(1)使用图层(1-3)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)