This commit is contained in:
GG Z
2021-09-18 14:48:46 +08:00
parent 6a7254b9dd
commit 750058386d
36 changed files with 528 additions and 214 deletions

View File

@@ -25,6 +25,7 @@ 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))
@@ -49,7 +50,7 @@ namespace RookieStation.Drawing.ExecuteCmds
});
doc.Invoke(ts =>
{
RsRevitUtils.SetLegendLocation(doc, legend);
RsRevitUtils.SetLegendLocation(doc, legend, location);
});
}, "创建货架图例");
}
@@ -113,9 +114,9 @@ namespace RookieStation.Drawing.ExecuteCmds
}
double fontSize = textNoteType.get_Parameter(BuiltInParameter.TEXT_SIZE).AsDouble();
double actualTextHeight = fontSize * 1.6;
double tableGridHeight = actualTextHeight * viewScale * 1.2;//图例网格高度
double tableGridWidth = tableGridHeight * 5;//图例网格长度
double[] widths = new double[6] { tableGridHeight * 2, tableGridHeight * 2, tableGridHeight * 6, tableGridHeight * 2, tableGridHeight * 2, tableGridHeight * 2 };
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--)//水平线
@@ -123,39 +124,39 @@ namespace RookieStation.Drawing.ExecuteCmds
Curve line;
if (i > 0 && i < statistics.Count)
{
line = Line.CreateBound(XYZ.Zero, XYZ.BasisX * tableGridWidth * 3).CreateOffset(tableGridHeight * i, -XYZ.BasisZ);
line = Line.CreateBound(XYZ.Zero, XYZ.BasisX * tableCellWidth * 3).CreateOffset(tableCellHeight * i, -XYZ.BasisZ);
}
else
{
line = Line.CreateBound(XYZ.Zero, XYZ.BasisX * tableGridWidth * 6).CreateOffset(tableGridHeight * i, -XYZ.BasisZ);
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) * tableGridHeight).CreateOffset(tableGridWidth * i, XYZ.BasisZ);
Curve line = Line.CreateBound(XYZ.Zero, XYZ.BasisY * (statistics.Count() + 1) * tableCellHeight).CreateOffset(tableCellWidth * i, XYZ.BasisZ);
curveArray.Append(line);
}
var y = XYZ.BasisY * tableGridHeight * (statistics.Count + 0.5);
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 * tableGridWidth * 0.5 + y, "货架类型", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 1.5) + y, "数量", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 2.5) + y, "总延米", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 3.5) + y, "总承载单量", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 4.5) + y, "设计单量", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 5.5) + y, "场地面积", opts);
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 * tableGridHeight * (i + 0.5);
var yElevation = XYZ.BasisY * tableCellHeight * (i + 0.5);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * tableGridWidth * 0.5 + yElevation, statistics[i].ShelfType, opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 1.5) + yElevation, statistics[i].Count.ToString(), opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 2.5) + yElevation,
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);
}
//承载单量总和
@@ -164,11 +165,11 @@ namespace RookieStation.Drawing.ExecuteCmds
{
orders += statistics[i].CapacityOrders;
}
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (tableGridWidth * 3.5) + XYZ.BasisY * tableGridHeight * statistics.Count() / 2, orders.ToString(), opts);
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 * (tableGridWidth * 4.5) + XYZ.BasisY * tableGridHeight * statistics.Count() / 2, statistics.FirstOrDefault().DesignOrders.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 * (tableGridWidth * 5.5) + XYZ.BasisY * tableGridHeight * statistics.Count() / 2, statistics[0].GroundArea + "m2".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);