Civil 3d中“计算材质”
作者:互联网
根据Autodesk 论坛中的帖子修改的测试代码
在其他帖子中看到自己曾经写过类型的代码,
可惜找不到了。
前提:
采样线编组采样源已经设置完毕:
如下图:
目标:
测试代码:
[CommandMethod("QtoTest")] public void C_QtoTest() { CivilDocument cdoc = CivilApplication.ActiveDocument; Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database; Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; PromptEntityOptions peo = new PromptEntityOptions("\n拾取采样线"); peo.SetRejectMessage("\n拾取对象应为采样线"); peo.AddAllowedClass(typeof(SampleLine), true); PromptEntityResult per = ed.GetEntity(peo); if (per.Status != PromptStatus.OK) return; using (Transaction ts = Autodesk.AutoCAD.ApplicationServices.Application .DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction()) { SampleLine sl = ts.GetObject(per.ObjectId, OpenMode.ForRead) as SampleLine; SampleLineGroup sampleLineGrp = ts.GetObject(sl.GroupId, OpenMode.ForWrite) as SampleLineGroup; SectionSourceCollection sectionSources = sampleLineGrp.GetSectionSources(); ed.WriteMessage("Number of section sources: {0}\n", sectionSources.Count); ObjectIdCollection surfaceId = new ObjectIdCollection(); ObjectId corridorId = ObjectId.Null; foreach (SectionSource sectionSource in sectionSources) { if ((sectionSource.SourceType == SectionSourceType.TinSurface || sectionSource.SourceType == SectionSourceType.CorridorSurface) && sectionSource.IsSampled == true) { //sectionSource.IsSampled = true; surfaceId.Add(sectionSource.SourceId); } else if (sectionSource.SourceType == SectionSourceType.Corridor) { corridorId = sectionSource.SourceId; } } QTOMaterialList qtoMaterialList = sampleLineGrp.MaterialLists.Add("填挖方"); QTOMaterial qtoMaterial1 = qtoMaterialList.Add("填方"); qtoMaterial1.QuantityType = MaterialQuantityType.Fill; QTOMaterialItem qtomaterialitem1 = qtoMaterial1.Add(surfaceId[0]); QTOMaterialItem qtomaterialitem2 = qtoMaterial1.Add(surfaceId[1]); qtomaterialitem1.Condition = MaterialConditionType.Above; qtomaterialitem2.Condition = MaterialConditionType.Below; QTOMaterial qtoMaterial2 = qtoMaterialList.Add("挖方"); qtoMaterial2.QuantityType = MaterialQuantityType.Cut; qtomaterialitem1 = qtoMaterial2.Add(surfaceId[0]); qtomaterialitem2 = qtoMaterial2.Add(surfaceId[1]); qtomaterialitem1.Condition = MaterialConditionType.Below; qtomaterialitem2.Condition = MaterialConditionType.Above; //QTOMaterialGapCollection QTOMGC = qtoMaterial2.MaterialGaps; QTOMaterial qtoMaterial3 = qtoMaterialList.Add("基础表层"); qtoMaterial3.QuantityType = MaterialQuantityType.Structure; qtomaterialitem1 = qtoMaterial3.Add(corridorId, "Base1"); ts.Commit(); } }
标签:Autodesk,Civil,sectionSource,Add,qtomaterialitem1,材质,surfaceId,qtoMaterial2,3d 来源: https://www.cnblogs.com/myzw/p/16296992.html