12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using Autodesk.Revit.DB;
- using Autodesk.Revit.UI.Selection;
- namespace FWindSoft.Revit.Common
- {
- public static class RevitTools
- {
- /// <summary>
- /// 移除非法字符串
- /// </summary>
- /// <param name="strValue"></param>
- /// <returns></returns>
- public static string RemoveForbiddenChars(this string strValue)
- {
- if (string.IsNullOrWhiteSpace(strValue))
- {
- return strValue;
- }
- foreach (var item in RevitSetting.RvtForbiddenChars)
- {
- strValue=strValue.Replace(item, "");
- }
- return strValue;
- }
- public static int RevitLeftPoint
- {
- get
- {
- var mainRec = RevitCore.UIApp.DrawingAreaExtents;
- return mainRec.Left;
- }
- }
- public static int RevitRightPoint
- {
- get
- {
- var mainRec = RevitCore.UIApp.DrawingAreaExtents;
- return mainRec.Right;
- }
- }
- public static int RevitTopPoint
- {
- get
- {
- var mainRec = RevitCore.UIApp.MainWindowExtents;
- return mainRec.Top;
- }
- }
- public static int RevitBottomPoint
- {
- get
- {
- var mainRec = RevitCore.UIApp.DrawingAreaExtents;
- return mainRec.Bottom;
- }
- }
- /// <summary>
- /// 整数转rgb
- /// </summary>
- /// <param name="intColor"></param>
- /// <returns></returns>
- public static Color GetColor(int intColor)
- {
- byte b = (byte)(intColor / (256 * 256));
- byte g = (byte)((intColor - b * 256 * 256) / 256);
- byte r = (byte)(intColor - b * 256 * 256 - g * 256);
- return new Color(r, g, b);
- }
- /// <summary>
- /// rgb转整数(Revit参数使用)
- /// </summary>
- /// <param name="color"></param>
- /// <returns></returns>
- public static int GetColor(Color color)
- {
- return color.Red + color.Green * 256 + color.Blue * 256 * 256;
- }
- }
- }
|