Civil 3d 获取横断面填挖面积
很久以前的测试代码,
昨天QQ群中有群友询问类似的问题,
这代码放自己硬盘中也产生不了什么价值,
不如分享到这里!
有类似需求的朋友可以参考一下。
// Put your command code here Document doc = Application.DocumentManager.MdiActiveDocument; Editor ed; if (doc == null) return; ed = doc.Editor; PromptEntityOptions peo = new PromptEntityOptions("\n选择路线"); peo.SetRejectMessage("\n选择的对象必须为路线"); peo.AddAllowedClass(typeof(Alignment), true); PromptEntityResult per = ed.GetEntity(peo); if (per.Status != PromptStatus.OK) return; using (Transaction tr = doc.TransactionManager.StartTransaction()) { Alignment alignment = per.ObjectId.GetObject(OpenMode.ForRead) as Alignment; try { ObjectId sampleLineGroupId = alignment.GetSampleLineGroupIds()[0]; SampleLineGroup slg = sampleLineGroupId.GetObject(OpenMode.ForRead) as SampleLineGroup; var mls = slg.MaterialLists; foreach(QTOMaterialList ml in mls) { string name = ml.Name; foreach(QTOMaterial m in ml) { string name1 = m.Name; var t = m.QuantityType; } } string[] names = slg.GetQTOMappingNames(); if (names.Length < 1) { tr.Abort(); return; } //https://forums.autodesk.com/t5/civil-3d-customization/i-want-to-get-each-material-volume-data-not-the-total-volume/td-p/8918744?profile.language=zh-CN QuantityTakeoffResult qtoResult = slg.GetTotalVolumeResultDataForMaterialList(slg.GetMappingGuid(names[0])); QTOSectionalResult qtoSectionalResult = qtoResult.GetResultsAlongSampleLines()[1]; QTOAreaResult qtoAreaResult = qtoSectionalResult.AreaResult; double cutarea = qtoAreaResult.CutArea; double fillarea = qtoAreaResult.FillArea; ed.WriteMessage("\n挖方面积为{0:0.00},填方面积为{1:0.00}", cutarea, fillarea); } catch (System.Exception ex) { ed.WriteMessage(ex.Message); } tr.Commit(); }
标签:
Civil3d
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?