修改采样线名称
Posted david96007
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了修改采样线名称相关的知识,希望对你有一定的参考价值。
问题来源:
在Autodesk论坛中,一位朋友提出了这样一个问题:要把路线曲线点、超高点等特征信息在横断面图标题中显示出来,注意是横断面图。
解决方法:
如果直接解决这个问题,貌似不可行,但可以稍稍绕一点路,通过采样线名称来实现——把采样线名称当做横断面图的标题!
这样以来,我们只需修改采样线名称即可!手工修改应该不大现实,我们可以通过简单的代码来实现!
代码如下:
注意这只是测试代码,测试前提假定路线有一个采样线编组,如果采样线编组多于一个,代码也只能修改第一个采样线编组中采样线的名称。
超高点、纵断面点的操作类似,代码没有给出,有兴趣的朋友可以自行完成。
using System; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.Civil.ApplicationServices; using Autodesk.Civil.DatabaseServices; using Autodesk.Civil.Settings; namespace ProfileTools { class RenameSampleline { Document doc; Editor ed; CivilDocument civilDoc; public RenameSampleline() { doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; ed = doc.Editor; civilDoc = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument; } public void DoSth() { PromptEntityOptions opt = new PromptEntityOptions( "\\n选择路线"); opt.AllowNone = true; opt.SetRejectMessage("\\n选定的图元必须属于类型:采样线!"); opt.AddAllowedClass(typeof(Alignment), false); PromptEntityResult res = doc.Editor.GetEntity(opt); if (res.Status != PromptStatus.OK) return; using (Transaction tr = doc.Database.TransactionManager.StartTransaction()) { Alignment al = res.ObjectId.GetObject(OpenMode.ForRead) as Alignment; if (al != null) { ObjectIdCollection ids = al.GetSampleLineGroupIds(); if (ids.Count > 0) { Station[] stas = al.GetStationSet(StationTypes.All); SampleLineGroup slg = ids[0].GetObject(OpenMode.ForRead) as SampleLineGroup; if (slg != null) { ids = slg.GetSampleLineIds(); foreach (ObjectId id in ids) { SampleLine sl = id.GetObject(OpenMode.ForWrite) as SampleLine; double sta = sl.Station; sl.Name= GetStaStr(stas, sta); } } } } tr.Commit(); } } private string GetStaStr(Station[] stas, double sta) { string str = ""; foreach (Station station in stas) { if (Math.Abs(station.RawStation - sta) < 0.002) { AlignmentGeometryPointStationType types = station.GeometryStationType; switch(types) { case AlignmentGeometryPointStationType.BegOfAlign: str = civilDoc.Settings.DrawingSettings.AbbreviationsSettings.AlignmentGeoPointText.GetAlignmentAbbreviation(AbbreviationAlignmentType.AlignmentBeginning); break; case AlignmentGeometryPointStationType.EndOfAlign: str = civilDoc.Settings.DrawingSettings.AbbreviationsSettings.AlignmentGeoPointText.GetAlignmentAbbreviation(AbbreviationAlignmentType.AlignmentEnd); break; case AlignmentGeometryPointStationType.TanTan: str = civilDoc.Settings.DrawingSettings.AbbreviationsSettings.AlignmentGeoPointText.GetAlignmentAbbreviation(AbbreviationAlignmentType.TangentTangentIntersect); break; case AlignmentGeometryPointStationType.TanCurve: str = civilDoc.Settings.DrawingSettings.AbbreviationsSettings.AlignmentGeoPointText.GetAlignmentAbbreviation(AbbreviationAlignmentType.TangentCurveIntersect); break; case AlignmentGeometryPointStationType.CurveTan: str = civilDoc.Settings.DrawingSettings.AbbreviationsSettings.AlignmentGeoPointText.GetAlignmentAbbreviation(AbbreviationAlignmentType.CurveTangentIntersect); break; case AlignmentGeometryPointStationType.CurveCompCurve: str = civilDoc.Settings.DrawingSettings.AbbreviationsSettings.AlignmentGeoPointText.GetAlignmentAbbreviation(AbbreviationAlignmentType.CompoundCurveCurveIntersect); break; case AlignmentGeometryPointStationType.CurveRevCurve: str = civilDoc.Settings.DrawingSettings.AbbreviationsSettings.AlignmentGeoPointText.GetAlignmentAbbreviation(AbbreviationAlignmentType.ReverseCurveCurveIntersect); break; case AlignmentGeometryPointStationType.TanSpiral: str = civilDoc.Settings.DrawingSettings.AbbreviationsSettings.AlignmentGeoPointText.GetAlignmentAbbreviation(AbbreviationAlignmentType.TangentSpiralIntersect); break; case AlignmentGeometryPointStationType.SpiralTan: str = civilDoc.Settings.DrawingSettings.AbbreviationsSettings.AlignmentGeoPointText.GetAlignmentAbbreviation(AbbreviationAlignmentType.SpiralTangentIntersect); break; case AlignmentGeometryPointStationType.CurveSpiral: str = civilDoc.Settings.DrawingSettings.AbbreviationsSettings.AlignmentGeoPointText.GetAlignmentAbbreviation(AbbreviationAlignmentType.CurveSpiralIntersect); break; case AlignmentGeometryPointStationType.SpiralCurve: str = civilDoc.Settings.DrawingSettings.AbbreviationsSettings.AlignmentGeoPointText.GetAlignmentAbbreviation(AbbreviationAlignmentType.SpiralCurveIntersect); break; case AlignmentGeometryPointStationType.SpiralCompSpiral: str = civilDoc.Settings.DrawingSettings.AbbreviationsSettings.AlignmentGeoPointText.GetAlignmentAbbreviation(AbbreviationAlignmentType.SpiralSpiralIntersect); break; case AlignmentGeometryPointStationType.SpiralRevSpiral: str = civilDoc.Settings.DrawingSettings.AbbreviationsSettings.AlignmentGeoPointText.GetAlignmentAbbreviation(AbbreviationAlignmentType.ReverseSpiralIntersect); break; case AlignmentGeometryPointStationType.ProfileTanCurve: str = civilDoc.Settings.DrawingSettings.AbbreviationsSettings.Profile.GetProfileAbbreviation(AbbreviationProfileType.BeginVerticalCurve); break; } break; } } if (str=="") { return sta.ToString("0+000.00"); } return str+"_"+sta.ToString("0+000.00"); } } }
测试结果如下:
这些简写,可以通过修改图形设置进行自定义。
以上是关于修改采样线名称的主要内容,如果未能解决你的问题,请参考以下文章
音频处理Melodyne 选择工具使用 ( 主工具简介 | 修改音高 | 自动吸附 | 音符长度修改 | 长度自动吸附 | 设置音符分离线 | 设置片段分离线 )