- /// <summary>
- /// 测试命令Tt
- /// </summary>
- [CommandMethod(nameof(Tt), CommandFlags.Session | CommandFlags.UsePickSet)]
- public void Tt()
- {
- var doc = Acap.DocumentManager.MdiActiveDocument;
- var db = doc.Database;
- using var dloc = doc.LockDocument();
- using var tr = db.TransactionManager.StartTransaction();
- var lty = (LinetypeTableRecord)tr.GetObject(db.Celtype, OpenMode.ForRead);
- var dashes1 = lty.GetDashes();
- if ("ByLayer".ToUpper().Equals(lty.Name.ToUpper()))
- {
- //var layer = (LayerTableRecord)curve.LayerId.GetObject();
- var layer = (LayerTableRecord)db.Clayer.GetObject();
- lty = (LinetypeTableRecord)layer.LinetypeObjectId.GetObject();
- }
- var dashes2 = lty.GetDashes();
- }
- /// <summary>
- /// 获取线型定义的长度间隔数据
- /// </summary>
- /// <param name="linetype">线型对象</param>
- /// <returns>长度间隔数据数组</returns>
- public static double[] GetDashes(this LinetypeTableRecord linetype)
- {
- return Enumerable.Range(0, linetype.NumDashes)
- .Select(i => linetype.DashLengthAt(i).ToRound()).ToArray();
- }
- /// <summary>
- /// 四舍五入
- /// </summary>
- /// <param name="value">数值;类型:double</param>
- /// <param name="digits">小数点位数;默认:8位;类型:int</param>
- /// <returns>四舍五入后的数值</returns>
- public static double ToRound(this double value, int digits = 8) => Math.Round(value, digits, MidpointRounding.AwayFromZero);
|