创建图形对象
来源:互联网 发布:数据库设计有几个阶段 编辑:程序博客网 时间:2024/05/16 06:53
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
[assembly:CommandClass(typeof(Liness.Lines))]
namespace Liness
{
class Lines
{
[CommandMethod("addline")]
public void AddLine()
{
//获取当前的 document 和 database
Document DocObj = Application.DocumentManager.MdiActiveDocument;
Database DBObj = DocObj.Database;
//启动一个事务
using (Transaction TransObj = DBObj.TransactionManager.StartTransaction())
{
//Open the BlockTable for Read
BlockTable BTObj = TransObj.GetObject(DBObj.BlockTableId, OpenMode.ForRead) as BlockTable;
//Open the BlockTableRecord Model space for write
BlockTableRecord BTRObj = TransObj.GetObject(BTObj[BlockTableRecord.ModelSpace],OpenMode.ForWrite)as BlockTableRecord;
//Create a line that starts at (100,100) and ends at (800,800)
Line acline = new Line(new Point3d(100, 100, 0), new Point3d(800, 800, 800));
acline.SetDatabaseDefaults();
//Add the new object to the block table record and the transaction
BTRObj.AppendEntity(acline);
TransObj.AddNewlyCreatedDBObject(acline, true);
//Save the new Object to the database
TransObj.Commit();
}
}
[CommandMethod("ployline")]
public void AddMultithreading()
{
//Get the current document and database
Document DocObj = Application.DocumentManager.MdiActiveDocument;
Database DBObj = DocObj.Database;
//start a transaction
using (Transaction TransObj = DBObj.TransactionManager.StartTransaction())
{
//Open the BlockTable for read
BlockTable BTObj = TransObj.GetObject(DBObj.BlockTableId, OpenMode.ForRead) as BlockTable;
//Open the BlockTableRecord Model space for write
BlockTableRecord BTRObj = TransObj.GetObject(BTObj[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
//Create a ployline with two segments(3 points)
Polyline Pline = new Polyline();
Pline.SetDatabaseDefaults();
Pline.AddVertexAt(0, new Point2d(200, 400), 0, 0, 0);
Pline.AddVertexAt(1, new Point2d(400, 200), 0, 0, 0);
Pline.AddVertexAt(2, new Point2d(600, 400), 0, 0, 0);
//Add the new object to the BlockTableRecord and the transaction
BTRObj.AppendEntity(Pline);
TransObj.AddNewlyCreatedDBObject(Pline, true);
//Save the new object to the database
TransObj.Commit();
}
}
}
}
- 创建图形对象
- 第 4 课:创建图形对象
- 使用点阵图形上下文创建Image对象
- MATLAB句柄图形对象的创建函数与函数描述
- 图形对象
- FlowChart.NET使用教程:加载图形数据和创建图形对象
- 流程图控件FlowChart.NET使用教程:加载图形数据和创建图形对象
- c#图形创建数据库
- Android画图板 - 创建图形
- 创建图形化界面
- 创建Java2D图形
- SVG动态创建图形
- 创建图形化界面
- 图形化界面创建
- For循环创建图形
- 创建图形用户界面
- 图形编程入门之如何创建用于绘制的 Graphics 对象
- 拖动图形对象
- 备忘(1)
- 华为面试第一题:你可以走了 你不合适(转)
- symbiann s60 3rd下GUI程序后台运行
- 110个oracle常用函数总结
- Spring 中XML文件配置的12个技巧
- 创建图形对象
- SqlServer 视图索引
- LazyInitializationException.java - could not initialize proxy - no Session
- 用Spring发Email
- 最近几年的国内开源软件侵权事件
- 高兴的技术博客
- 不知道干什么。。。
- git on windows
- Android 与J2ME 虚拟机相关资料