几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » ObjectARX(VB.NET/C#)
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-20, 09:52 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】大家帮看看,我找不到这个错误了

大家帮看看,我找不到这个错误了
www.dimcax.com
大家帮看看,我找不到这个错误了
命令: namespace vecto { /// /// summary description for commands. /// public class commands { data da = new data(); public commands() { // // todo: add constructor logic here // } // define command "asdkcmd1" [commandmethod("ex")] public void est() { dataset selfds = da.returnds("select * from table1"); transaction trans = hostapplicationservices.workingdatabase.transactionmanager.starttransaction(); for (int i = 0; i ["coloindex"]; string name = selfds.tables[0].rows["lithology"].tostring(); create.addlayer(name,x); double ox = (double)selfds.tables[0].rows["orgionx"]; double oy = (double)selfds.tables[0].rows["orgiony"]; double oz = (double)selfds.tables[0].rows["orgionz"]; double tx = (double)selfds.tables[0].rows["tox"]; double ty = (double)selfds.tables[0].rows["toy"]; double tz = (double)selfds.tables[0].rows["toz"]; point3d pt1=new point3d(ox,oy,oz); point3d pt2=new point3d(tx,ty,tz); point3dcollection pts=new point3dcollection(); pts.add(pt1); pts.add(pt2); entity pline=create.add3dpoly(pts); create.addextrudedsolid((region)create.addregion(ox,oy,oz),(curve)pline); } } } 创建东西的函数 namespace vecto { class create { // 由截面面域、拉伸路径曲线和拉伸角度创建拉伸体的函数. public static objectid addextrudedsolid(region region, curve path) { try { solid3d ent = new solid3d(); ent.extrudealongpath(region, path, 0); objectid entid = appendentity(ent); return entid; } catch { objectid nullid = objectid.null; return nullid; } } public static entity addcircle(point3d cenpt) { circle ent = new circle(cenpt, vector3d.zaxis,5); objectid entid = appendentity(ent); return ent; } // 由三维点集合创建三维多段线的函数. public static entity add3dpoly(point3dcollection pts) { transaction trans = hostapplicationservices.workingdatabase.transactionmanager.starttransaction(); try { polyline3d ent = new polyline3d(poly3dtype.simplepoly, pts, false); objectid entid = appendentity(ent); entity ents = (entity)trans.getobject(entid,openmode.forread); return ents; } catch { return null; } } // 将图形对象加入到模型空间的函数. public static objectid appendentity(entity ent) { database db = hostapplicationservices.workingdatabase; objectid entid; using (transaction trans = db.transactionmanager.starttransaction()) { blocktable bt = (blocktable)trans.getobject(db.blocktableid, openmode.forread); blocktablerecord btr = (blocktablerecord)trans.getobject(bt[blocktablerecord.modelspace], openmode.forwrite); entid = btr.appendentity(ent); trans.addnewlycreateddbobject(ent, true); trans.commit(); trans.dispose(); } return entid; } // 创建图层 public static void addlayer(string layername, short inde) { database db = hostapplicationservices.workingdatabase; using (transaction trans = db.transactionmanager.starttransaction()) { layertable lt = (layertable)trans.getobject(db.layertableid, openmode.forwrite); objectid layerid; if (lt.has(layername) == false) { layertablerecord ltr = new layertablerecord(); ltr.name = layername; color layercolor = color.fromcolorindex(colormethod.bycolor, inde); ltr.color = layercolor; linetypetable tt = (linetypetable)trans.getobject(db.linetypetableid, openmode.forread); linetypetablerecord ttr; try { db.loadlinetypefile("center", "acadiso.lin"); } catch { // 此处无需操作. } ttr = (linetypetablerecord)trans.getobject(tt["center"], openmode.forread); ltr.linetypeobjectid = ttr.objectid; ltr.lineweight = lineweight.lineweight030; db.lineweightdisplay = true; db.ltscale = 2; // 图层锁定 //ltr.islocked = true // 图层冻结 //ltr.isfrozen = true // 图层关闭 //ltr.isoff = true; layerid = lt.add(ltr); trans.addnewlycreateddbobject(ltr, true); db.clayer = layerid; } trans.commit(); trans.dispose(); } } //创建面域 public static entity addregion(double x,double y,double z) { transaction trans=hostapplicationservices.workingdatabase.transactionmanager.starttransaction(); point3d pt=new point3d(x,y,z); entity cir=addcircle(pt); dbobjectcollection ent=new dbobjectcollection(); ent.add(cir); dbobjectcollection region=region.createfromcurves(ent); objectid regionid=appendentity((entity)region[0]); entity re=(entity)trans.getobject(regionid,openmode.forread); return re; } } } 数据库连接 namespace vecto { class data { // 连接数据源 private oledbconnection con = null; private string connectstring; public data() { string connectstring="provider=microsoft.jet.oledb.4.0;data source=c:\\documents and settings\\administrator\\桌面\\煤层柱状图数据.mdbersist security info=false"; con = new oledbconnection (connectstring); } /// /// 根据sql查询返回dataset对象,如果没有查询到则返回null /// /// 查询语句 /// dataset public dataset returnds(string sql) { dataset ds = new dataset(); try { oledbcommand cmd = new oledbcommand(sql, con); cmd.commandtimeout = 60; this.open(); oledbdataadapter adapter = new oledbdataadapter(cmd); adapter.fill(ds); } catch (exception e) { throw (e); } finally { this.close(); } return ds; } /// /// 对数据库的增,删,改的操作 /// /// sql语句 /// 是否成功 public bool operatedb(string sql) { bool succeed = false; int cnt = 0; try { oledbcommand cmd = new oledbcommand(sql, con); cmd.commandtimeout = 30; this.open(); cnt = cmd.executenonquery(); } catch (exception e) { throw (e); //messagebox.show(e.tostring()); } finally { if (cnt > 0) { succeed = true; } this.close(); } return succeed; } /// /// 打开数据库连接. /// private void open() { if (con.state == system.data.connectionstate.closed) { con.open(); } else if (con.state == system.data.connectionstate.broken) { con.close(); con.open(); } } /// /// 关闭数据库连接 /// private void close() { if (con != null) { con.close(); } } /// /// 释放资源 /// public void dispose() { // 确认连接是否已经关闭 if (con != null) { con.dispose(); con = null; } } } }
这个代码用于在数据库中读取数据然后产生一个立体的柱状图但在运行时可以出现正确图形,可是过一会就会有错误,致命错误
please refer to the following vb.net routine,hope it helps you. _ publicfunctionwb3dsolidcommand() dimdbasdatabase=application.documentmanager.mdiactivedocument.database dimtmasdbtransman=db.transactionmanager 'startatransaction dimmytastransaction=tm.starttransaction() try 'create4linestomaketheregionfrom diml1,l2,l3,l4asline l1=newline(newpoint3d(0,0,0),newpoint3d(4,0,0)) l2=newline(newpoint3d(4,0,0),newpoint3d(4,6,0)) l3=newline(newpoint3d(4,6,0),newpoint3d(0,6,0)) l4=newline(newpoint3d(0,6,0),newpoint3d(0,0,0)) 'addthelinestothearray dimmyarrayasnewdbobjectcollection() myarray.add(l1) myarray.add(l2) myarray.add(l3) myarray.add(l4) 'createtheregion dimmyregionasnewregion() dimmyregionsasnewdbobjectcollection() myregions=myregion.createfromcurves(myarray) myregion=myregions(0) 'createthesolid dimmy3dsolidasnewsolid3d() my3dsolid.extrude(myregion,10.0,0.0) dimbtasblocktable=ctype(tm.getobject(db.blocktableid,openmode.forread,false),blocktable) dimbtrasblocktablerecord=ctype(tm.getobject(bt(blocktablerecord.modelspace),openmode.forwrite,false),blocktablerecord) 'addthe3dsolidtothemodelspaceblocktablerecord btr.appendentity(my3dsolid) 'makesurethatthetransactionknowsaboutthisnewobject tm.addnewlycreateddbobject(my3dsolid,true) myt.commit() finally myt.dispose() endtry endfunction
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



所有的时间均为北京时间。 现在的时间是 06:12 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多