当前位置: 移动技术网 > IT编程>开发语言>.net > .NET CAD二次开发学习 直线画矩形并转换成组

.NET CAD二次开发学习 直线画矩形并转换成组

2019年04月10日  | 移动技术网IT编程  | 我要评论

黑白大搏斗燕赵刑警,上海交警打人,日本邪恶漫画网

主要代码:

using system;
using system.collections.generic;
using system.linq;
using system.text;
using system.threading.tasks;
using grxcad.runtime;
using grxcad.applicationservices;
using grxcad.editorinput;
using grxcad.geometry;
using grxcad.databaseservices;
using grxcad.windows;

namespace arxfirsttest
{
public class xrect
{

private point3d startpoint;
private point3d endpoint;
private double width;

public void xrecpic()
{
document doc = application.documentmanager.mdiactivedocument;
editor editor = doc.editor;
database db = doc.database;
promptpointoptions promptpoint1 = new promptpointoptions("\n请指定起点<退出>");
promptpointresult pointresult1 = editor.getpoint(promptpoint1);
promptpointoptions promptpoint2 = new promptpointoptions("\n请指定终点<退出>");
promptpointresult pointresult2 = editor.getpoint(promptpoint2);
promptdoubleoptions pdoubleoptions = new promptdoubleoptions("\n请输入宽度<退出>");
promptdoubleresult pdoubleres = editor.getdouble(pdoubleoptions);
if (pointresult1.status == promptstatus.ok && pointresult2.status == promptstatus.ok && pdoubleres.value > 0)
{
using (transaction trans = doc.transactionmanager.starttransaction())
{
startpoint = pointresult1.value;
endpoint = pointresult2.value;
width = pdoubleres.value;
line line = new line();
line.startpoint = startpoint;
line.endpoint = endpoint;
dbobjectcollection dboj = line.getoffsetcurves(width / 2);
dbobjectcollection dboj1 = line.getoffsetcurves(width / 2 - width);
line line1 = (line)dboj[0];
line line2 = (line)dboj1[0];
line line3 = new line();
line line4 = new line();
line3.startpoint = line1.startpoint;
line3.endpoint = line2.startpoint;
line4.startpoint = line1.endpoint;
line4.endpoint = line2.endpoint;
objectid idmodelspace = symbolutilityservices.getblockmodelspaceid(db);
blocktablerecord btr = trans.getobject(idmodelspace, openmode.forwrite) as blocktablerecord;
btr.appendentity(line1);
btr.appendentity(line2);
btr.appendentity(line3);
btr.appendentity(line4);
trans.addnewlycreateddbobject(line1, true);
trans.addnewlycreateddbobject(line2, true);
trans.addnewlycreateddbobject(line3, true);
trans.addnewlycreateddbobject(line4, true);
entity ent1 = (entity)line1;
entity ent2 = (entity)line2;
entity ent3 = (entity)line3;
entity ent4 = (entity)line4;
group group = new group();
group.append(ent1.objectid);
group.append(ent2.objectid);
group.append(ent3.objectid);
group.append(ent4.objectid);
dbdictionary groupdic = trans.getobject(db.groupdictionaryid,openmode.forwrite) as dbdictionary;
group.selectable = true;
groupdic.setat(group.name, group);
trans.addnewlycreateddbobject(group, true);
trans.commit();

}

}
else
{
application.showalertdialog("选择或者输入有误,请重新输入");
return;

}

}
}
}

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网