欢迎加我的QQ群:193522571,一起来讨论、交流!

03 2014 档案

摘要:Color.AliceBlue240,248,255Color.LightSalmon255,160,122Color.AntiqueWhite250,235,215Color.LightSeaGreen32,178,170Color.Aqua0,255,255Color.LightSkyBlue135,206,250Color.Aquamarine127,255,212Color.LightSlateGray119,136,153Color.Azure240,255,255Color.LightSteelBlue176,196,222Color.Beige245,245,220Color.L 阅读全文
posted @ 2014-03-31 14:45 swtool 阅读(1943) 评论(0) 推荐(0) 编辑
摘要:运行命令后自动搜索当前图纸中所有图框,并获取图框中的图纸信息。检测是否已经有图纸目录存在,如存在将图纸目录中的图纸读入到一个全局数组A并导入listbox2,包括图号、版次和最后一次施工版次及时间。用户选择确认图时,listbox1中列出所有检测到的图纸,listbox2根据listbox1中的选择情况实时进行版次的更改。用户选择施工图时,listbox2中列出当前目录中的数据,包括图号、版次和最后一次施工版次及时间。listbox2根据listbox1中的选择情况实时进行版次、最后一次施工版次和时间的修改。当listbox1中选定的项listbox2中没有时,自动加入listbox2,并且根 阅读全文
posted @ 2014-03-29 23:34 swtool 阅读(638) 评论(0) 推荐(0) 编辑
摘要:获取图纸空间中所有块参照和其对应的块定义对象using (Transaction trans = db.TransactionManager.StartTransaction()){ //获取块表 BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead); //取得图纸空间块表记录 BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.PaperSpace], OpenMo... 阅读全文
posted @ 2014-03-25 11:22 swtool 阅读(2489) 评论(0) 推荐(1) 编辑
摘要://通过支持文件搜索路径查找文件string path = HostApplicationServices.Current.FindFile("head.dwg", db, FindFileHint.Default); 阅读全文
posted @ 2014-03-24 13:13 swtool 阅读(820) 评论(0) 推荐(0) 编辑
摘要:database是第1级,就是相当于一个DWG文件,它下面主要包含symbol table和各种dictionarysymbol table是第2级,它包含blocktable、dimstyletable、layertable等dictionary是第2级,它下面包含第3级有名词典,它包含所有acad_color、acad_layout、acad_group等第4级词典blocktablerecord是第4级,为块定义,包含ModelSpace、PaperSpace、PaperSpaceX,以及所有其它的块定义blockreference是第5级,它是第4级中常规的块定义插入到Space中的具 阅读全文
posted @ 2014-03-24 09:39 swtool 阅读(1859) 评论(0) 推荐(1) 编辑
摘要:#if AC2013 [DllImport("accore.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedCmd")]#else [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedCmd")]#endif private static extern int acedCmd(System.IntPtr vl 阅读全文
posted @ 2014-03-23 00:27 swtool 阅读(1182) 评论(4) 推荐(0) 编辑
摘要:测试代码: [CommandMethod("test")] public static void test() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; //定义所有的视口ID集合 ObjectIdCollection viewportIDs = new O... 阅读全文
posted @ 2014-03-21 16:37 swtool 阅读(2562) 评论(0) 推荐(0) 编辑
摘要:http://www.cad8.net/thread-988-1-1.html 阅读全文
posted @ 2014-03-21 10:22 swtool 阅读(462) 评论(0) 推荐(0) 编辑
摘要:Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable(variable, value) 阅读全文
posted @ 2014-03-20 22:59 swtool 阅读(790) 评论(0) 推荐(0) 编辑
摘要:相信很多人以前在lisp中写过很多程序,那么如果要在.net中去调用写好的lisp程序怎么弄呢?以下是一个简单的例子:using Autodesk.AutoCAD.Windows;using Autodesk.AutoCAD.Runtime;using System.Windows.Forms;using Autodesk.AutoCAD.DatabaseServices;using Autodesk.AutoCAD.EditorInput;using Autodesk.AutoCAD.ApplicationServices;using System;using System.Collecti 阅读全文
posted @ 2014-03-19 20:57 swtool 阅读(1996) 评论(1) 推荐(0) 编辑
摘要:1.using wrapper RunCommand:using System;using System.Linq.Expressions;using System.Reflection;using Autodesk.AutoCAD.ApplicationServices;using Autodesk.AutoCAD.DatabaseServices;using Autodesk.AutoCAD.EditorInput;using Autodesk.AutoCAD.Geometry;using Autodesk.AutoCAD.Runtime;using AcAp = Autodesk.Aut 阅读全文
posted @ 2014-03-19 20:05 swtool 阅读(5227) 评论(0) 推荐(1) 编辑
摘要:以下是代码,先记录下来:http://www.theswamp.org/index.php?topic=44472.0 阅读全文
posted @ 2014-03-18 16:28 swtool 阅读(362) 评论(0) 推荐(0) 编辑
摘要:本文转自网络,未经测试,留存备用!http://blog.sina.com.cn/s/blog_49a9ee1401016843.htmlBy Adam NagyI would like to serialize my .NET class into an AutoCAD drawing database, so it is saved into the drawing, and I can recreate my class again (deserialize it), when the drawing is reopened. How could I do it?SolutionYou 阅读全文
posted @ 2014-03-18 09:07 swtool 阅读(934) 评论(0) 推荐(0) 编辑
摘要:经常从网上复制的代码都有很多空行,一行行删除太费事,现在我找到了一个方法,按下面的步骤即可一次性把所有的空行删除1. Click Ctrl+H (quick replace)2. Tick "Use Regular Expressions"3. In Find specify "^$\n"4. In Replace box delete everything.5. Click "Replace All"All Blank lines will be deleted. ^ Means Beginning of line $ Means 阅读全文
posted @ 2014-03-17 12:28 swtool 阅读(556) 评论(0) 推荐(0) 编辑
摘要:ResultBuffer相关的常量值,如常用的5005代表string,5006代表objectId 1 ' Type of resbuf element 2 Const RTNONE As Short = 5000 3 ' No result 4 Const RTREAL As Short = 5001 5 ' Real number 6 Const RTPOshort As Short = 5002 7 ' 2D poshort X and Y only 8 Const RTSHORT As Short = 5003 9 ' Short intege 阅读全文
posted @ 2014-03-17 09:53 swtool 阅读(909) 评论(0) 推荐(0) 编辑
摘要:1 Math.cell 2 语法:Math.cell(x); 3 参数:X是一个数值或者表达式。 4 说明:返回所给参数的近似整数值,近假值为向上取整所得的数值,取近似值为大于等于参数的整数。 5 6 7 Math.round 8 语法:Math.round(x); 9 参数:X为一个数值。10 说明:返回对参数X四舍五入后所得的整数近似值。11 12 13 Math.floor14 语法:Math.floor(x);15 参数:X是一个数值或者表达式。16 说明:返回所给参数的近似整数值,近似值为向下取整所得的数值,即近似值为小于等于参数的整数。 阅读全文
posted @ 2014-03-17 09:14 swtool 阅读(363) 评论(0) 推荐(0) 编辑
摘要:利用linq获取在两点确定的矩形内的块参照Query syntax:private ObjectId[] FindBlockReferencesInRectangle(Point3d pt1, Point3d pt2, Database db) { using (Transaction tr = db.TransactionManager.StartOpenCloseTransaction()) using (Line line = new Line(pt1, pt2)) { Exte... 阅读全文
posted @ 2014-03-16 22:34 swtool 阅读(998) 评论(0) 推荐(0) 编辑
摘要://获取块表 BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead); //获取图纸空间的块表记录 BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.PaperSpace], OpenMode.ForRead); //在这些块表记录中进行循环... 阅读全文
posted @ 2014-03-14 22:56 swtool 阅读(1993) 评论(0) 推荐(0) 编辑
摘要:if (db.TileMode){ ed.WriteMessage("\n当前正激活的空间为:【模型空间】");}else if (db.CurrentSpaceId == SymbolUtilityServices.GetBlockModelSpaceId(db)){ ed.WriteMessage("\n当前正激活的空间为:【paperspace中某一个激活的视口】");}else{ ed.WriteMessage("\n当前正激活的空间为:【图纸空间】");} 阅读全文
posted @ 2014-03-14 15:09 swtool 阅读(605) 评论(0) 推荐(0) 编辑
摘要:就满足以下需求:按图号区分图层,因为图纸在经过反复修改后,每张图纸的版次到后面都不一样了,关闭一个图层不能影响其它的图纸中的修改标记。自动判断机修改标记所在的图纸,从而自动得到当前图号和版次,再得到相应图层和修改标记号。自动判断修改标记所在的视口并自动根据视口比例放大。修改标记可以从块库选择自定义属性块插入并rename。对于非标准输入框的图纸则提示用户输入当前图纸和版次以便于区分图层。自动建立图层的规则为:将图号中的“/”替换为"."后加“RX”,X为取得的版次。其中涉及的知识点:当前点在模型空间时,根据当前点判断其所在的视口并且得到标记需要放大的比例,如果有两个以上对应 阅读全文
posted @ 2014-03-11 21:18 swtool 阅读(271) 评论(0) 推荐(0) 编辑
摘要:条件编译的原理是满足【条件编译符号】(见下图)时代码才有用,这帮我们CAD二次开发人解决一个很大的难题,我们可以只用维护一套代码就可以了,避免多套代码管理起来混乱我采用的是:一套代码文件加若干project框架来实现,打个简单的比喻,project框架相当于是一个酒瓶子,而代码则是其中的酒,瓶子可以有不同的外形(.net版本、cad版本),也可以贴不同的标签(相当于引用文件),但不管怎么弄,里面的酒(代码,采用【从主程序中链接的方式,见后面的图片】)都还是酒……示例解决方案http://pan.baidu.com/s/1gdsWSVp以下为示例代码: #if(Ca... 阅读全文
posted @ 2014-03-11 09:33 swtool 阅读(1806) 评论(1) 推荐(0) 编辑
摘要:我用的win7x64+vs2010+autocad 2013http://bbs.mjtd.com/thread-107357-1-1.html 阅读全文
posted @ 2014-03-09 22:15 swtool 阅读(495) 评论(0) 推荐(0) 编辑
摘要:搜索发现国内很少有人开AutoCAD.Net二次开发的博客,正好我自己在学习这方面的知识,所以就想到在此开通博客,希望大家一起来学习用C#.Net对AutoCAD的二次开发。同时也希望各位同行也将自己的学习心得分享到博客,这样大家共同进步。 阅读全文
posted @ 2014-03-09 16:32 swtool 阅读(196) 评论(0) 推荐(0) 编辑

欢迎加我的QQ群:193522571,一起来讨论、交流!
点击右上角即可分享
微信分享提示