博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
autocad.net 利用linq获取矩形框内的块参照
阅读量:4497 次
发布时间:2019-06-08

本文共 2565 字,大约阅读时间需要 8 分钟。

利用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))            {                Extents3d bound = line.GeometricExtents;                BlockTableRecord modelSpace = (BlockTableRecord)tr.GetObject(                  SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForRead);                Func
isBlockReference = (id => id.ObjectClass == RXClass.GetClass(typeof(BlockReference))); Func
isInside = (id => { BlockReference br = (BlockReference)tr.GetObject(id, OpenMode.ForRead); Extents3d exts = new Extents3d(bound.MinPoint, bound.MaxPoint); exts.AddExtents(br.GeometricExtents); return bound.IsEqualTo(exts); }); ; var blocks = from ObjectId id in modelSpace where isBlockReference(id) && isInside(id) select id; return blocks.ToArray(); } }
View Code

Extension methods syntax:

private ObjectId[] FindBlockReferencesInRectangle(Point3d pt1, Point3d pt2, Database db)        {            using (Transaction tr = db.TransactionManager.StartOpenCloseTransaction())            using (Line line = new Line(pt1, pt2))            {                Extents3d bound = line.GeometricExtents;                BlockTableRecord modelSpace = (BlockTableRecord)tr.GetObject(                    SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForRead);                Func
isBlockReference = (id => id.ObjectClass == RXClass.GetClass(typeof(BlockReference))); Func
isInside = (id => { BlockReference br = (BlockReference)tr.GetObject(id, OpenMode.ForRead); Extents3d exts = new Extents3d(bound.MinPoint, bound.MaxPoint); exts.AddExtents(br.GeometricExtents); return bound.IsEqualTo(exts); }); return modelSpace .Cast
() .Where(isBlockReference) .Where(isInside) .ToArray(); } }
View Code

 

转载于:https://www.cnblogs.com/swtool/p/SWTOOL_00007.html

你可能感兴趣的文章
构建之法4
查看>>
String to Integer (atoi)
查看>>
Servlet API
查看>>
PyCharm命令行输入
查看>>
Codeforces Round #248 (Div. 2) C. Ryouko's Memory Note
查看>>
js数组操作总结
查看>>
九九乘法表
查看>>
写个.net开发者的Linux迁移指南
查看>>
搭建使用SVN的快速教程
查看>>
openlayers显示区域
查看>>
适配器模式学习
查看>>
第一周博客作业2018091-2
查看>>
Spring boot JPA读取数据库方法
查看>>
TEA对称加密算法
查看>>
Dell笔记本刷回低版本bios的方法
查看>>
redis资料
查看>>
《自己动手写docker》之namespace部门实验
查看>>
Vim学习总结
查看>>
maven也是Apache开发的,也是java开发的。maven需要你本地系统JDK的支持
查看>>
垂直同步v-sync
查看>>