更新图例功能

This commit is contained in:
GG Z
2021-11-12 11:40:43 +08:00
parent 8300d032cb
commit e16b1c0f4a
83 changed files with 1879 additions and 496 deletions

View File

@@ -11,7 +11,7 @@ namespace RookieStation.CommonTools.ExecuteCmd
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdChangeBackgroundColor : IExternalCommand
internal class ChangeBackgroundColor : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{

View File

@@ -14,7 +14,7 @@ namespace RookieStation.CommonTools.ExecuteCmd
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdDecryptFamily : IExternalCommand
internal class DecryptFamily : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{

View File

@@ -14,7 +14,7 @@ namespace RookieStation.CommonTools.ExecuteCmd
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdEncryptFamily : IExternalCommand
internal class EncryptFamily : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{

View File

@@ -7,7 +7,7 @@ namespace RookieStation.CommonTools.ExecuteCmd
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdUseFamilyPane : IExternalCommand
internal class UseFamilyPane : IExternalCommand
{
private Guid guid = new Guid("{028001AD-0588-4A9C-AA03-D7E472D85050}");

View File

@@ -11,7 +11,7 @@ namespace RookieStation.Drawing.ExecuteCmds
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdBatchExportDwg : IExternalCommand
internal class BatchExportDwg : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{

View File

@@ -1,180 +0,0 @@
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using RookieStation.Drawing.Models;
using RookieStation.Extension;
using RookieStation.ProjectConfig;
using RookieStation.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Controls;
namespace RookieStation.Drawing.ExecuteCmds
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdCreateShelvesLegend : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
if (uidoc.ActiveView.ViewType == ViewType.DrawingSheet)
{
var portRefer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter<Viewport>(), "请选择参考的视口确定比例尺");
var location = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择左下角点放置图例");
var viewport = doc.GetElement(portRefer) as Viewport;
var viewPlan = doc.GetElement(viewport.ViewId);
if (!(viewPlan is ViewPlan))
{
TaskDialog.Show("温馨提示", "请选择平面视图的视口");
return Result.Failed;
}
try
{
doc.InvokeGroup(tg =>
{
var viewScale = viewport.get_Parameter(BuiltInParameter.VIEW_SCALE).AsInteger();
View legend = null;
doc.Invoke(ts =>
{
legend = RsRevitUtils.CreateNewLegend(doc, "货架说明", viewScale);
});
doc.Invoke(ts =>
{
var shelvesData = GetShelfData(doc);
CreateShelfLegend(doc, shelvesData, legend, viewScale);
});
doc.Invoke(ts =>
{
RsRevitUtils.SetLegendLocation(doc, legend, location);
});
}, "创建货架图例");
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
}
}
else
{
TaskDialog.Show("温馨提示", "请打开图纸视图");
return Result.Failed;
}
return Result.Succeeded;
}
private List<ShelfStatistic> GetShelfData(Document doc)
{
var shelves = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_Furniture).Cast<FamilyInstance>().Where(s => s.Symbol.FamilyName.Contains("货架"));
var rooms = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).Cast<Room>();
double area = 0.0;
foreach (var room in rooms)
{
area += RsRevitUtils.ConvertSquareFeetToSquareMetre(room.get_Parameter(BuiltInParameter.ROOM_AREA).AsDouble());
}
var shelfGroup = shelves.GroupBy(g => g.Name);
List<ShelfStatistic> statistics = new List<ShelfStatistic>();
foreach (var group in shelfGroup)
{
var instance = group.ElementAt(0);
var l = instance.Symbol.GetParameters("长度").FirstOrDefault().AsValueString();
ShelfStatistic shelfStatistic = new ShelfStatistic
{
ShelfType = instance.Name,
Count = group.Count(),
GroundArea = Math.Round(area, 2),
DesignOrders = UserConstant.Orders
};
shelfStatistic.LinearMetre = shelfStatistic.Count * Convert.ToDouble(l) / 1000;
shelfStatistic.CapacityOrders = Convert.ToInt32(shelfStatistic.LinearMetre * 80);
statistics.Add(shelfStatistic);
}
return statistics;
}
/// <summary>
/// 创建表格、文字
/// </summary>
/// <param name="doc"></param>
/// <param name="statistics"></param>
/// <param name="newLegend"></param>
/// <param name="viewScale"></param>
private void CreateShelfLegend(Document doc, List<ShelfStatistic> statistics, View newLegend, int viewScale)
{
TextNoteType textNoteType = new FilteredElementCollector(doc).OfClass(typeof(TextNoteType)).Where(x => x.Name.Contains(UserConstant.FontName)).FirstOrDefault() as TextNoteType;
if (textNoteType == null)
{
textNoteType = new FilteredElementCollector(doc).OfClass(typeof(TextNoteType)).Cast<TextNoteType>().FirstOrDefault().Duplicate(UserConstant.FontName) as TextNoteType;
textNoteType.get_Parameter(BuiltInParameter.TEXT_SIZE).SetValueString("2.5");
textNoteType.get_Parameter(BuiltInParameter.TEXT_WIDTH_SCALE).SetValueString("0.8");
}
double fontSize = textNoteType.get_Parameter(BuiltInParameter.TEXT_SIZE).AsDouble();
double actualTextHeight = fontSize * 1.6;
double tableCellHeight = actualTextHeight * viewScale * 1.2;//图例网格高度
double tableCellWidth = tableCellHeight * 5;//图例网格长度
double[] widths = new double[6] { tableCellHeight * 2, tableCellHeight * 2, tableCellHeight * 6, tableCellHeight * 2, tableCellHeight * 2, tableCellHeight * 2 };
CurveArray curveArray = new CurveArray();
for (int i = statistics.Count + 1; i >= 0; i--)//水平线
{
Curve line;
if (i > 0 && i < statistics.Count)
{
line = Line.CreateBound(XYZ.Zero, XYZ.BasisX * tableCellWidth * 3).CreateOffset(tableCellHeight * i, -XYZ.BasisZ);
}
else
{
line = Line.CreateBound(XYZ.Zero, XYZ.BasisX * tableCellWidth * 6).CreateOffset(tableCellHeight * i, -XYZ.BasisZ);
}
curveArray.Append(line);
}
for (int i = 0; i < 7; i++)//垂直线
{
Curve line = Line.CreateBound(XYZ.Zero, XYZ.BasisY * (statistics.Count() + 1) * tableCellHeight).CreateOffset(tableCellWidth * i, XYZ.BasisZ);
curveArray.Append(line);
}
var y = XYZ.BasisY * tableCellHeight * (statistics.Count + 0.5);
var opts = new TextNoteOptions(textNoteType.Id)
{
VerticalAlignment = VerticalTextAlignment.Middle,
HorizontalAlignment = HorizontalTextAlignment.Center
};
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * tableCellWidth * 0.5 + y, "货架类型", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableCellWidth * 1.5) + y, "数量", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableCellWidth * 2.5) + y, "总延米", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableCellWidth * 3.5) + y, "总承载单量", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableCellWidth * 4.5) + y, "日均单量", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableCellWidth * 5.5) + y, "场地面积", opts);
for (int i = 0; i < statistics.Count(); i++)
{
var yElevation = XYZ.BasisY * tableCellHeight * (i + 0.5);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * tableCellWidth * 0.5 + yElevation, statistics[i].ShelfType, opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableCellWidth * 1.5) + yElevation, statistics[i].Count.ToString(), opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableCellWidth * 2.5) + yElevation,
statistics[i].LinearMetre.ToString(), opts);
}
//承载单量总和
int orders = 0;
for (int i = 0; i < statistics.Count; i++)
{
orders += statistics[i].CapacityOrders;
}
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableCellWidth * 3.5) + XYZ.BasisY * tableCellHeight * statistics.Count() / 2, orders.ToString(), opts);
//设计单量
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableCellWidth * 4.5) + XYZ.BasisY * tableCellHeight * statistics.Count() / 2, statistics.FirstOrDefault().DesignOrders.ToString(), opts);
//面积
TextNote area = TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableCellWidth * 5.5) + XYZ.BasisY * tableCellHeight * statistics.Count() / 2, statistics[0].GroundArea + "m2".ToString(), opts);
FormattedText formattedText = new FormattedText(area.Text);
TextRange range = new TextRange(area.Text.Length - 2, 1);
formattedText.SetSuperscriptStatus(range, true);
area.SetFormattedText(formattedText);
var curves = doc.Create.NewDetailCurveArray(newLegend, curveArray);
}
}
}

View File

@@ -0,0 +1,140 @@
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using RookieStation.Drawing.Models;
using RookieStation.Extension;
using RookieStation.ProjectConfig;
using RookieStation.Utils;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Controls;
namespace RookieStation.Drawing.ExecuteCmds
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CreateFurnitureLegend : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
if (uidoc.ActiveView.ViewType == ViewType.DrawingSheet)
{
try
{
var portRefer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter<Viewport>(), "请选择参考的视口以确定比例");
var location = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择左下角点放置图例");
var viewport = doc.GetElement(portRefer) as Viewport;
var viewPlan = doc.GetElement(viewport.ViewId);
if (!(viewPlan is ViewPlan))
{
TaskDialog.Show("温馨提示", "请选择平面视图的视口");
return Result.Failed;
}
doc.InvokeGroup(tg =>
{
var viewScale = viewport.get_Parameter(BuiltInParameter.VIEW_SCALE).AsInteger();
View legend = null;
doc.Invoke(ts =>
{
legend = RsRevitUtils.CreateNewLegend(doc, "家具图例", viewScale);
});
doc.Invoke(ts =>
{
var furnitureData = GetData(doc);
CreateLegend(doc, furnitureData, legend);
});
doc.Invoke(ts =>
{
RsRevitUtils.SetLegendLocation(doc, legend, location);
});
}, "创建家具图例");
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
}
}
else
{
TaskDialog.Show("温馨提示", "请打开图纸视图");
return Result.Failed;
}
return Result.Succeeded;
}
/// <summary>
/// 获取货架数据
/// </summary>
/// <param name="doc"></param>
/// <returns></returns>
private List<dynamic> GetData(Document doc)
{
var furnitures = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_Furniture).Cast<FamilyInstance>();
//按族分组
var familyGroups = furnitures.GroupBy(g => g.Symbol.FamilyName);
var data = new List<dynamic>();
//遍历每个族的分组
foreach (var instanceByFamily in familyGroups)
{
//按族类型分组
var symbolGroups = instanceByFamily.GroupBy(g => g.Name);
//遍历每个族类型
foreach (var instancesBySymbol in symbolGroups)
{
//var instance = instancesBySymbol.ElementAt(0);
dynamic datarow = new { FamilyName = instanceByFamily.Key, SymbolName = instancesBySymbol.Key, Count = instancesBySymbol.Count().ToString() };
data.Add(datarow);
}
}
dynamic headrow = new { FamilyName = "家具类型", SymbolName = "家具尺寸", Count = "数量" };
data.Add(headrow);
return data;
}
private void CreateLegend(Document doc, List<dynamic> data, View newLegend)
{
TextNoteType textNoteType = RsRevitUtils.GetOrNewTextNoteType(doc, UserConstant.TextSymbolName);
double fontSize = textNoteType.get_Parameter(BuiltInParameter.TEXT_SIZE).AsDouble();
double tableGridHeight = fontSize * newLegend.Scale * 2;//图例网格高度
double tableGridWidth = tableGridHeight * 2.5;
double[] widths = new double[3] { tableGridWidth * 2, tableGridWidth * 3, tableGridWidth };
RsRevitUtils.CreateTable(doc, newLegend, data.Count, 3, tableGridHeight, widths);
var opts = new TextNoteOptions(textNoteType.Id)
{
HorizontalAlignment = HorizontalTextAlignment.Center,
VerticalAlignment = VerticalTextAlignment.Middle,
};
for (int i = 0; i < data.Count; i++)
{
var y = XYZ.BasisY * (i + 0.5) * tableGridHeight;
var datarow = data[i];
//doc.Create.NewFamilyInstance(XYZ.BasisX * (tableGridWidth / 2) + y, datarow.GetType().GetProperty("FamilyName").GetValue(datarow).ToString(), newLegend);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth) + y, datarow.GetType().GetProperty("FamilyName").GetValue(datarow).ToString(), opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 7 / 2) + y, datarow.GetType().GetProperty("SymbolName").GetValue(datarow).ToString(), opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 11 / 2) + y, datarow.GetType().GetProperty("Count").GetValue(datarow).ToString(), opts);
//TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 7 / 2) + y, $"{item.Count}个", opts);
//LegendItem item = data[i];
//y = XYZ.BasisY * (i + 0.5) * tableGridHeight;
//if (item.PlaneLegendType != null)
//{
// doc.Create.NewFamilyInstance(XYZ.BasisX * (tableGridWidth / 2) + y, item.PlaneLegendType, newLegend);
//}
//TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 3 / 2) + y, item.Description, opts);
//if (item.ElevationLegend != null)
//{
// doc.Create.NewFamilyInstance(XYZ.BasisX * (tableGridWidth * 5 / 2) + y, item.ElevationLegend, newLegend);
//}
//if (item.Count != 0)
//{
// TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 7 / 2) + y, $"{item.Count}个", opts);
//}
}
}
}
}

View File

@@ -0,0 +1,315 @@
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;
using RookieStation.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RookieStation.Extension;
using RookieStation.ProjectConfig;
namespace RookieStation.Drawing.ExecuteCmds
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CreateGroundPavingLegend : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
if (uidoc.ActiveView.ViewType == ViewType.DrawingSheet)
{
try
{
var portRefer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter<Viewport>(), "请选择参考的视口以确定比例");
var location = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择左下角点放置图例");
var viewport = doc.GetElement(portRefer) as Viewport;
var viewPlan = doc.GetElement(viewport.ViewId);
if (!(viewPlan is ViewPlan))
{
TaskDialog.Show("温馨提示", "请选择平面视图的视口");
return Result.Failed;
}
doc.InvokeGroup(tg =>
{
var viewScale = viewport.get_Parameter(BuiltInParameter.VIEW_SCALE).AsInteger();
View legend = null;
doc.Invoke(ts =>
{
legend = RsRevitUtils.CreateNewLegend(doc, "地面铺贴图例", viewScale);
});
doc.Invoke(ts =>
{
var items = GetData(doc);
CreateLegend(doc, items, legend);
});
doc.Invoke(ts =>
{
RsRevitUtils.SetLegendLocation(doc, legend, location);
});
}, "创建地面铺贴图例");
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
}
}
else
{
TaskDialog.Show("温馨提示", "请打开图纸视图");
return Result.Failed;
}
return Result.Succeeded;
}
/// <summary>
/// 获取数据
/// </summary>
/// <param name="doc"></param>
/// <returns></returns>
private List<dynamic> GetData(Document doc)
{
var floors = new FilteredElementCollector(doc).OfClass(typeof(Floor)).OfCategory(BuiltInCategory.OST_Floors);
var sites = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_Site);
var filledRegionTypes = new FilteredElementCollector(doc).OfClass(typeof(FilledRegionType)).OfCategory(BuiltInCategory.OST_DetailComponents);
var data = new List<dynamic>();
//按族分组
var floorTypeGroups = floors.GroupBy(g => g.Name);
//遍历每个族的分组
foreach (var instanceByFamily in floorTypeGroups)
{
var floor = instanceByFamily.ElementAt(0) as Floor;
var floorType = floor.FloorType;
string floorTypeName = floorType.Name;
for (int i = 0; i < filledRegionTypes.Count(); i++)
{
var t = filledRegionTypes.ElementAt(i) as FilledRegionType;
if (floorTypeName.Contains(t.Name))
{
dynamic datarow = new { FilledRegionTypeName = t.Name, TypeName = floorTypeName };
data.Add(datarow);
break;
}
//如果没找到填充图案则新建
if (i == filledRegionTypes.Count() - 1)
GetOrNewFloorTypeFilledRegionType(doc, floorType, floorTypeName, t);
}
}
var siteGroups = sites.GroupBy(s => s.Name);
foreach (var siteGroup in siteGroups)
{
var site = siteGroup.ElementAt(0) as FamilyInstance;
var symbol = site.Symbol;
string symbolTypeName = symbol.Name;
for (int i = 0; i < filledRegionTypes.Count(); i++)
{
var t = filledRegionTypes.ElementAt(i) as FilledRegionType;
if (symbolTypeName.Contains(t.Name))
{
dynamic datarow = new { FilledRegionTypeName = t.Name, TypeName = symbolTypeName };
data.Add(datarow);
break;
}
//如果没找到填充图案则新建
if (i == filledRegionTypes.Count() - 1)
GetOrNewSiteFilledRegion(doc, symbol, symbolTypeName, t);
}
}
return data;
}
private static void GetOrNewSiteFilledRegion(Document doc, FamilySymbol familySymbol, string floorTypeName, FilledRegionType defaultFilledRegionType)
{
FilledRegionType newFilledRegionType = null;
newFilledRegionType = defaultFilledRegionType.Duplicate(floorTypeName) as FilledRegionType;
try
{
ElementId mId = null;
foreach (Parameter item in familySymbol.ParametersMap)
{
if (item.Definition.ParameterType == ParameterType.Material)
{
mId = item.AsElementId();
break;
}
}
var material = doc.GetElement(mId) as Material;
//根据墙体核心层材质,赋予填充图案
if (material.CutForegroundPatternId != ElementId.InvalidElementId)
{
newFilledRegionType.ForegroundPatternId = material.CutForegroundPatternId;
newFilledRegionType.ForegroundPatternColor = material.CutForegroundPatternColor;
newFilledRegionType.BackgroundPatternId = material.CutForegroundPatternId;
newFilledRegionType.BackgroundPatternColor = material.CutForegroundPatternColor;
}
else if (material.CutBackgroundPatternId != ElementId.InvalidElementId)
{
newFilledRegionType.ForegroundPatternId = material.CutBackgroundPatternId;
newFilledRegionType.ForegroundPatternColor = material.CutBackgroundPatternColor;
newFilledRegionType.BackgroundPatternId = material.CutBackgroundPatternId;
newFilledRegionType.BackgroundPatternColor = material.CutBackgroundPatternColor;
}
else if (material.SurfaceForegroundPatternId != ElementId.InvalidElementId)
{
newFilledRegionType.ForegroundPatternId = material.SurfaceForegroundPatternId;
newFilledRegionType.ForegroundPatternColor = material.SurfaceForegroundPatternColor;
newFilledRegionType.BackgroundPatternId = material.SurfaceForegroundPatternId;
newFilledRegionType.BackgroundPatternColor = material.SurfaceForegroundPatternColor;
}
else if (material.SurfaceBackgroundPatternId != ElementId.InvalidElementId)
{
newFilledRegionType.ForegroundPatternId = material.SurfaceBackgroundPatternId;
newFilledRegionType.ForegroundPatternColor = material.SurfaceBackgroundPatternColor;
newFilledRegionType.BackgroundPatternId = material.SurfaceBackgroundPatternId;
newFilledRegionType.BackgroundPatternColor = material.SurfaceBackgroundPatternColor;
}
else
{
newFilledRegionType.ForegroundPatternId = ElementId.InvalidElementId;
newFilledRegionType.BackgroundPatternId = ElementId.InvalidElementId;
}
}
catch (Exception)
{
newFilledRegionType.ForegroundPatternId = ElementId.InvalidElementId;
newFilledRegionType.BackgroundPatternId = ElementId.InvalidElementId;
}
//填充图案默认为空
}
/// <summary>
/// 新建填充图案
/// </summary>
/// <param name="doc"></param>
/// <param name="floorType"></param>
/// <param name="floorTypeName"></param>
/// <param name="defaultFilledRegionType"></param>
private static void GetOrNewFloorTypeFilledRegionType(Document doc, FloorType floorType, string floorTypeName, FilledRegionType defaultFilledRegionType)
{
FilledRegionType newFilledRegionType = null;
newFilledRegionType = defaultFilledRegionType.Duplicate(floorTypeName) as FilledRegionType;
try
{
var compound = floorType.GetCompoundStructure();
var mId = compound.GetMaterialId(compound.GetFirstCoreLayerIndex());
var material = doc.GetElement(mId) as Material;
//根据墙体核心层材质,赋予填充图案
if (material.CutForegroundPatternId != ElementId.InvalidElementId)
{
newFilledRegionType.ForegroundPatternId = material.CutForegroundPatternId;
newFilledRegionType.ForegroundPatternColor = material.CutForegroundPatternColor;
newFilledRegionType.BackgroundPatternId = material.CutForegroundPatternId;
newFilledRegionType.BackgroundPatternColor = material.CutForegroundPatternColor;
}
else if (material.CutBackgroundPatternId != ElementId.InvalidElementId)
{
newFilledRegionType.ForegroundPatternId = material.CutBackgroundPatternId;
newFilledRegionType.ForegroundPatternColor = material.CutBackgroundPatternColor;
newFilledRegionType.BackgroundPatternId = material.CutBackgroundPatternId;
newFilledRegionType.BackgroundPatternColor = material.CutBackgroundPatternColor;
}
else if (material.SurfaceForegroundPatternId != ElementId.InvalidElementId)
{
newFilledRegionType.ForegroundPatternId = material.SurfaceForegroundPatternId;
newFilledRegionType.ForegroundPatternColor = material.SurfaceForegroundPatternColor;
newFilledRegionType.BackgroundPatternId = material.SurfaceForegroundPatternId;
newFilledRegionType.BackgroundPatternColor = material.SurfaceForegroundPatternColor;
}
else if (material.SurfaceBackgroundPatternId != ElementId.InvalidElementId)
{
newFilledRegionType.ForegroundPatternId = material.SurfaceBackgroundPatternId;
newFilledRegionType.ForegroundPatternColor = material.SurfaceBackgroundPatternColor;
newFilledRegionType.BackgroundPatternId = material.SurfaceBackgroundPatternId;
newFilledRegionType.BackgroundPatternColor = material.SurfaceBackgroundPatternColor;
}
else
{
newFilledRegionType.ForegroundPatternId = ElementId.InvalidElementId;
newFilledRegionType.BackgroundPatternId = ElementId.InvalidElementId;
}
}
catch (Exception)
{
newFilledRegionType.ForegroundPatternId = ElementId.InvalidElementId;
newFilledRegionType.BackgroundPatternId = ElementId.InvalidElementId;
}
//填充图案默认为空
}
private void CreateLegend(Document doc, List<dynamic> data, View newLegend)
{
TextNoteType textNoteType = RsRevitUtils.GetOrNewTextNoteType(doc, UserConstant.TextSymbolName);
double fontSize = textNoteType.get_Parameter(BuiltInParameter.TEXT_SIZE).AsDouble();
double headGridHeight = fontSize * newLegend.Scale * 2;//图例网格高度
double tableGridWidth = headGridHeight * 2.5;
double tableGridHeight = headGridHeight * 3;
double[] widths = new double[2] { tableGridWidth * 2, tableGridWidth * 3 };
RsRevitUtils.CreateTable(doc, newLegend, data.Count + 1, 2, headGridHeight, tableGridHeight, widths);
var filledRegionTypes = new FilteredElementCollector(doc).OfClass(typeof(FilledRegionType)).OfCategory(BuiltInCategory.OST_DetailComponents);
var opts = new TextNoteOptions(textNoteType.Id)
{
HorizontalAlignment = HorizontalTextAlignment.Center,
VerticalAlignment = VerticalTextAlignment.Middle,
};
XYZ y = null;
for (int i = 0; i < data.Count; i++)
{
y = XYZ.BasisY * (i + 0.5) * tableGridHeight;
var datarow = data[i];
var floorTypeName = datarow.GetType().GetProperty("TypeName").GetValue(datarow).ToString();
FilledRegionType wallfilledRegionType = null;
foreach (var filledRegionType in filledRegionTypes)
{
if (floorTypeName.Contains(filledRegionType.Name))
{
wallfilledRegionType = filledRegionType as FilledRegionType;
break;
}
}
CurveLoop cl = new CurveLoop();
var cenP = XYZ.BasisX * tableGridWidth + y;
var lefttop = cenP - tableGridWidth * XYZ.BasisX / 2 + tableGridHeight * XYZ.BasisY * 0.4;
var leftbottom = cenP - tableGridWidth * XYZ.BasisX / 2 - tableGridHeight * XYZ.BasisY * 0.4;
var righttop = cenP + tableGridWidth * XYZ.BasisX / 2 + tableGridHeight * XYZ.BasisY * 0.4;
var rightbottom = cenP + tableGridWidth * XYZ.BasisX / 2 - tableGridHeight * XYZ.BasisY * 0.4;
Line l1 = Line.CreateBound(leftbottom, lefttop);
Line l2 = Line.CreateBound(lefttop, righttop);
Line l3 = Line.CreateBound(righttop, rightbottom);
Line l4 = Line.CreateBound(rightbottom, leftbottom);
cl.Append(l1);
cl.Append(l2);
cl.Append(l3);
cl.Append(l4);
List<CurveLoop> l = new List<CurveLoop>();
l.Add(cl);
if (wallfilledRegionType != null)
{
FilledRegion.Create(doc, wallfilledRegionType.Id, newLegend.Id, l);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 7 / 2) + y, floorTypeName, opts);
}
}
y += XYZ.BasisY * (tableGridHeight + headGridHeight) / 2;
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth) + y, "图例", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 7 / 2) + y, "图例说明", opts);
}
}
}

View File

@@ -16,7 +16,7 @@ namespace RookieStation.Drawing.ExecuteCmds
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdCreateLightLegend : IExternalCommand
internal class CreateLightLegend : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
@@ -25,17 +25,18 @@ namespace RookieStation.Drawing.ExecuteCmds
if (doc.ActiveView.ViewType == ViewType.DrawingSheet)
{
var portRefer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter<Viewport>(), "请选择参考的视口确定比例");
var location = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择左下角点放置图例");
var viewport = doc.GetElement(portRefer) as Viewport;
var viewPlan = doc.GetElement(viewport.ViewId);
if (!(viewPlan is ViewPlan))
{
TaskDialog.Show("温馨提示", "请选择平面视图的视口");
return Result.Failed;
}
try
{
var portRefer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter<Viewport>(), "请选择参考的视口以确定比例");
var location = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择左下角点放置图例");
var viewport = doc.GetElement(portRefer) as Viewport;
var viewPlan = doc.GetElement(viewport.ViewId);
if (!(viewPlan is ViewPlan))
{
TaskDialog.Show("温馨提示", "请选择平面视图的视口");
return Result.Failed;
}
doc.InvokeGroup(tg =>
{
var viewScale = viewport.get_Parameter(BuiltInParameter.VIEW_SCALE).AsInteger();
@@ -46,8 +47,8 @@ namespace RookieStation.Drawing.ExecuteCmds
});
doc.Invoke(ts =>
{
var items = GetLightData(doc);
CreateLightLegend(doc, GetLightData(doc), legend, viewScale);
var items = GetData(doc);
CreateLegend(doc, items, legend);
});
doc.Invoke(ts =>
{
@@ -68,29 +69,30 @@ namespace RookieStation.Drawing.ExecuteCmds
return Result.Succeeded;
}
private List<LegendItem> GetLightData(Document doc)
private List<LightingDevices> GetData(Document doc)
{
var lights = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_LightingFixtures).Cast<FamilyInstance>().Where(s => s.Symbol.FamilyName.Contains("灯"));
var lightFamilyGroup = lights.GroupBy(g => g.Symbol.FamilyName);//按族分组
List<LegendItem> items = new List<LegendItem>();
List<LightingDevices> items = new List<LightingDevices>();
//常规注释
var lightAnnotationSymboltypes = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).OfCategory(BuiltInCategory.OST_GenericAnnotation).Cast<FamilySymbol>().Where(s => s.Name.Contains("灯"));
foreach (var g1 in lightFamilyGroup)
{
var lightSymbolGroup = g1.ToList().GroupBy(f => f.Name).Reverse();//同一族按类型分组
foreach (var g2 in lightSymbolGroup)
{
var instance = g2.ElementAt(0);
//var wattage = instance.Symbol.get_Parameter(BuiltInParameter.FBX_LIGHT_WATTAGE).AsValueString();
var mark = instance.Symbol.get_Parameter(BuiltInParameter.WINDOW_TYPE_ID).AsString();
var annotation = instance.Symbol.get_Parameter(BuiltInParameter.ALL_MODEL_MODEL).AsString();
var comment = annotation == null ? $"{instance.Symbol.FamilyName}" : $"{instance.Symbol.FamilyName},{annotation}";
var annotation = instance.Symbol.GetParameters("物料说明").FirstOrDefault().AsString();
var comment = annotation == null ? $"{instance.Symbol.FamilyName}" : $"{annotation}";
var planeLegendTypes = from type in lightAnnotationSymboltypes
where type.Name.Contains(instance.Symbol.FamilyName) && type.Name.Contains("平面")
select type;
LegendItem item = new LegendItem
LightingDevices item = new LightingDevices
{
PlaneLegendType = planeLegendTypes.FirstOrDefault(),
Description = comment,
@@ -104,34 +106,27 @@ namespace RookieStation.Drawing.ExecuteCmds
return items;
}
private void CreateLightLegend(Document doc, List<LegendItem> items, View newLegend, int viewScale)
private void CreateLegend(Document doc, List<LightingDevices> items, View newLegend)
{
TextNoteType textNoteType = new FilteredElementCollector(doc).OfClass(typeof(TextNoteType)).Where(x => x.Name.Contains(UserConstant.FontName)).FirstOrDefault() as TextNoteType;
if (textNoteType == null)
{
textNoteType = new FilteredElementCollector(doc).OfClass(typeof(TextNoteType)).Cast<TextNoteType>().FirstOrDefault().Duplicate(UserConstant.FontName) as TextNoteType;
textNoteType.get_Parameter(BuiltInParameter.TEXT_SIZE).SetValueString("2.5");
textNoteType.get_Parameter(BuiltInParameter.TEXT_WIDTH_SCALE).SetValueString("0.8");
}
TextNoteType textNoteType = RsRevitUtils.GetOrNewTextNoteType(doc, UserConstant.TextSymbolName);
double fontSize = textNoteType.get_Parameter(BuiltInParameter.TEXT_SIZE).AsDouble();
double actualTextHeight = fontSize * 1.6;
double tableGridHeight = actualTextHeight * viewScale * 2;//图例网格高度
double tableGridHeight = actualTextHeight * newLegend.Scale * 2;//图例网格高度
var opts = new TextNoteOptions(textNoteType.Id)
{
HorizontalAlignment = HorizontalTextAlignment.Center,
VerticalAlignment = VerticalTextAlignment.Middle,
};
double[] widths = new double[5] { tableGridHeight * 2, tableGridHeight * 2, tableGridHeight * 6, tableGridHeight * 2, tableGridHeight * 2 };
RsRevitUtils.CreateTable(doc, newLegend, items.Count + 1, 5, tableGridHeight, widths);
double[] widths = new double[4] { tableGridHeight * 2, tableGridHeight * 2, tableGridHeight * 6, tableGridHeight * 2 };
RsRevitUtils.CreateTable(doc, newLegend, items.Count + 1, 4, tableGridHeight, widths);
var y = XYZ.BasisY * (items.Count + 0.5) * tableGridHeight;
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * tableGridHeight + y, "图例", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridHeight * 3) + y, "编号", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridHeight * 7) + y, "说明", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridHeight * 11) + y, "色温", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridHeight * 13) + y, "数量", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridHeight * 11) + y, "数量", opts);
for (int i = items.Count - 1; i >= 0; i--)
{
LegendItem item = items[i];
LightingDevices item = items[i];
y = XYZ.BasisY * (i + 0.5) * tableGridHeight;
if (item.PlaneLegendType != null)
{
@@ -145,15 +140,11 @@ namespace RookieStation.Drawing.ExecuteCmds
{
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridHeight * 7) + y, item.Description, opts);
}
if (!string.IsNullOrEmpty(item.ColorTemperature))
{
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridHeight * 11) + y, item.ColorTemperature, opts);
}
if (!string.IsNullOrEmpty(item.Count.ToString()))
{
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridHeight * 13) + y, $"{item.Count}个", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridHeight * 11) + y, $"{item.Count}个", opts);
}
}
}

View File

@@ -15,7 +15,7 @@ namespace RookieStation.Drawing.ExecuteCmds
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdCreateMainMaterialsTable : IExternalCommand
internal class CreateMainMaterialsTable : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{

View File

@@ -0,0 +1,157 @@
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.UI.Selection;
using RookieStation.Extension;
using RookieStation.ProjectConfig;
using RookieStation.Utils;
using Autodesk.Revit.DB.Architecture;
using RookieStation.Drawing.Models;
using System.Windows.Controls;
using System.Data;
using OfficeOpenXml.Style;
namespace RookieStation.Drawing.ExecuteCmds
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CreatePlaneGraphLegend : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
if (uidoc.ActiveView.ViewType == ViewType.DrawingSheet)
{
try
{
var portRefer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter<Viewport>(), "请选择参考的视口以确定比例");
var location = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择左下角点放置图例");
var viewport = doc.GetElement(portRefer) as Viewport;
var viewPlan = doc.GetElement(viewport.ViewId);
if (!(viewPlan is ViewPlan))
{
TaskDialog.Show("温馨提示", "请选择平面视图的视口");
return Result.Failed;
}
doc.InvokeGroup(tg =>
{
var viewScale = viewport.get_Parameter(BuiltInParameter.VIEW_SCALE).AsInteger();
View legend = null;
doc.Invoke(ts =>
{
legend = RsRevitUtils.CreateNewLegend(doc, "平面图例", viewScale);
});
doc.Invoke(ts =>
{
TextNoteType textNoteType = RsRevitUtils.GetOrNewTextNoteType(doc, UserConstant.TextSymbolName);
CreateLegend(doc, legend);
});
doc.Invoke(ts =>
{
RsRevitUtils.SetLegendLocation(doc, legend, location);
});
}, "创建平面图例");
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
}
}
else
{
TaskDialog.Show("温馨提示", "请在图纸视图下使用该命令");
return Result.Failed;
}
return Result.Succeeded;
}
/// <summary>
/// 获取数据
/// </summary>
/// <param name="doc"></param>
/// <returns></returns>
private List<string> GetData(Document doc)
{
var shelves = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_Furniture).Cast<FamilyInstance>().Where(s => s.Symbol.FamilyName.Contains("货架"));
var rooms = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).Cast<Room>();
double area = 0.0;
int orders = 0;
foreach (var room in rooms)
{
area += RsRevitUtils.ConvertSquareFeetToSquareMetre(room.get_Parameter(BuiltInParameter.ROOM_AREA).AsDouble());
}
var shelfGroup = shelves.GroupBy(g => g.Name);
List<string> statistics = new List<string>();
foreach (var group in shelfGroup)
{
//分组的实例
var instance = group.ElementAt(0);
//当前分组货架的长度
var l = instance.Symbol.GetParameters("长度").FirstOrDefault().AsValueString();
orders = group.Count() * Convert.ToInt16(l) / 1000 * 80;
}
statistics.Add(UserConstant.Orders.ToString());
statistics.Add(orders.ToString());
statistics.Add(Convert.ToInt16(area).ToString());
return statistics;
}
private void CreateLegend(Document doc, View newLegend)
{
//DataTable dt = new DataTable();
//dt.Columns.Add("设计单量");
//dt.Columns.Add("日均单量");
//dt.Columns.Add("场地面积");
//DataRow dr = dt.NewRow();
TextNoteType textNoteType = RsRevitUtils.GetOrNewTextNoteType(doc, UserConstant.TextSymbolName);
double fontSize = textNoteType.get_Parameter(BuiltInParameter.TEXT_SIZE).AsDouble();
double tableCellHeight = fontSize * newLegend.Scale * 2;//图例网格高度
double tableCellWidth = tableCellHeight * 4;//图例网格长度
CurveArray curveArray = new CurveArray();
for (int i = 2; i >= 0; i--)//水平线
{
Curve line;
if (i > 0 && i < 2)
{
line = Line.CreateBound(XYZ.Zero, XYZ.BasisX * tableCellWidth * 3).CreateOffset(tableCellHeight * i, -XYZ.BasisZ);
}
else
{
line = Line.CreateBound(XYZ.Zero, XYZ.BasisX * tableCellWidth * 3).CreateOffset(tableCellHeight * i, -XYZ.BasisZ);
}
curveArray.Append(line);
}
for (int i = 0; i < 4; i++)//垂直线
{
Curve line = Line.CreateBound(XYZ.Zero, XYZ.BasisY * 2 * tableCellHeight).CreateOffset(tableCellWidth * i, XYZ.BasisZ);
curveArray.Append(line);
}
var curves = doc.Create.NewDetailCurveArray(newLegend, curveArray);
var opts = new TextNoteOptions(textNoteType.Id)
{
VerticalAlignment = VerticalTextAlignment.Middle,
HorizontalAlignment = HorizontalTextAlignment.Center
};
var y = XYZ.BasisY * tableCellHeight * 1.5;
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * tableCellWidth * 0.5 + y, "设计单量", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableCellWidth * 1.5) + y, "日均单量", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableCellWidth * 2.5) + y, "场地面积", opts);
var li = GetData(doc);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableCellWidth * 0.5) + XYZ.BasisY * tableCellHeight * 0.5, li[0], opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableCellWidth * 1.5) + XYZ.BasisY * tableCellHeight * 0.5, li[1], opts);
var area = TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableCellWidth * 2.5) + XYZ.BasisY * tableCellHeight * 0.5, li[2] + "m2".ToString(), opts);
FormattedText formattedText = new FormattedText(area.Text);
TextRange range = new TextRange(area.Text.Length - 2, 1);
formattedText.SetSuperscriptStatus(range, true);
area.SetFormattedText(formattedText);
}
}
}

View File

@@ -15,7 +15,7 @@ namespace RookieStation.Drawing.ExecuteCmds
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdCreateSocketLegend : IExternalCommand
internal class CreateSocketLegend : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
@@ -24,17 +24,18 @@ namespace RookieStation.Drawing.ExecuteCmds
if (uidoc.ActiveView.ViewType == ViewType.DrawingSheet)
{
var portRefer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter<Viewport>(), "请选择参考的视口确定比例尺");
var location = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择左下角点放置图例");
var viewport = doc.GetElement(portRefer) as Viewport;
var viewPlan = doc.GetElement(viewport.ViewId);
if (!(viewPlan is ViewPlan))
{
TaskDialog.Show("温馨提示", "请选择平面视图的视口");
return Result.Failed;
}
try
{
var portRefer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter<Viewport>(), "请选择参考的视口以确定比例");
var location = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择左下角点放置图例");
var viewport = doc.GetElement(portRefer) as Viewport;
var viewPlan = doc.GetElement(viewport.ViewId);
if (!(viewPlan is ViewPlan))
{
TaskDialog.Show("温馨提示", "请选择平面视图的视口");
return Result.Failed;
}
doc.InvokeGroup(tg =>
{
var viewScale = viewport.get_Parameter(BuiltInParameter.VIEW_SCALE).AsInteger();
@@ -45,8 +46,8 @@ namespace RookieStation.Drawing.ExecuteCmds
});
doc.Invoke(ts =>
{
var items = GetSocketData(doc);
CreateSocketLegend(doc, GetSocketData(doc), legend, viewScale);
var items = GetData(doc);
CreateLegend(doc, items, legend);
});
doc.Invoke(ts =>
{
@@ -67,7 +68,7 @@ namespace RookieStation.Drawing.ExecuteCmds
return Result.Succeeded;
}
private List<LegendItem> GetSocketData(Document doc)
private List<LightingDevices> GetData(Document doc)
{
ElementCategoryFilter filter1 = new ElementCategoryFilter(BuiltInCategory.OST_CommunicationDevices);
ElementCategoryFilter filter2 = new ElementCategoryFilter(BuiltInCategory.OST_ElectricalFixtures);
@@ -76,7 +77,7 @@ namespace RookieStation.Drawing.ExecuteCmds
var socketAnnotationSymboltypes = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).OfCategory(BuiltInCategory.OST_GenericAnnotation).Cast<FamilySymbol>().Where(s => s.Name.Contains("插座"));
var socketFamilyGroup = sockets.GroupBy(g => g.Symbol.FamilyName);//按族分组
List<LegendItem> items = new List<LegendItem>();
List<LightingDevices> items = new List<LightingDevices>();
foreach (var g1 in socketFamilyGroup)
{
@@ -89,12 +90,11 @@ namespace RookieStation.Drawing.ExecuteCmds
where type.Name.Contains(familyName) && type.Name.Contains("平面")
select type;
LegendItem item = new LegendItem
LightingDevices item = new LightingDevices
{
PlaneLegendType = planeLegendTypes.FirstOrDefault(),
Description = familyName.Split(' ').FirstOrDefault(),
Count = g2.Count(),
Position = "现场定高"
};
items.Add(item);
}
@@ -102,34 +102,27 @@ namespace RookieStation.Drawing.ExecuteCmds
return items;
}
private void CreateSocketLegend(Document doc, List<LegendItem> items, View newLegend, int viewScale)
private void CreateLegend(Document doc, List<LightingDevices> items, View newLegend)
{
TextNoteType textNoteType = new FilteredElementCollector(doc).OfClass(typeof(TextNoteType)).Where(x => x.Name.Contains(UserConstant.FontName)).FirstOrDefault() as TextNoteType;
if (textNoteType == null)
{
textNoteType = new FilteredElementCollector(doc).OfClass(typeof(TextNoteType)).Cast<TextNoteType>().FirstOrDefault().Duplicate(UserConstant.FontName) as TextNoteType;
textNoteType.get_Parameter(BuiltInParameter.TEXT_SIZE).SetValueString("2.5");
textNoteType.get_Parameter(BuiltInParameter.TEXT_WIDTH_SCALE).SetValueString("0.8");
}
TextNoteType textNoteType = RsRevitUtils.GetOrNewTextNoteType(doc, UserConstant.TextSymbolName);
double fontSize = textNoteType.get_Parameter(BuiltInParameter.TEXT_SIZE).AsDouble();
double actualTextHeight = fontSize * 1.6;
double tableGridHeight = actualTextHeight * viewScale * 2;//图例网格高度
double tableGridHeight = actualTextHeight * newLegend.Scale * 2;//图例网格高度
double tableGridWidth = tableGridHeight * 2;
var opts = new TextNoteOptions(textNoteType.Id)
{
HorizontalAlignment = HorizontalTextAlignment.Center,
VerticalAlignment = VerticalTextAlignment.Middle,
};
double[] widths = new double[4] { tableGridWidth, tableGridWidth, tableGridWidth, tableGridWidth };
RsRevitUtils.CreateTable(doc, newLegend, items.Count + 1, 4, tableGridHeight, widths);
double[] widths = new double[3] { tableGridWidth, tableGridWidth, tableGridWidth };
RsRevitUtils.CreateTable(doc, newLegend, items.Count + 1, 3, tableGridHeight, widths);
var y = XYZ.BasisY * (items.Count + 0.5) * tableGridHeight;
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * tableGridHeight + y, "图例", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridHeight * 3) + y, "说明", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridHeight * 5) + y, "定位", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridHeight * 7) + y, "数量", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridHeight * 5) + y, "数量", opts);
for (int i = items.Count - 1; i >= 0; i--)
{
LegendItem item = items[i];
LightingDevices item = items[i];
y = XYZ.BasisY * (i + 0.5) * tableGridHeight;
//TextNote.Create(doc, newLegend.Id, new XYZ(tableGridWidth * 0.5, (items.Count + 0.5) * tableGridHeight, 0), "图例", opts);
if (item.PlaneLegendType != null)
@@ -140,12 +133,8 @@ namespace RookieStation.Drawing.ExecuteCmds
{
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridHeight * 3) + y, item.Description, opts);
}
if (item.Position != null)
{
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridHeight * 5) + y, item.Position, opts);
}
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridHeight * 7) + y, $"{item.Count}个", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridHeight * 5) + y, $"{item.Count}个", opts);
}
}
}

View File

@@ -15,7 +15,7 @@ namespace RookieStation.Drawing.ExecuteCmds
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdCreateSwitchLegend : IExternalCommand
internal class CreateSwitchLegend : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
@@ -24,17 +24,18 @@ namespace RookieStation.Drawing.ExecuteCmds
if (uidoc.ActiveView.ViewType == ViewType.DrawingSheet)
{
var portRefer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter<Viewport>(), "请选择参考的视口确定比例尺");
var location = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择左下角点放置图例");
var viewport = doc.GetElement(portRefer) as Viewport;
var viewPlan = doc.GetElement(viewport.ViewId);
if (!(viewPlan is ViewPlan))
{
TaskDialog.Show("温馨提示", "请选择平面视图的视口");
return Result.Failed;
}
try
{
var portRefer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter<Viewport>(), "请选择参考的视口以确定比例");
var location = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择左下角点放置图例");
var viewport = doc.GetElement(portRefer) as Viewport;
var viewPlan = doc.GetElement(viewport.ViewId);
if (!(viewPlan is ViewPlan))
{
TaskDialog.Show("温馨提示", "请选择平面视图的视口");
return Result.Failed;
}
doc.InvokeGroup(tg =>
{
var viewScale = viewport.get_Parameter(BuiltInParameter.VIEW_SCALE).AsInteger();
@@ -45,8 +46,8 @@ namespace RookieStation.Drawing.ExecuteCmds
});
doc.Invoke(ts =>
{
var items = GetSwitchData(doc);
CreateSwitchLegend(doc, GetSwitchData(doc), legend, viewScale);
var items = GetData(doc);
CreateLegend(doc, GetData(doc), legend);
});
doc.Invoke(ts =>
{
@@ -66,12 +67,12 @@ namespace RookieStation.Drawing.ExecuteCmds
return Result.Succeeded;
}
private List<LegendItem> GetSwitchData(Document doc)
private List<LightingDevices> GetData(Document doc)
{
var switchs = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_LightingDevices).Cast<FamilyInstance>().Where(s => s.Symbol.FamilyName.Contains("开关"));
var socketFamilyGroup = switchs.GroupBy(g => g.Symbol.FamilyName).Reverse();//按族分组
List<LegendItem> items = new List<LegendItem>();
List<LightingDevices> items = new List<LightingDevices>();
foreach (var g1 in socketFamilyGroup)
{
@@ -87,7 +88,7 @@ namespace RookieStation.Drawing.ExecuteCmds
var elevationLegendTypes = from type in switchAnnotationSymboltypes
where type.Name.Contains(symbolName) && type.Name.Contains("立面")
select type;
LegendItem item = new LegendItem
LightingDevices item = new LightingDevices
{
PlaneLegendType = planeLegendTypes.FirstOrDefault(),
Description = symbolName,
@@ -100,50 +101,40 @@ namespace RookieStation.Drawing.ExecuteCmds
return items; ;
}
private void CreateSwitchLegend(Document doc, List<LegendItem> items, View newLegend, int viewScale)
private void CreateLegend(Document doc, List<LightingDevices> items, View newLegend)
{
TextNoteType textNoteType = new FilteredElementCollector(doc).OfClass(typeof(TextNoteType)).Where(x => x.Name.Contains(UserConstant.FontName)).FirstOrDefault() as TextNoteType;
if (textNoteType == null)
{
textNoteType = new FilteredElementCollector(doc).OfClass(typeof(TextNoteType)).Cast<TextNoteType>().FirstOrDefault().Duplicate(UserConstant.FontName) as TextNoteType;
textNoteType.get_Parameter(BuiltInParameter.TEXT_SIZE).SetValueString("2.5");
textNoteType.get_Parameter(BuiltInParameter.TEXT_WIDTH_SCALE).SetValueString("0.8");
}
TextNoteType textNoteType = RsRevitUtils.GetOrNewTextNoteType(doc, UserConstant.TextSymbolName);
double fontSize = textNoteType.get_Parameter(BuiltInParameter.TEXT_SIZE).AsDouble();
double actualTextHeight = fontSize * 1.6;
double tableGridHeight = actualTextHeight * viewScale * 2;//图例网格高度
double tableGridHeight = actualTextHeight * newLegend.Scale * 2;//图例网格高度
double tableGridWidth = tableGridHeight * 2;
var opts = new TextNoteOptions(textNoteType.Id)
{
HorizontalAlignment = HorizontalTextAlignment.Center,
VerticalAlignment = VerticalTextAlignment.Middle,
};
double[] widths = new double[4] { tableGridWidth, tableGridWidth, tableGridWidth, tableGridWidth };
RsRevitUtils.CreateTable(doc, newLegend, items.Count + 1, 4, tableGridHeight, widths);
double[] widths = new double[3] { tableGridWidth, tableGridWidth, tableGridWidth };
RsRevitUtils.CreateTable(doc, newLegend, items.Count + 1, 3, tableGridHeight, widths);
var y = XYZ.BasisY * (items.Count + 0.5) * tableGridHeight;
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth / 2) + y, "图例", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 3 / 2) + y, "说明", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 5 / 2) + y, "立面图例", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 7 / 2) + y, "数量", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 5 / 2) + y, "数量", opts);
for (int i = items.Count - 1; i >= 0; i--)
{
LegendItem item = items[i];
LightingDevices item = items[i];
y = XYZ.BasisY * (i + 0.5) * tableGridHeight;
if (item.PlaneLegendType != null)
{
doc.Create.NewFamilyInstance(XYZ.BasisX * (tableGridWidth / 2) + y, item.PlaneLegendType, newLegend);
}
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 3 / 2) + y, item.Description, opts);
if (item.ElevationLegend != null)
{
doc.Create.NewFamilyInstance(XYZ.BasisX * (tableGridWidth * 5 / 2) + y, item.ElevationLegend, newLegend);
}
if (item.Count != 0)
{
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 7 / 2) + y, $"{item.Count}个", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 5 / 2) + y, $"{item.Count}个", opts);
}
}
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 5.5) + y, "注面板底边距地H:1300mm", opts);
//TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 5.5) + y, "注面板底边距地H:1300mm", opts);
}
}
}

View File

@@ -14,7 +14,7 @@ namespace RookieStation.Drawing.ExecuteCmds
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdCreateViewPlanAnnotation : IExternalCommand
internal class CreateViewPlanAnnotation : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{

View File

@@ -15,7 +15,7 @@ namespace RookieStation.Drawing.ExecuteCmds
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdCreateViewSectionAnnotation : IExternalCommand
internal class CreateViewSectionAnnotation : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{

View File

@@ -0,0 +1,231 @@
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RookieStation.ProjectConfig;
using RookieStation.Utils;
using Autodesk.Revit.UI.Selection;
using RookieStation.Extension;
namespace RookieStation.Drawing.ExecuteCmds
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CreateWallLegend : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
if (uidoc.ActiveView.ViewType == ViewType.DrawingSheet)
{
try
{
var portRefer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter<Viewport>(), "请选择参考的视口以确定比例");
var location = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择左下角点放置图例");
var viewport = doc.GetElement(portRefer) as Viewport;
var viewPlan = doc.GetElement(viewport.ViewId);
if (!(viewPlan is ViewPlan))
{
TaskDialog.Show("温馨提示", "请选择平面视图的视口");
return Result.Failed;
}
doc.InvokeGroup(tg =>
{
var viewScale = viewport.get_Parameter(BuiltInParameter.VIEW_SCALE).AsInteger();
View legend = null;
doc.Invoke(ts =>
{
legend = RsRevitUtils.CreateNewLegend(doc, "墙体图例", viewScale);
});
doc.Invoke(ts =>
{
var items = GetData(doc);
CreateLegend(doc, items, legend);
});
doc.Invoke(ts =>
{
RsRevitUtils.SetLegendLocation(doc, legend, location);
});
}, "创建墙体图例");
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
}
}
else
{
TaskDialog.Show("温馨提示", "请打开图纸视图");
return Result.Failed;
}
return Result.Succeeded;
}
/// <summary>
/// 获取数据
/// </summary>
/// <param name="doc"></param>
/// <returns></returns>
private List<dynamic> GetData(Document doc)
{
var walls = new FilteredElementCollector(doc).OfClass(typeof(Wall)).OfCategory(BuiltInCategory.OST_Walls);
var filledRegionTypes = new FilteredElementCollector(doc).OfClass(typeof(FilledRegionType)).OfCategory(BuiltInCategory.OST_DetailComponents);
//按族分组
var wallTypeGroups = walls.GroupBy(g => g.Name);
var data = new List<dynamic>();
//遍历每个族的分组
foreach (var instanceByFamily in wallTypeGroups)
{
var wall = instanceByFamily.ElementAt(0) as Wall;
var wallType = wall.WallType;
string finalName = string.Empty;
if (wallType.Name.Contains("-"))
finalName = wallType.Name.Substring(0, wallType.Name.IndexOf("-"));
if (finalName == "")
{
finalName = wallType.Name;
}
for (int i = 0; i < filledRegionTypes.Count(); i++)
{
var t = filledRegionTypes.ElementAt(i) as FilledRegionType;
//通过名称,类型,把不需要的墙体过滤掉
if (wallType.Name.Contains("墙饰面") || wallType.Name.Contains("踢脚线") || wallType.Kind != WallKind.Basic)
{
continue;
}
if (wallType.Name.Contains(t.Name))
{
dynamic datarow = new { FilledRegionTypeName = t.Name, WallTypeName = finalName };
data.Add(datarow);
break;
}
//如果没找到填充图案则新建
if (i == filledRegionTypes.Count() - 1)
{
GetOrNewWallTypeFilledRegionType(doc, wallType, finalName, t);
//填充图案默认为空
}
}
}
return data;
}
private static void GetOrNewWallTypeFilledRegionType(Document doc, WallType wallType, string finalName, FilledRegionType t)
{
FilledRegionType newFilledRegionType = null;
newFilledRegionType = t.Duplicate(finalName) as FilledRegionType;
try
{
var compound = wallType.GetCompoundStructure();
var mId = compound.GetMaterialId(compound.GetFirstCoreLayerIndex());
var material = doc.GetElement(mId) as Material;
//根据墙体核心层材质,赋予填充图案
if (material.CutForegroundPatternId != ElementId.InvalidElementId)
{
newFilledRegionType.ForegroundPatternId = material.CutForegroundPatternId;
newFilledRegionType.ForegroundPatternColor = material.CutForegroundPatternColor;
newFilledRegionType.BackgroundPatternId = material.CutForegroundPatternId;
newFilledRegionType.BackgroundPatternColor = material.CutForegroundPatternColor;
}
else if (material.CutBackgroundPatternId != ElementId.InvalidElementId)
{
newFilledRegionType.ForegroundPatternId = material.CutBackgroundPatternId;
newFilledRegionType.ForegroundPatternColor = material.CutBackgroundPatternColor;
newFilledRegionType.BackgroundPatternId = material.CutBackgroundPatternId;
newFilledRegionType.BackgroundPatternColor = material.CutBackgroundPatternColor;
}
else if (material.SurfaceForegroundPatternId != ElementId.InvalidElementId)
{
newFilledRegionType.ForegroundPatternId = material.SurfaceForegroundPatternId;
newFilledRegionType.ForegroundPatternColor = material.SurfaceForegroundPatternColor;
newFilledRegionType.BackgroundPatternId = material.SurfaceForegroundPatternId;
newFilledRegionType.BackgroundPatternColor = material.SurfaceForegroundPatternColor;
}
else if (material.SurfaceBackgroundPatternId != ElementId.InvalidElementId)
{
newFilledRegionType.ForegroundPatternId = material.SurfaceBackgroundPatternId;
newFilledRegionType.ForegroundPatternColor = material.SurfaceBackgroundPatternColor;
newFilledRegionType.BackgroundPatternId = material.SurfaceBackgroundPatternId;
newFilledRegionType.BackgroundPatternColor = material.SurfaceBackgroundPatternColor;
}
else
{
newFilledRegionType.ForegroundPatternId = ElementId.InvalidElementId;
newFilledRegionType.BackgroundPatternId = ElementId.InvalidElementId;
}
}
catch (Exception)
{
newFilledRegionType.ForegroundPatternId = ElementId.InvalidElementId;
newFilledRegionType.BackgroundPatternId = ElementId.InvalidElementId;
}
}
private void CreateLegend(Document doc, List<dynamic> data, View newLegend)
{
TextNoteType textNoteType = RsRevitUtils.GetOrNewTextNoteType(doc, UserConstant.TextSymbolName);
double fontSize = textNoteType.get_Parameter(BuiltInParameter.TEXT_SIZE).AsDouble();
double tableGridHeight = fontSize * newLegend.Scale * 2;//图例网格高度
double tableGridWidth = tableGridHeight * 2.5;
double[] widths = new double[2] { tableGridWidth * 2, tableGridWidth * 3 };
RsRevitUtils.CreateTable(doc, newLegend, data.Count + 1, 2, tableGridHeight, widths);
var filledRegionTypes = new FilteredElementCollector(doc).OfClass(typeof(FilledRegionType)).OfCategory(BuiltInCategory.OST_DetailComponents);
var opts = new TextNoteOptions(textNoteType.Id)
{
HorizontalAlignment = HorizontalTextAlignment.Center,
VerticalAlignment = VerticalTextAlignment.Middle,
};
XYZ y = null;
for (int i = 0; i < data.Count; i++)
{
y = XYZ.BasisY * (i + 0.5) * tableGridHeight;
var datarow = data[i];
var wallTypeName = datarow.GetType().GetProperty("WallTypeName").GetValue(datarow).ToString();
FilledRegionType wallfilledRegionType = null;
foreach (var filledRegionType in filledRegionTypes)
{
if (wallTypeName.Contains(filledRegionType.Name))
{
wallfilledRegionType = filledRegionType as FilledRegionType;
break;
}
}
CurveLoop cl = new CurveLoop();
var cenP = XYZ.BasisX * tableGridWidth + y;
var lefttop = cenP - tableGridWidth * XYZ.BasisX / 2 + tableGridHeight * XYZ.BasisY * 0.4;
var leftbottom = cenP - tableGridWidth * XYZ.BasisX / 2 - tableGridHeight * XYZ.BasisY * 0.4;
var righttop = cenP + tableGridWidth * XYZ.BasisX / 2 + tableGridHeight * XYZ.BasisY * 0.4;
var rightbottom = cenP + tableGridWidth * XYZ.BasisX / 2 - tableGridHeight * XYZ.BasisY * 0.4;
Line l1 = Line.CreateBound(leftbottom, lefttop);
Line l2 = Line.CreateBound(lefttop, righttop);
Line l3 = Line.CreateBound(righttop, rightbottom);
Line l4 = Line.CreateBound(rightbottom, leftbottom);
cl.Append(l1);
cl.Append(l2);
cl.Append(l3);
cl.Append(l4);
List<CurveLoop> l = new List<CurveLoop>();
l.Add(cl);
if (wallfilledRegionType != null)
{
FilledRegion.Create(doc, wallfilledRegionType.Id, newLegend.Id, l);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 7 / 2) + y, wallTypeName, opts);
}
}
y += XYZ.BasisY * tableGridHeight;
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth) + y, "图例", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 7 / 2) + y, "图例说明", opts);
}
}
}

View File

@@ -14,7 +14,7 @@ namespace RookieStation.Drawing.ExecuteCmds
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdCreateWires : IExternalCommand
internal class CreateWires : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{

View File

@@ -14,7 +14,7 @@ namespace RookieStation.Drawing.ExecuteCmds
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdUnifyViewportOnViewSheet : IExternalCommand
internal class UnifyViewportOnViewSheet : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{

View File

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace RookieStation.Drawing.Models
{
internal class LegendItem
internal class LightingDevices
{
/// <summary>
/// 标记、编号

View File

@@ -17,7 +17,7 @@ namespace RookieStation.Finishes.ExecuteCmds
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
[Obsolete("已替换", true)]
internal class CmdFloorFinishes : IExternalCommand
internal class FloorFinishes : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{

View File

@@ -19,7 +19,7 @@ namespace RookieStation.Properties {
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -190,6 +190,16 @@ namespace RookieStation.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap PlaneLegend {
get {
object obj = ResourceManager.GetObject("PlaneLegend", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>

View File

@@ -157,6 +157,9 @@
<data name="MainMaterials" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\MainMaterials.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="PlaneLegend" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\PlaneLegend.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Reception" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\reception.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

View File

@@ -94,24 +94,27 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="CommonTools\ExecuteCmd\CmdChangeBackgroundColor.cs" />
<Compile Include="CommonTools\ExecuteCmd\CmdDecryptFamily.cs" />
<Compile Include="CommonTools\ExecuteCmd\CmdEncryptFamily.cs" />
<Compile Include="CommonTools\ExecuteCmd\ChangeBackgroundColor.cs" />
<Compile Include="CommonTools\ExecuteCmd\DecryptFamily.cs" />
<Compile Include="CommonTools\ExecuteCmd\EncryptFamily.cs" />
<Compile Include="CommonTools\ViewModels\EncryptOrDecryptFamily.cs" />
<Compile Include="CommonTools\ViewModels\ProgressMonitorControl.cs" />
<Compile Include="CommonTools\Views\ProgressMonitorView.xaml.cs">
<DependentUpon>ProgressMonitorView.xaml</DependentUpon>
</Compile>
<Compile Include="Drawing\ExecuteCmds\CmdCreateLightLegend.cs" />
<Compile Include="Drawing\ExecuteCmds\CmdCreateShelvesLegend.cs" />
<Compile Include="Drawing\ExecuteCmds\CmdBatchExportDwg.cs" />
<Compile Include="Drawing\ExecuteCmds\CmdCreateMainMaterialsTable.cs" />
<Compile Include="Drawing\ExecuteCmds\CmdCreateSocketLegend.cs" />
<Compile Include="Drawing\ExecuteCmds\CmdCreateSwitchLegend.cs" />
<Compile Include="Drawing\ExecuteCmds\CmdCreateViewSectionAnnotation.cs" />
<Compile Include="Drawing\ExecuteCmds\CmdCreateWires.cs" />
<Compile Include="Drawing\ExecuteCmds\CmdUnifyViewportOnViewSheet.cs" />
<Compile Include="Drawing\Models\LegendItem.cs" />
<Compile Include="Drawing\ExecuteCmds\CreateGroundPavingLegend.cs" />
<Compile Include="Drawing\ExecuteCmds\CreateLightLegend.cs" />
<Compile Include="Drawing\ExecuteCmds\CreateFurnitureLegend.cs" />
<Compile Include="Drawing\ExecuteCmds\BatchExportDwg.cs" />
<Compile Include="Drawing\ExecuteCmds\CreateMainMaterialsTable.cs" />
<Compile Include="Drawing\ExecuteCmds\CreatePlaneGraphLegend.cs" />
<Compile Include="Drawing\ExecuteCmds\CreateSocketLegend.cs" />
<Compile Include="Drawing\ExecuteCmds\CreateSwitchLegend.cs" />
<Compile Include="Drawing\ExecuteCmds\CreateViewSectionAnnotation.cs" />
<Compile Include="Drawing\ExecuteCmds\CreateWallLegend.cs" />
<Compile Include="Drawing\ExecuteCmds\CreateWires.cs" />
<Compile Include="Drawing\ExecuteCmds\UnifyViewportOnViewSheet.cs" />
<Compile Include="Drawing\Models\LightingDevices.cs" />
<Compile Include="Drawing\Models\MaterialItem.cs" />
<Compile Include="Drawing\Models\ShelfStatistic.cs" />
<Compile Include="Drawing\Views\WpfLegendCreator.xaml.cs">
@@ -132,12 +135,12 @@
<Compile Include="Statistics\ExecuteCmds\CmdExportBudgetInventory.cs" />
<Compile Include="Statistics\Models\SubItem.cs" />
<Compile Include="Utils\AssemblyLoader.cs" />
<Compile Include="Drawing\ExecuteCmds\CmdCreateViewPlanAnnotation.cs" />
<Compile Include="Drawing\ExecuteCmds\CreateViewPlanAnnotation.cs" />
<Compile Include="Utils\DocumentExtension.cs" />
<Compile Include="Utils\EnumItemsSource.cs" />
<Compile Include="Utils\ExcelUtils.cs" />
<Compile Include="Utils\KeyPress.cs" />
<Compile Include="CommonTools\ExecuteCmd\CmdUseFamilyPane.cs" />
<Compile Include="CommonTools\ExecuteCmd\UseFamilyPane.cs" />
<Compile Include="ParcelAreaModule\ExecuteCmds\CmdPlaceShelves.cs" />
<Compile Include="Utils\CommonUtils.cs" />
<Compile Include="Utils\Log.cs" />
@@ -146,7 +149,7 @@
<Compile Include="ParcelAreaModule\ExecuteCmds\CmdPlaceExitGate.cs" />
<Compile Include="Utils\RsFamilyLoadOption.cs" />
<Compile Include="Utils\RsRevitUtils.cs" />
<Compile Include="Finishes\ExecuteCmds\CmdFloorFinishes.cs" />
<Compile Include="Finishes\ExecuteCmds\FloorFinishes.cs" />
<Compile Include="ParcelAreaModule\ExecuteCmds\CmdPlaceLamps.cs" />
<Compile Include="ParcelAreaModule\Models\Enum.cs" />
<Compile Include="Utils\ProjectConfigUtil.cs" />
@@ -208,6 +211,12 @@
<None Include="RsLibrary\FamilyLibrary\其他\雨棚.rfa">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="RsLibrary\FamilyLibrary\出入口\收检台-右.rfa">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="RsLibrary\FamilyLibrary\出入口\收检台-左.rfa">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="RsLibrary\FamilyLibrary\出入口\智能翼闸.rfa">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
@@ -295,12 +304,6 @@
<None Include="RsLibrary\FamilyLibrary\出入口\三辊闸机.rfa">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="RsLibrary\FamilyLibrary\出入口\收检台-右.rfa">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="RsLibrary\FamilyLibrary\出入口\收检台-左.rfa">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="RsLibrary\FamilyLibrary\其他\吊线.rfa">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
@@ -464,39 +467,103 @@
<None Include="Resources\ShelfLegend.png" />
<None Include="Resources\SwitchLegend.png" />
<None Include="Resources\SocketLegend.png" />
<None Include="Resources\PlaneLegend.png" />
<Content Include="Resources\WallFinishes.png" />
<None Include="Resources\Wire.png" />
<Content Include="Resources\YTX.ico" />
<None Include="Resources\WorkSchedule.png" />
<None Include="Resources\视口.png" />
<Content Include="RsLibrary\MainMaterials\吊灯.png">
<Content Include="RsLibrary\MainMaterials\AP三开开关.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\明装射灯.png">
<Content Include="RsLibrary\MainMaterials\AP五孔插座.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\木饰面.png">
<Content Include="RsLibrary\MainMaterials\AP单开开关.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\桥架.png">
<Content Include="RsLibrary\MainMaterials\AP双开开关.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\AP弱电面板.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\T5支架灯.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\前台吊灯.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\塑胶地板.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\明装筒灯.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\木门.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\枫木免漆板.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\深灰色铝塑板.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\灰色乳胶漆.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\灰色地砖.png">
<Content Include="RsLibrary\MainMaterials\灰色地砖.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\白色乳胶漆.png">
<Content Include="RsLibrary\MainMaterials\灰色桥架.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\白色铝塑板.png">
<Content Include="RsLibrary\MainMaterials\烤漆玻璃.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\明装筒灯.png">
<Content Include="RsLibrary\MainMaterials\玻璃门.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\黑钛不锈钢(哑光).png">
<Content Include="RsLibrary\MainMaterials\电动卷闸门.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\白色乳胶漆.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\白色人造石.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\白色铝塑板.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\真石漆.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\矿棉板吊顶.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\纸面石膏板.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\芝麻灰花岗岩.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\蒙古黑花岗岩.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\轨道射灯.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\钢化玻璃.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\铝合金.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\铝方通.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\黑钛不锈钢.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\Texture\免费WiFi.png">

View File

@@ -101,30 +101,36 @@ namespace RookieStation.RibbonMenu
//出图面板
RibbonPanel drawingPanel = application.CreateRibbonPanel(TabName, DrawingPanelName);
CreatePushButton<CmdCreateMainMaterialsTable>(drawingPanel, "主材表", Properties.Resources.MainMaterials, DrawingSheetCmdEnabled);
CreatePushButton<CreateMainMaterialsTable>(drawingPanel, "主材表", Properties.Resources.MainMaterials, DrawingSheetCmdEnabled);
SplitButtonData splitButtonData = new SplitButtonData("创建图例", "创建图例");
var spb = drawingPanel.AddItem(splitButtonData) as SplitButton;
PushButtonData shelfButtonData = new PushButtonData("货架说明", "货架说明", AddInPath, typeof(CmdCreateShelvesLegend).FullName)
PushButtonData shelfButtonData = new PushButtonData("平面图例", "平面图例", AddInPath, typeof(CreatePlaneGraphLegend).FullName)
{
LargeImage = ConvertFromBitmap(Properties.Resources.PlaneLegend),
Image = ConvertFromBitmap(Properties.Resources.PlaneLegend),
AvailabilityClassName = DrawingSheetCmdEnabled
};
PushButtonData furnitureButtonData = new PushButtonData("家具图例", "家具图例", AddInPath, typeof(CreateFurnitureLegend).FullName)
{
LargeImage = ConvertFromBitmap(Properties.Resources.ShelfLegend),
Image = ConvertFromBitmap(Properties.Resources.ShelfLegend),
AvailabilityClassName = DrawingSheetCmdEnabled
};
PushButtonData lightButtonData = new PushButtonData("灯具说明", "灯具说明", AddInPath, typeof(CmdCreateLightLegend).FullName)
PushButtonData lightButtonData = new PushButtonData("灯具图例", "灯具图例", AddInPath, typeof(CreateLightLegend).FullName)
{
LargeImage = ConvertFromBitmap(Properties.Resources.LightLegend),
Image = ConvertFromBitmap(Properties.Resources.LightLegend),
AvailabilityClassName = DrawingSheetCmdEnabled
};
PushButtonData socketButtonData = new PushButtonData("插座说明", "插座说明", AddInPath, typeof(CmdCreateSocketLegend).FullName)
PushButtonData socketButtonData = new PushButtonData("插座图例", "插座图例", AddInPath, typeof(CreateSocketLegend).FullName)
{
LargeImage = ConvertFromBitmap(Properties.Resources.SocketLegend),
Image = ConvertFromBitmap(Properties.Resources.SocketLegend),
AvailabilityClassName = DrawingSheetCmdEnabled
};
PushButtonData switchButtonData = new PushButtonData("开关说明", "开关说明", AddInPath, typeof(CmdCreateSwitchLegend).FullName)
PushButtonData switchButtonData = new PushButtonData("开关图例", "开关图例", AddInPath, typeof(CreateSwitchLegend).FullName)
{
LargeImage = ConvertFromBitmap(Properties.Resources.SwitchLegend),
Image = ConvertFromBitmap(Properties.Resources.SwitchLegend),
@@ -135,19 +141,19 @@ namespace RookieStation.RibbonMenu
spb.AddPushButton(socketButtonData);
spb.AddPushButton(switchButtonData);
CreatePushButton<CmdCreateViewPlanAnnotation>(drawingPanel, "平面标注", Properties.Resources.ViewPlanDim, ViewPlanCmdEnabled);
CreatePushButton<CmdCreateViewSectionAnnotation>(drawingPanel, "立面标注", Properties.Resources.ViewSectionDim, ViewSectionCmdEnabled);
CreatePushButton<CmdCreateWires>(drawingPanel, "创建导线", Properties.Resources.Wire, ViewPlanCmdEnabled);
var UnifyViewportPBD = CreatePushButton<CmdUnifyViewportOnViewSheet>(drawingPanel, "统一视口", Properties.Resources.UnifyViewport, ViewPlanCmdEnabled);
UnifyViewportPBD.ToolTip = "请选择一个合适的楼层平面,该视口为模型和标注注释的范围为最大";
CreatePushButton<CmdBatchExportDwg>(drawingPanel, "批量导出DWG", Properties.Resources.ExportDWG, null);
CreatePushButton<CreateViewPlanAnnotation>(drawingPanel, "平面标注", Properties.Resources.ViewPlanDim, ViewPlanCmdEnabled);
CreatePushButton<CreateViewSectionAnnotation>(drawingPanel, "立面标注", Properties.Resources.ViewSectionDim, ViewSectionCmdEnabled);
CreatePushButton<CreateWires>(drawingPanel, "创建导线", Properties.Resources.Wire, ViewPlanCmdEnabled);
var UnifyViewportPBD = CreatePushButton<UnifyViewportOnViewSheet>(drawingPanel, "统一视口", Properties.Resources.UnifyViewport, ViewPlanCmdEnabled);
UnifyViewportPBD.ToolTip = "请选择一个合适的楼层平面,以该楼层平面视口范围作为图纸视口范围";
CreatePushButton<BatchExportDwg>(drawingPanel, "批量导出DWG", Properties.Resources.ExportDWG, null);
//通用面板
RibbonPanel commonToolsPanel = application.CreateRibbonPanel(TabName, CommonTools);
//CreatePushButton<CmdEncryptFamily>(commonToolsPanel, "加密族", Properties.Resources.Encrypt, null);
//CreatePushButton<CmdDecryptFamily>(commonToolsPanel, "解密族", Properties.Resources.Decrypt, null);
CreatePushButton<CmdUseFamilyPane>(commonToolsPanel, "族库浏览", Properties.Resources.FamilyLib, null);
CreatePushButton<CmdChangeBackgroundColor>(commonToolsPanel, "切换背景色", Properties.Resources.Background, null);
CreatePushButton<UseFamilyPane>(commonToolsPanel, "族库浏览", Properties.Resources.FamilyLib, null);
CreatePushButton<ChangeBackgroundColor>(commonToolsPanel, "切换背景色", Properties.Resources.Background, null);
RegisterDockPane(application);
return Result.Succeeded;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

View File

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -15,7 +15,10 @@ namespace RookieStation.ProjectConfig
private static string AddinPath = typeof(RsApp).Assembly.Location;
public static string AddinDirectory => System.IO.Path.GetDirectoryName(AddinPath);
public static string FontName = "体-2.5mm_0.8";
public static string TextSymbolName = "体-2.5mm_0.8";
public static string FontFamily = "黑体";
public static string FontSize = "2.5";
public static string WidthScale = "0.8";
#if (DEBUG)
//调试路径

View File

@@ -168,14 +168,14 @@ namespace RookieStation.Utils
return;
}
CurveArray curveArray = new CurveArray();
var width = 0.0;
var totalWidth = 0.0;
foreach (var w in gridwidths)
{
width += w;
totalWidth += w;
}
for (int i = 0; i <= rowcount; i++)//水平网格
{
Curve c = Line.CreateBound(XYZ.Zero, XYZ.BasisX * width).CreateOffset(gridheight * i, -XYZ.BasisZ);
Curve c = Line.CreateBound(XYZ.Zero, XYZ.BasisX * totalWidth).CreateOffset(gridheight * i, -XYZ.BasisZ);
curveArray.Append(c);
}
Curve line = Line.CreateBound(XYZ.Zero, XYZ.BasisY * rowcount * gridheight);
@@ -188,6 +188,47 @@ namespace RookieStation.Utils
doc.Create.NewDetailCurveArray(legend, curveArray);
}
/// <summary>
/// 创建表格
/// </summary>
/// <param name="doc"></param>
/// <param name="legend">图例视图</param>
/// <param name="rowcount">行数(含标题行)</param>
/// <param name="columncount">列数</param>
/// <param name="gridheight">单元格高度</param>
/// <param name="gridwidths">各单元格对应的宽度</param>
public static void CreateTable(Document doc, View legend, int rowcount, int columncount, double headHeight, double gridheight, params double[] gridwidths)
{
if (columncount != gridwidths.Count())
{
System.Windows.Forms.MessageBox.Show("列数和提供的列宽数量不一致。");
return;
}
CurveArray curveArray = new CurveArray();
var totalWidth = 0.0;
foreach (var w in gridwidths)
{
totalWidth += w;
}
for (int i = 0; i <= rowcount - 1; i++)//水平网格
{
Curve c = Line.CreateBound(XYZ.Zero, XYZ.BasisX * totalWidth).CreateOffset(gridheight * i, -XYZ.BasisZ);
curveArray.Append(c);
}
//标题行
Curve line = Line.CreateBound(XYZ.Zero, XYZ.BasisX * totalWidth).CreateOffset(gridheight * (rowcount - 1) + headHeight, -XYZ.BasisZ);
curveArray.Append(line);
//列
line = Line.CreateBound(XYZ.Zero, XYZ.BasisY * ((rowcount - 1) * gridheight + headHeight));
curveArray.Append(line);
for (int i = 0; i < columncount; i++)//垂直网格
{
line = line.CreateOffset(gridwidths[i], XYZ.BasisZ);
curveArray.Append(line);
}
doc.Create.NewDetailCurveArray(legend, curveArray);
}
/// <summary>
/// 通过名称获取默认的墙类型完整厚度
/// </summary>
@@ -720,5 +761,78 @@ namespace RookieStation.Utils
}
return null;
}
/// <summary>
/// 获取或创建文字类型
/// </summary>
/// <param name="doc"></param>
/// <param name="textSymbolName">文字类型名称</param>
/// <param name="fontFamily"></param>
/// <param name="fontSize"></param>
/// <param name="widthScale"></param>
/// <returns></returns>
public static TextNoteType GetOrNewTextNoteType(Document doc, string textSymbolName)
{
TextNoteType textNoteType = new FilteredElementCollector(doc).OfClass(typeof(TextNoteType)).Where(x => x.Name.Contains(textSymbolName)).FirstOrDefault() as TextNoteType;
if (textNoteType == null)
{
textNoteType = new FilteredElementCollector(doc).OfClass(typeof(TextNoteType)).Cast<TextNoteType>().FirstOrDefault().Duplicate(textSymbolName) as TextNoteType;
textNoteType.get_Parameter(BuiltInParameter.TEXT_FONT).SetValueString(UserConstant.FontFamily);
textNoteType.get_Parameter(BuiltInParameter.TEXT_SIZE).SetValueString(UserConstant.FontSize);
textNoteType.get_Parameter(BuiltInParameter.TEXT_WIDTH_SCALE).SetValueString(UserConstant.WidthScale);
}
return textNoteType;
}
///// <summary>
///// 创建表格
///// </summary>
///// <param name="doc"></param>
///// <param name="newLegend">图例视图</param>
///// <param name="viewScale">图例比例</param>
///// <param name="textNoteType"></param>
///// <param name="rowCount"></param>
///// <param name="headRow"></param>
///// <param name="headHeight"></param>
//public static void CreateLegend(Document doc, View newLegend, int viewScale, TextNoteType textNoteType, int rowCount, List<string> headRow, double tableHeight)
//{
// double fontSize = textNoteType.get_Parameter(BuiltInParameter.TEXT_SIZE).AsDouble();
// double actualTextHeight = fontSize * 1.6;
// double tableCellHeight = actualTextHeight * viewScale * 1.2;//图例网格高度
// double tableCellWidth = tableCellHeight * 5;//图例网格长度
// double[] widths = new double[6] { tableCellHeight * 2, tableCellHeight * 2, tableCellHeight * 6, tableCellHeight * 2, tableCellHeight * 2, tableCellHeight * 2 };
// CurveArray curveArray = new CurveArray();
// for (int i = rowCount + 1; i >= 0; i--)//水平线
// {
// Curve line;
// if (i > 0 && i < statistics.Count)
// {
// line = Line.CreateBound(XYZ.Zero, XYZ.BasisX * tableCellWidth * 3).CreateOffset(tableCellHeight * i, -XYZ.BasisZ);
// }
// else
// {
// line = Line.CreateBound(XYZ.Zero, XYZ.BasisX * tableCellWidth * 6).CreateOffset(tableCellHeight * i, -XYZ.BasisZ);
// }
// curveArray.Append(line);
// }
// for (int i = 0; i < headRow.Count; i++)//垂直线
// {
// Curve line = Line.CreateBound(XYZ.Zero, XYZ.BasisY * (statistics.Count() + 1) * tableCellHeight).CreateOffset(tableCellWidth * i, XYZ.BasisZ);
// curveArray.Append(line);
// }
// var opts = new TextNoteOptions(textNoteType.Id)
// {
// VerticalAlignment = VerticalTextAlignment.Middle,
// HorizontalAlignment = HorizontalTextAlignment.Center
// };
// var y = XYZ.BasisY * tableCellHeight * (rowCount + 0.5);
// for (int i = 0; i < headRow.Count; i++)
// {
// TextNote.Create(doc, newLegend.Id, XYZ.BasisX * tableCellWidth * (i + 1) * 0.5 + y, headRow[i], opts);
// }
//}
}
}

File diff suppressed because it is too large Load Diff