明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 9600|回复: 25

取cass断面数据

    [复制链接]
发表于 2011-1-25 00:21 | 显示全部楼层 |阅读模式
购买主题 已有 50 人购买  本主题需向作者支付 1 个明经币 才能浏览
发表于 2011-9-12 11:17 | 显示全部楼层
本帖最后由 gzxl 于 2011-9-12 11:18 编辑
gzxl 发表于 2011-9-11 03:51
C#的


可以啊,不过里面还没完善,比如判断左正右负等等

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Autodesk.AutoCAD.ApplicationServices;
  6. using Autodesk.AutoCAD.EditorInput;
  7. using Autodesk.AutoCAD.Runtime;
  8. using Autodesk.AutoCAD.DatabaseServices;
  9. using Autodesk.AutoCAD.Geometry;

  10. namespace 断面采集//gzxl
  11. {
  12.     public class Class1
  13.     {
  14.         [CommandMethod("cjdm")]
  15.         public static void cjdm()
  16.         {
  17.             var db = HostApplicationServices.WorkingDatabase;
  18.             var doc = Application.DocumentManager.GetDocument(db);
  19.             var ed = doc.Editor;
  20.             Database acCurDb = doc.Database;

  21.             Application.SetSystemVariable("osmode", 513);
  22.             PromptPointOptions prPointOptions = new PromptPointOptions("\n选择断面起点或中点:");
  23.             PromptPointResult prPointRes;
  24.             prPointRes = ed.GetPoint(prPointOptions);
  25.             if (prPointRes.Status != PromptStatus.OK)
  26.                 return;
  27.             Application.SetSystemVariable("osmode", 0);

  28.             var resEnt = ed.GetEntity("\n请选择断面线(直线):");
  29.             if (resEnt.Status != PromptStatus.OK)
  30.                 return;

  31.             using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
  32.             {
  33.                 Line line = resEnt.ObjectId.GetObject(OpenMode.ForRead) as Line;
  34.                 LineSegment3d ls3d = new LineSegment3d(line.StartPoint, line.EndPoint); ;
  35.                 Line3d l3d = new Line3d(line.StartPoint, line.EndPoint);               
  36.                
  37.                 TypedValue[] acTypValAr = new TypedValue[2];
  38.                 acTypValAr.SetValue(new TypedValue((int)DxfCode.Start, "INSERT"), 0);
  39.                 acTypValAr.SetValue(new TypedValue((int)DxfCode.LayerName, "GCD"), 1);
  40.                 SelectionFilter acSelFtr = new SelectionFilter(acTypValAr);

  41.                 PromptSelectionResult acSSPrompt;
  42.                 acSSPrompt = ed.GetSelection(acSelFtr);

  43.                 if (acSSPrompt.Status == PromptStatus.OK)
  44.                 {
  45.                     SelectionSet acSSet = acSSPrompt.Value;
  46.                     int count2 = 0;
  47.                     string LineText2 = "";
  48.                     //double[] PositionX, PositionY, PositionZ;
  49.                     double[]PositionZ;
  50.                     // 遍历选择集中的对象
  51.                     foreach (SelectedObject acSSObj in acSSet)
  52.                     {
  53.                         // 检查以确定返回的 SelectedObject 对象是有效的
  54.                         if (acSSObj != null)
  55.                         {

  56.                             Entity acEnt = acTrans.GetObject(acSSObj.ObjectId, OpenMode.ForWrite) as Entity;
  57.                             if (acEnt != null)
  58.                             {
  59.                                 count2++;
  60.                                 //PositionX = new Double[count2];
  61.                                 //PositionY = new Double[count2];
  62.                                 PositionZ = new Double[count2];
  63.                                 Point3d Position = ((Autodesk.AutoCAD.DatabaseServices.BlockReference)(acEnt)).Position;
  64.                                 //PositionX[count2 - 1] = Position[0];
  65.                                 //PositionY[count2 - 1] = Position[1];
  66.                                 PositionZ[count2 - 1] = Position[2];   

  67.                                 Point3d pt1 = prPointRes.Value; //断面起点
  68.                                 Point3d pt2 = l3d.GetClosestPointTo(Position).Point;

  69.                                 //double dist = pt2.DistanceTo(pt1);
  70.                                 LineText2 += (pt2 - pt1).Length + "," + PositionZ[count2 - 1].ToString() + "\n";
  71.                             }                           
  72.                         }
  73.                     }
  74.                     ed.WriteMessage(LineText2 + "\n");
  75.                 }
  76.             }
  77.         }
  78.     }
  79. }

评分

参与人数 1明经币 +1 金钱 +5 收起 理由
xgr + 1 + 5 鼓励一下在此版块发布C#源码

查看全部评分

回复 支持 1 反对 0

使用道具 举报

发表于 2017-9-12 22:08 | 显示全部楼层
zjlszw 发表于 2012-2-24 21:52
提取断面数据 我发一个,源码如下:
(defun c:tqdmsj()
(srcs_data)

能否加个循环,能批量提取就好了
发表于 2020-11-1 11:18 | 显示全部楼层
取cass断面数据

没有币下载  也没截图啊。。
 楼主| 发表于 2011-1-25 00:25 | 显示全部楼层
本帖最后由 yjpzc 于 2011-1-25 00:27 编辑

回复 yjpzc 的帖子

取cass断面数据演示
横断面线需要为直线

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2011-9-10 01:10 | 显示全部楼层
不顶此贴哥心里不踏实!
发表于 2011-9-11 03:51 | 显示全部楼层
C#的

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x

点评

只有图啊,貌似挺好的,就不能把程序也发上来么?  发表于 2011-9-11 21:42
发表于 2011-10-5 22:21 | 显示全部楼层
好东西
发表于 2011-10-18 14:56 | 显示全部楼层
没 币咯!郁闷
发表于 2011-10-23 08:22 | 显示全部楼层
顶一下,希望多发一些类似的测绘方面的源码。
发表于 2011-11-11 18:37 | 显示全部楼层
怎么这样子..
发表于 2012-2-8 17:02 | 显示全部楼层
没有钱了 悲哀啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-23 17:07 , Processed in 0.520401 second(s), 36 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表