主材表功能

This commit is contained in:
GG Z
2021-08-05 17:45:27 +08:00
parent e1f6ba160d
commit 0a317446f7
35 changed files with 829 additions and 228 deletions

View File

@@ -0,0 +1,212 @@
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;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
View activeview = doc.ActiveView;
if (uidoc.ActiveView.ViewType == ViewType.DrawingSheet)
{
CurveArray curveArray = new CurveArray();
var tableLocation = uidoc.Selection.PickPoint(ObjectSnapTypes.Endpoints, "请选择布图区域左上角端点");
var sql = SQLiteUtil.GetInstance();
sql.CreateDb(UserConstant.DbFolder + "Inventory.db");
List<string[]> tableRow = sql.QueryTable("MainMaterials");
sql.CloseConncetion();
//FilteredElementCollector collectorAll = new FilteredElementCollector(doc);
//collectorAll.WherePasses(new LogicalOrFilter(new ElementIsElementTypeFilter(false), new ElementIsElementTypeFilter(true)));
var collectorAll = new FilteredElementCollector(doc);
ElementClassFilter instanceFilter = new ElementClassFilter(typeof(FamilyInstance));
ElementClassFilter hostobjectFilter = new ElementClassFilter(typeof(HostObject));
LogicalOrFilter orFilter = new LogicalOrFilter(instanceFilter, hostobjectFilter);
collectorAll.WherePasses(orFilter);
List<MaterialItem> materialItems = new List<MaterialItem>();
double similarity = 0.4;//相似度
for (int i = 0; i < tableRow.Count; i++)
{
var description = tableRow[i][1];
var position = tableRow[i][6];
bool isExist = false;
foreach (var ele in collectorAll)
{
string name = string.Empty;
FamilyInstance fi = ele as FamilyInstance;
if (fi != null)
{
name = fi.Symbol.FamilyName;
}
else
{
name = ele.Name;
if (name == "单喷灰色乳胶漆")
{
}
}
if (CommonUtils.levenshtein(description, name) > similarity || CommonUtils.levenshtein(position, name) > similarity)
{
isExist = true;
break;
}
}
if (isExist)
{
MaterialItem item = new MaterialItem()
{
Description = tableRow[i][1],
FireRating = tableRow[i][2],
Legend = $"{UserConstant.MainMaterialFolder}{tableRow[i][1]}.png",
Specifications = tableRow[i][4],
Pigment = tableRow[i][5],
Position = tableRow[i][6],
Remark = tableRow[i][7],
};
materialItems.Add(item);
}
}
var width = 346 / 304.8;
var height = 283 / 304.8;
var gridWidth = width / 7;
var gridHeight = height / (materialItems.Count + 1);//表头要加1
doc.InvokeGroup(tg =>
{
doc.Invoke(ts =>
{
for (int j = 0; j < 8; j++)
{
var colStart = new XYZ(tableLocation.X + j * gridWidth, tableLocation.Y, 0);
var colEnd = new XYZ(tableLocation.X + j * gridWidth, tableLocation.Y - height, 0);
Line colLine = Line.CreateBound(colStart, colEnd);
curveArray.Append(colLine);
}
TextNoteType textNoteType = new FilteredElementCollector(doc).OfClass(typeof(TextNoteType)).Where(x => x.Name.Contains("宋")).FirstOrDefault() as TextNoteType;
var opts = new TextNoteOptions(textNoteType.Id)
{
HorizontalAlignment = HorizontalTextAlignment.Center,
VerticalAlignment = VerticalTextAlignment.Middle
};
for (int i = 0; i <= materialItems.Count; i++)
{
var rowStart = new XYZ(tableLocation.X, tableLocation.Y - i * gridHeight, 0);
var rowEnd = new XYZ(tableLocation.X + width, tableLocation.Y - i * gridHeight, 0);
Line rowLine = Line.CreateBound(rowStart, rowEnd);
curveArray.Append(rowLine);
if (i == 0)//创建表头
{
TextNote.Create(doc,
doc.ActiveView.Id,
new XYZ(tableLocation.X + 0.5 * gridWidth, tableLocation.Y - (i + 0.5) * gridHeight, 0),
"材料名称\nDESCRIPTION",
opts);
TextNote.Create(doc,
doc.ActiveView.Id,
new XYZ(tableLocation.X + 1.5 * gridWidth, tableLocation.Y - (i + 0.5) * gridHeight, 0),
"防火等级\nFIRE RATING",
opts);
TextNote.Create(doc,
doc.ActiveView.Id,
new XYZ(tableLocation.X + 2.5 * gridWidth, tableLocation.Y - (i + 0.5) * gridHeight, 0),
"图例\nLEGEND",
opts);
TextNote.Create(doc,
doc.ActiveView.Id,
new XYZ(tableLocation.X + 3.5 * gridWidth, tableLocation.Y - (i + 0.5) * gridHeight, 0),
"规格\nSPECIFICATIONS",
opts);
TextNote.Create(doc,
doc.ActiveView.Id,
new XYZ(tableLocation.X + 4.5 * gridWidth, tableLocation.Y - (i + 0.5) * gridHeight, 0),
"颜色\nPIGMENT",
opts);
TextNote.Create(doc,
doc.ActiveView.Id,
new XYZ(tableLocation.X + 5.5 * gridWidth, tableLocation.Y - (i + 0.5) * gridHeight, 0),
"位置\nPOSITION",
opts);
TextNote.Create(doc,
doc.ActiveView.Id,
new XYZ(tableLocation.X + 6.5 * gridWidth, tableLocation.Y - (i + 0.5) * gridHeight, 0),
"备注\nREMARK",
opts);
continue;
}
var item = materialItems[i - 1];//从0开始i=0已运行并跳过此段
TextNote.Create(doc,
doc.ActiveView.Id,
new XYZ(tableLocation.X + 0.5 * gridWidth, tableLocation.Y - (i + 0.5) * gridHeight, 0),
item.Description,
opts);
TextNote.Create(doc,
doc.ActiveView.Id,
new XYZ(tableLocation.X + 1.5 * gridWidth, tableLocation.Y - (i + 0.5) * gridHeight, 0),
item.FireRating,
opts);
var it = ImageType.Create(doc, new ImageTypeOptions(item.Legend));
var ii = ImageInstance.Create(doc,
activeview,
it.Id,
new ImagePlacementOptions(new XYZ(tableLocation.X + 2.5 * gridWidth, tableLocation.Y - (i + 0.5) * gridHeight, 0),
BoxPlacement.Center));
doc.Regenerate();
ii.get_Parameter(BuiltInParameter.RASTER_SHEETHEIGHT).SetValueString("21");
ii.get_Parameter(BuiltInParameter.RASTER_SHEETWIDTH).SetValueString("21");
TextNote.Create(doc,
doc.ActiveView.Id,
new XYZ(tableLocation.X + 3.5 * gridWidth, tableLocation.Y - (i + 0.5) * gridHeight, 0),
item.Specifications,
opts);
TextNote.Create(doc,
doc.ActiveView.Id,
new XYZ(tableLocation.X + 4.5 * gridWidth, tableLocation.Y - (i + 0.5) * gridHeight, 0),
item.Pigment,
opts);
TextNote.Create(doc,
doc.ActiveView.Id,
new XYZ(tableLocation.X + 5.5 * gridWidth, tableLocation.Y - (i + 0.5) * gridHeight, 0),
item.Position,
opts);
TextNote.Create(doc,
doc.ActiveView.Id,
new XYZ(tableLocation.X + 6.5 * gridWidth, tableLocation.Y - (i + 0.5) * gridHeight, 0),
item.Remark,
opts);
}
doc.Create.NewDetailCurveArray(activeview, curveArray);
//ii.Width = 10;
//ii.Height = 10;
});
});
}
else
{
TaskDialog.Show("温馨提示", "请打开图纸视图");
return Result.Failed;
}
return Result.Succeeded;
}
}
}

View File

@@ -14,15 +14,12 @@ namespace RookieStation.Drawing.ExecuteCmds
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdAutoCreateLegend : IExternalCommand
internal class CmdCreateShelvesLegend : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
DocumentSet docset = uiapp.Application.Documents;
if (uidoc.ActiveView.ViewType == ViewType.DrawingSheet)
{
@@ -114,45 +111,57 @@ namespace RookieStation.Drawing.ExecuteCmds
TextNoteType textNoteType = new FilteredElementCollector(doc).OfClass(typeof(TextNoteType)).Where(x => x.Name.Contains("宋")).FirstOrDefault() as TextNoteType;
double fontSize = textNoteType.get_Parameter(BuiltInParameter.TEXT_SIZE).AsDouble();
double actualTextHeight = fontSize * 1.6;
double legendTextHeight = actualTextHeight * scale * 1.2;
double legendTextLength = legendTextHeight * 5;
double legendGridHeight = actualTextHeight * scale * 1.2;//图例网格高度
double legendGridLength = legendGridHeight * 5;//图例网格长度
doc.Invoke(ts =>
{
CurveArray curveArray = new CurveArray();
for (int i = 0; i < statistics.Count() + 2; i++)
for (int i = 0; i < statistics.Count() + 2; i++)//水平线
{
Curve line = Line.CreateBound(XYZ.Zero, XYZ.BasisX * legendTextLength * 6).CreateOffset(legendTextHeight * i, -XYZ.BasisZ);
curveArray.Append(line);
}
for (int i = 0; i < 7; i++)
{
Curve line = Line.CreateBound(XYZ.Zero, XYZ.BasisY * (statistics.Count() + 1) * legendTextHeight).CreateOffset(legendTextLength * i, XYZ.BasisZ);
if (i == 0 || i == statistics.Count() || i == statistics.Count() + 1)
{
Curve line = Line.CreateBound(XYZ.Zero, XYZ.BasisX * legendGridLength * 6).CreateOffset(legendGridHeight * i, -XYZ.BasisZ);
curveArray.Append(line);
}
else
{
Curve line = Line.CreateBound(XYZ.Zero, XYZ.BasisX * legendGridLength * 3).CreateOffset(legendGridHeight * i, -XYZ.BasisZ);
curveArray.Append(line);
}
}
for (int i = 0; i < 7; i++)//垂直线
{
Curve line = Line.CreateBound(XYZ.Zero, XYZ.BasisY * (statistics.Count() + 1) * legendGridHeight).CreateOffset(legendGridLength * i, XYZ.BasisZ);
curveArray.Append(line);
}
var opts = new TextNoteOptions(textNoteType.Id);
for (int i = 0; i <= statistics.Count(); i++)
{
var yElevation = XYZ.BasisY * legendTextHeight * (i + 1);
var opts = new TextNoteOptions(textNoteType.Id);
var yElevation = XYZ.BasisY * legendGridHeight * (i + 1);
if (i < statistics.Count())
{
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * 0.5 + yElevation, statistics[i].ShelfType, opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendTextLength + 0.5) + yElevation, statistics[i].Count.ToString(), opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendTextLength * 2 + 0.5) + yElevation,
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendGridLength + 0.5) + yElevation, statistics[i].Count.ToString(), opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendGridLength * 2 + 0.5) + yElevation,
statistics[i].LinearMetre.ToString(), opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendTextLength * 3 + 0.5) + yElevation, statistics[i].CapacityOrders.ToString(), opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendTextLength * 4 + 0.5) + yElevation, statistics[i].DesignOrders.ToString(), opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendTextLength * 5 + 0.5) + yElevation, statistics[i].GroundArea.ToString(), opts);
}
else
{
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * 0.5 + yElevation, "货架类型", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendTextLength + 0.5) + yElevation, "数量", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendTextLength * 2 + 0.5) + yElevation, "总延米", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendTextLength * 3 + 0.5) + yElevation, "总承载单量", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendTextLength * 4 + 0.5) + yElevation, "设计单量", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendTextLength * 5 + 0.5) + yElevation, "场地面积", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendGridLength + 0.5) + yElevation, "数量", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendGridLength * 2 + 0.5) + yElevation, "总延米", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendGridLength * 3 + 0.5) + yElevation, "总承载单量", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendGridLength * 4 + 0.5) + yElevation, "设计单量", opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendGridLength * 5 + 0.5) + yElevation, "场地面积", opts);
}
}
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendGridLength * 3 + 0.5) + XYZ.BasisY * legendGridHeight * (statistics.Count() + 1) / 2, statistics[0].CapacityOrders.ToString(), opts);
TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendGridLength * 4 + 0.5) + XYZ.BasisY * legendGridHeight * (statistics.Count() + 1) / 2, statistics[0].DesignOrders.ToString(), opts);
TextNote tn = TextNote.Create(doc, newLegend.Id, XYZ.BasisX * (legendGridLength * 5 + 0.5) + XYZ.BasisY * legendGridHeight * (statistics.Count() + 1) / 2, statistics[0].GroundArea + "m2".ToString(), opts);
FormattedText formattedText = new FormattedText(tn.Text);
TextRange range = new TextRange(tn.Text.Length - 2, 1);
formattedText.SetSuperscriptStatus(range, true);
tn.SetFormattedText(formattedText);
doc.Create.NewDetailCurveArray(newLegend, curveArray);
});
@@ -162,11 +171,14 @@ namespace RookieStation.Drawing.ExecuteCmds
//XYZ p = new XYZ(6.0335, 1, 0) * 0.03606;
//ViewSheet.Create(doc, newLegend.Id);
var viewport = Viewport.Create(doc, doc.ActiveView.Id, newLegend.Id, XYZ.Zero);
//viewport.SetBoxCenter();
XYZ p = XYZ.BasisX * 0.21757 + XYZ.BasisY * viewport.GetBoxOutline().GetDiagonalLength() / 2;
viewport.SetBoxCenter(viewport.GetBoxOutline().MaximumPoint + new XYZ(0.0313999575806783, 0.0199667276438911, 0));
double l = viewport.GetBoxOutline().MaximumPoint.X - viewport.GetBoxOutline().MinimumPoint.X;
double w = viewport.GetBoxOutline().MaximumPoint.Y - viewport.GetBoxOutline().MinimumPoint.Y;
XYZ c = new XYZ(l / 2 + 7 / 304.8, w / 2 + 7 / 304.8, 0);
viewport.SetBoxCenter(c);
var ele = new FilteredElementCollector(doc).OfClass(typeof(ElementType)).WhereElementIsElementType().FirstOrDefault(x => x.Name.Contains("无"));
viewport.ChangeTypeId(ele.Id);
viewport.ChangeTypeId(ele.Id);//选择视口-无标题
});
return newLegend;

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RookieStation.Drawing.Models
{
internal class MaterialItem
{
public string Description { get; set; }
public string FireRating { get; set; }
public string Legend { get; set; }
public string Specifications { get; set; }
public string Pigment { get; set; }
public string Position { get; set; }
public string Remark { get; set; }
public string RevitType { get; set; }
}
}

View File

@@ -166,9 +166,9 @@ namespace RookieStation.Finishes.ExecuteCmds
PanelType panelType = null;
MullionType mullionType = null;
string cutainSystemTypeName = $"铺贴{length} x {width}mm";
string cutainSystemTypeName = $"地砖铺贴{length}x{width}mm";
string panelTypeName = "铺贴";
string mullionTypeName = $"{gap} x {thickness}mm";
string mullionTypeName = $"{gap}x{thickness}mm";
doc.Invoke(ts =>
{

View File

@@ -93,7 +93,10 @@ namespace RookieStation.ParcelAreaModule.ExecuteCmds
double parallelReferlineOffest = vm.ParallelReferlineOffest / 304.8;
//参考线起点垂直于参考线的偏移量
double verticalReferlineOffest = vm.VerticalReferlineOffest / 304.8;
shelfFamily = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "货架\\仓储货架.rfa");
doc.Invoke(ts =>
{
shelfFamily = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "货架\\仓储货架.rfa");
}, "加载仓储货架族");
for (int i = 0; i < shelves.Count; i++)
{
@@ -552,7 +555,14 @@ namespace RookieStation.ParcelAreaModule.ExecuteCmds
case NumOfGroup.Single:
for (int j = 0; j < cardInstances.Count(); j++)
{
cardInstances[j].GetParameters("货架号").FirstOrDefault().Set($"{currentnum}");
if (currentnum < 10)
{
cardInstances[j].GetParameters("货架号").FirstOrDefault().Set($"0{currentnum}");
}
else
{
cardInstances[j].GetParameters("货架号").FirstOrDefault().Set($"{currentnum}");
}
}
currentnum += 1;
@@ -566,7 +576,18 @@ namespace RookieStation.ParcelAreaModule.ExecuteCmds
}
for (int j = 0; j < cardInstances.Count(); j++)
{
cardInstances[j].GetParameters("货架号").FirstOrDefault().Set($"{currentnum}~{currentnum + 1}");
if (currentnum < 9)
{
cardInstances[j].GetParameters("货架号").FirstOrDefault().Set($"0{currentnum}~0{currentnum + 1}");
}
else if (currentnum == 9)
{
cardInstances[j].GetParameters("货架号").FirstOrDefault().Set($"0{currentnum}~{currentnum + 1}");
}
else
{
cardInstances[j].GetParameters("货架号").FirstOrDefault().Set($"{currentnum}~{currentnum + 1}");
}
}
//最后一个需要加上组合数作为下一列的开始
if (i == shelfInstances.Count - 1)
@@ -583,7 +604,14 @@ namespace RookieStation.ParcelAreaModule.ExecuteCmds
}
for (int j = 0; j < cardInstances.Count(); j++)
{
cardInstances[j].GetParameters("货架号").FirstOrDefault().Set($"{currentnum}~{currentnum + 2}");
if (currentnum < 9)
{
cardInstances[j].GetParameters("货架号").FirstOrDefault().Set($"0{currentnum}~0{currentnum + 2}");
}
else
{
cardInstances[j].GetParameters("货架号").FirstOrDefault().Set($"{currentnum}~{currentnum + 2}");
}
}
//最后一个需要加上组合数作为下一列的开始
if (i == shelfInstances.Count - 1)

View File

@@ -170,6 +170,16 @@ namespace RookieStation.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap MainMaterials {
get {
object obj = ResourceManager.GetObject("MainMaterials", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>

View File

@@ -151,6 +151,9 @@
<data name="LogoExtrusion" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\logoextrusion.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<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="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.

Before

Width:  |  Height:  |  Size: 691 B

After

Width:  |  Height:  |  Size: 611 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 B

View File

@@ -100,9 +100,11 @@
<Compile Include="CommonTools\Views\ProgressMonitorView.xaml.cs">
<DependentUpon>ProgressMonitorView.xaml</DependentUpon>
</Compile>
<Compile Include="Drawing\ExecuteCmds\CmdAutoCreateLegend.cs" />
<Compile Include="Drawing\ExecuteCmds\CmdCreateShelvesLegend.cs" />
<Compile Include="Drawing\ExecuteCmds\CmdBatchExportDwg.cs" />
<Compile Include="Drawing\ExecuteCmds\CmdCreateMainMaterialsTable.cs" />
<Compile Include="Drawing\ExecuteCmds\CmdCreateViewSectionAnnotation.cs" />
<Compile Include="Drawing\Models\MaterialItem.cs" />
<Compile Include="Drawing\Models\ShelfStatistic.cs" />
<Compile Include="Drawing\Views\WpfLegendCreator.xaml.cs">
<DependentUpon>WpfLegendCreator.xaml</DependentUpon>
@@ -425,17 +427,48 @@
<None Include="Resources\Shipping.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ExportDWG.png" />
<None Include="Resources\AutoShelfLegend.gif" />
<None Include="Resources\Legend.png" />
<None Include="Resources\Decrypt.png" />
<None Include="Resources\Encrypt.png" />
<None Include="Resources\ExportDwg.png" />
<Content Include="Resources\LogoExtrusion.png" />
<None Include="Resources\ViewPlanDim.png" />
<None Include="Resources\ViewSectionDim.png" />
<None Include="Resources\MainMaterials.png" />
<Content Include="Resources\WallFinishes.png" />
<Content Include="Resources\YTX.ico" />
<None Include="Resources\WorkSchedule.png" />
<Content Include="RsLibrary\MainMaterials\吊灯.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\明装射灯.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\木饰面.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\桥架.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\灰色乳胶漆.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\灰色地砖.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\白色乳胶漆.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\白色铝塑板.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\明装筒灯.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\MainMaterials\黑钛不锈钢(哑光).png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="RsLibrary\Texture\免费WiFi.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

View File

@@ -87,7 +87,6 @@ namespace RookieStation.RibbonMenu
////var exitBtn = (PushButton)gateItemsStacked[1];
//寄件区布置
CreatePushButton<CmdPlaceShelves>(packAreaPanel, "货架布置", Properties.Resources.Shelf, ViewPlanCmdEnabled);
CreatePushButton<CmdArrangeShelfCards>(packAreaPanel, "货架端牌", Properties.Resources.ShelfCard, ViewPlanCmdEnabled);
CreatePushButton<CmdPlaceLamps>(packAreaPanel, "灯具布置", Properties.Resources.Lamp, ViewPlanCmdEnabled);
@@ -101,17 +100,16 @@ namespace RookieStation.RibbonMenu
CreatePushButton<CmdExportBudgetInventory>(statisticsPanel, "工程量导出", Properties.Resources.WorkSchedule, null);
//出图面板
RibbonPanel drawingPanel = application.CreateRibbonPanel(TabName, DrawingPanelName);
CreatePushButton<CmdAutoCreateLegend>(drawingPanel, "货架图例说明", Properties.Resources.Legend, DrawingSheetCmdEnabled);
CreatePushButton<CmdCreateMainMaterialsTable>(drawingPanel, "主材表", Properties.Resources.MainMaterials, DrawingSheetCmdEnabled);
CreatePushButton<CmdCreateShelvesLegend>(drawingPanel, "货架图例说明", Properties.Resources.Legend, DrawingSheetCmdEnabled);
CreatePushButton<CmdCreateViewPlanAnnotation>(drawingPanel, "平面标注", Properties.Resources.ViewPlanDim, ViewPlanCmdEnabled);
CreatePushButton<CmdCreateViewSectionAnnotation>(drawingPanel, "立面标注", Properties.Resources.ViewSectionDim, ViewSectionCmdEnabled);
//CreatePushButton<CmdCreateViewPlanAnnotation>(drawingPanel, "平面标注", Properties.Resources.ViewPlanDim, ViewPlanCmdEnabled);
//CreatePushButton<CmdCreateViewSectionAnnotation>(drawingPanel, "立面标注", Properties.Resources.ViewSectionDim, null);
//CreatePushButton<CmdBatchExportDwg>(drawingPanel, "导出dwg图纸", Properties.Resources.ExportDWG, null);
CreatePushButton<CmdBatchExportDwg>(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<CmdEncryptFamily>(commonToolsPanel, "加密族", Properties.Resources.Encrypt, null);
//CreatePushButton<CmdDecryptFamily>(commonToolsPanel, "解密族", Properties.Resources.Decrypt, null);
CreatePushButton<CmdUseFamilyPane>(commonToolsPanel, "族库浏览", Properties.Resources.FamilyLib, null);
RegisterDockPane(application);
return Result.Succeeded;

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -15,6 +15,7 @@ using System.Data.SQLite;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
@@ -33,14 +34,6 @@ namespace RookieStation.Statistics.ExecuteCmds
Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
Document doc = uidoc.Document;
DocumentSet docset = uiapp.Application.Documents;
//实例化SQL辅助类
var sql = SQLiteUtil.GetInstance();
sql.CreateDb(UserConstant.DbFolder + "Inventory.db");
//var tablecontent = sql.QueryTable("菜鸟驿站工程预算清单");
//string[] values = new string[] { "", "装饰装修项目", "Null", "测试", "测试描述", "m2", "Area" };
//sql.InsertValue("'CaiNiaoInventory'", values);
SaveFileDialog sfd = new SaveFileDialog()
{
Filter = "Excel文件|*.xlsx",
@@ -55,8 +48,15 @@ namespace RookieStation.Statistics.ExecuteCmds
{
return Result.Cancelled;
}
var strs = sql.QueryTable("CaiNiaoInventory");
var items = GetQuantity(doc, strs);
//实例化SQL辅助类
var sql = SQLiteUtil.GetInstance();
sql.CreateDb(UserConstant.DbFolder + "Inventory.db");
//var tablecontent = sql.QueryTable("菜鸟驿站工程预算清单");
//string[] values = new string[] { "", "装饰装修项目", "Null", "测试", "测试描述", "m2", "Area" };
//sql.InsertValue("'CaiNiaoInventory'", values);
var tableRows = sql.QueryTable("CaiNiaoInventory");
var items = GetQuantity(doc, tableRows);
sql.CloseConncetion();
var itemGroups = items.GroupBy(i => i.RootCategory).Select(s => s.Where(q => q.Quantity != 0.0));//分成三组
@@ -85,7 +85,7 @@ namespace RookieStation.Statistics.ExecuteCmds
range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
range.Style.Font.Size = 10;
range.Style.Fill.PatternType = ExcelFillStyle.Solid;
range.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.DimGray);
range.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.DarkGray);
range.Style.Border.BorderAround(ExcelBorderStyle.Thin);
}
@@ -104,8 +104,9 @@ namespace RookieStation.Statistics.ExecuteCmds
{
sheet.Cells[row, 1].Value = NumberToChar(j + 1);
sheet.Cells[row, 2].Value = subGroupys.ElementAt(j).Key;
sheet.Cells[row, 3].Value = $"=SUM({sheet.Cells[subStartRow + 1, 9].Address}:{sheet.Cells[subStartRow + subGroupys.ElementAt(j).Count(), 9].Address})";
sheet.Cells[row, 3].Formula = $"SUM({sheet.Cells[subStartRow + 1, 9].Address}:{sheet.Cells[subStartRow + subGroupys.ElementAt(j).Count(), 9].Address})";
sheet.Cells[row, 3].Style.Numberformat.Format = "#,##0.00";
sheet.Cells[row, 3].Style.Font.Color.SetColor(System.Drawing.Color.Red);
using (var range = sheet.Cells[row, 1, row, 10])
{
range.Style.Font.Name = "宋体";
@@ -132,9 +133,17 @@ namespace RookieStation.Statistics.ExecuteCmds
sheet.Cells[row, 4].Value = subitem.Unit;
sheet.Cells[row, 5].Value = subitem.Quantity;
sheet.Cells[row, 5].Style.Font.Color.SetColor(System.Drawing.Color.Red);
sheet.Cells[row, 5].Style.Numberformat.Format = "0.00";
sheet.Cells[row, 8].Formula = $"=SUM({sheet.Cells[row, 6].Address}:{sheet.Cells[row, 6].Address})";
sheet.Cells[row, 9].Formula = $"={sheet.Cells[row, 5].Address}*{sheet.Cells[row, 8].Address}";
if (subitem.Unit == "套" || subitem.Unit == "个")
{
sheet.Cells[row, 5].Style.Numberformat.Format = "0";
}
else
{
sheet.Cells[row, 5].Style.Numberformat.Format = "0.00";
}
sheet.Cells[row, 8].Formula = $"SUM({sheet.Cells[row, 6].Address}:{sheet.Cells[row, 6].Address})";
sheet.Cells[row, 9].Formula = $"{sheet.Cells[row, 5].Address}*{sheet.Cells[row, 8].Address}";
sheet.Cells[row, 10].Value = subitem.Remarks;
using (var range = sheet.Cells[row, 1, row, 10])
{
range.Style.Font.Name = "宋体";
@@ -181,8 +190,9 @@ namespace RookieStation.Statistics.ExecuteCmds
sheet.Cells[row, 1, row, 8].Merge = true;
sheet.Cells[row, 1].Value = rootItem.FirstOrDefault().RootCategory + "合计";
sheet.Cells[row, 9].Formula = $"=SUM({sheet.Cells[startRow, 9].Address}:{sheet.Cells[row - 1, 9].Address})";
rows.Add(row);//记录汇总行号
sheet.Cells[row, 9].Formula = $"SUM({sheet.Cells[startRow, 9].Address}:{sheet.Cells[row - 1, 9].Address})";
sheet.Cells[row, 9].Style.Numberformat.Format = "#,##0.00";
rows.Add(row);//记录汇总的行号
using (var range = sheet.Cells[row, 1, row, 10])
{
range.Style.Font.Name = "宋体";
@@ -203,7 +213,20 @@ namespace RookieStation.Statistics.ExecuteCmds
sheet.Cells[row, 1, row, 8].Merge = true;
sheet.Cells[row, 1].Value = "预算总价(一+二+三)";
sheet.Cells[row, 9].Formula = $"=SUM({sheet.Cells[rows[0], 9].Address}+{sheet.Cells[rows[1], 9].Address}+{sheet.Cells[rows[2], 9].Address})";
string formula = $"SUM({sheet.Cells[rows[0], 9].Address}";
sheet.Cells[2, 4].Formula = $"{sheet.Cells[row, 9].Address}";//表头预算总价合计
for (int i = 1; i < rows.Count; i++)
{
formula += "+" + sheet.Cells[rows[1], 9].Address;
if (i == rows.Count - 1)
{
formula += "+" + sheet.Cells[rows[1], 9].Address + ")";
}
}
sheet.Cells[row, 9].Formula = formula;
sheet.Cells[row, 9].Style.Numberformat.Format = "#,##0.00";
using (var range = sheet.Cells[row, 1, row, 10])
{
range.Style.Font.Name = "宋体";
@@ -245,7 +268,7 @@ namespace RookieStation.Statistics.ExecuteCmds
/// <summary>
/// 数字转汉字
/// </summary>
/// <param name="n"></param>
/// <param item.ItemName="n"></param>
/// <returns></returns>
private string NumberToChineseDigital(int n)
{
@@ -271,7 +294,7 @@ namespace RookieStation.Statistics.ExecuteCmds
/// <summary>
/// 数字转字母
/// </summary>
/// <param name="n"></param>
/// <param item.ItemName="n"></param>
/// <returns></returns>
private string NumberToChar(int n)
{
@@ -306,17 +329,24 @@ namespace RookieStation.Statistics.ExecuteCmds
/// <summary>
/// 获取量
/// </summary>
/// <param name="doc"></param>
/// <param name="li"></param>
/// <param item.ItemName="doc"></param>
/// <param item.ItemName="li"></param>
/// <returns></returns>
private static List<SubItem> GetQuantity(Document doc, List<string[]> li)
{
double similarity = 0.3;
double similarity = 0.8;
List<SubItem> items = new List<SubItem>();
for (int i = 0; i < li.Count; i++)
{
string revitType = li[i].ElementAt(6).ToLower();
string name = li[i].ElementAt(3);
SubItem item = new SubItem()
{
RootCategory = li[i][1],
SubCategory = li[i][2],
ItemName = li[i][3],
Description = li[i][4],
Unit = li[i][5],
};
string revitType = li[i][6].ToLower();
if (revitType == "wall")
{
double wallTotalArea = 0.0;
@@ -325,26 +355,21 @@ namespace RookieStation.Statistics.ExecuteCmds
foreach (var wall in walls)
{
if (levenshtein(name, wall.Name) > similarity)
if (CommonUtils.levenshtein(item.ItemName, wall.Name) > similarity)
{
if (name.Contains("踢脚线"))
if (item.Unit == "m" && wall.Name.Contains("踢脚线"))
{
item.Remarks += wall.Name + "\r\n";
wallTotalLength += wall.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsDouble();
}
else
else if (item.Unit == "m2" && !wall.Name.Contains("踢脚线"))
{
item.Remarks += wall.Name + "\r\n";
wallTotalArea += wall.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();
}
}
}
SubItem item = new SubItem()
{
RootCategory = li[i].ElementAt(1),
SubCategory = li[i].ElementAt(2),
ItemName = li[i].ElementAt(3),
Description = li[i].ElementAt(4),
Unit = li[i].ElementAt(5),
};
if (wallTotalArea == 0.0)
{
item.Quantity = RsRevitUtils.ConvertFeetToMetre(wallTotalLength);
@@ -362,45 +387,33 @@ namespace RookieStation.Statistics.ExecuteCmds
foreach (var floor in floors)
{
//if (name.Intersect(floor.Name).Count() >= 3)
//if (item.ItemName.Intersect(floor.Name).Count() >= 3)
//{
//}
if (levenshtein(name, floor.Name) > similarity)
if (CommonUtils.levenshtein(item.ItemName, floor.Name) > similarity)
{
floorTotalArea += floor.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();
item.Remarks += floor.Name + "\r\n";
}
}
SubItem item = new SubItem()
{
RootCategory = li[i].ElementAt(1),
SubCategory = li[i].ElementAt(2),
ItemName = li[i].ElementAt(3),
Description = li[i].ElementAt(4),
Unit = li[i].ElementAt(5),
Quantity = RsRevitUtils.ConvertSquareFeetToSquareMetre(floorTotalArea)
};
item.Quantity = RsRevitUtils.ConvertSquareFeetToSquareMetre(floorTotalArea);
items.Add(item);
}
else if (revitType == "ceiling")
{
double ceilingTotalArea = 0.0;
var ceilings = new FilteredElementCollector(doc).OfClass(typeof(Ceiling)).Cast<Ceiling>();
foreach (var ceiling in ceilings)
{
if (levenshtein(name, ceiling.Name) > similarity)
if (CommonUtils.levenshtein(item.ItemName, ceiling.Name) > similarity)
{
ceilingTotalArea += ceiling.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();
item.Remarks += ceiling.Name + "\r\n";
}
}
SubItem item = new SubItem()
{
RootCategory = li[i].ElementAt(1),
SubCategory = li[i].ElementAt(2),
ItemName = li[i].ElementAt(3),
Description = li[i].ElementAt(4),
Unit = li[i].ElementAt(5),
Quantity = RsRevitUtils.ConvertSquareFeetToSquareMetre(ceilingTotalArea)
};
item.Quantity = RsRevitUtils.ConvertSquareFeetToSquareMetre(ceilingTotalArea);
items.Add(item);
}
else if (revitType == "familyinstance")
@@ -409,107 +422,82 @@ namespace RookieStation.Statistics.ExecuteCmds
int count = 0;
double length = 0.0;
double area = 0.0;
string unit = li[i].ElementAt(5);
string unit = item.Unit;
foreach (var instance in instances)
{
string familyName = instance.Symbol.FamilyName;
if (levenshtein(familyName, li[i].ElementAt(3)) > similarity)
string tempname = CommonUtils.GetChineseWord(item.ItemName);
if (CommonUtils.levenshtein(tempname, familyName) > similarity)
{
if (unit == "m")
{
if (familyName.Contains("接待台"))
{
length += RsRevitUtils.ConvertFeetToMetre(instance.Symbol.GetParameters("台面长度").FirstOrDefault().AsDouble());
item.Remarks += familyName + "\r\n";
}
if (familyName.Contains("腰封玻璃贴"))
{
var cur = RsRevitUtils.GetLocationCurveByElement(instance);
length += RsRevitUtils.ConvertFeetToMetre(cur.Length);
item.Remarks += familyName + "\r\n";
}
if (familyName.Contains("亚克力水晶字"))
{
length += instance.GetParameters("文字").FirstOrDefault().AsString().Length * 116.4 / 1000;
item.Remarks += familyName + "\r\n";
}
if (familyName.Contains("精工背发光字"))
{
double l = Convert.ToDouble((instance.Symbol.Name.Substring(0, instance.Symbol.Name.IndexOf('m')))) / 1000;
length += l;
item.Remarks += familyName + "\r\n";
}
if (familyName.Contains("立体发光字"))
{
double l = Convert.ToDouble((instance.Symbol.Name.Substring(0, instance.Symbol.Name.IndexOf('m')))) / 1000;
length += l;
item.Remarks += familyName + "\r\n";
}
}
else if (unit == "m2")
{
if (familyName.Contains("卷帘"))
if (familyName.Contains("卷帘") || familyName.Contains("玻璃隔断"))
{
var a = instance.Symbol.get_Parameter(BuiltInParameter.FAMILY_HEIGHT_PARAM).AsDouble() * instance.Symbol.get_Parameter(BuiltInParameter.FURNITURE_WIDTH).AsDouble();
area += RsRevitUtils.ConvertSquareFeetToSquareMetre(a);
item.Remarks += familyName + "\r\n";
}
}
else if (unit == "套" || unit == "个")
{
if (familyName.Contains("仓储货架"))
{
if (li[i].ElementAt(3).Contains(instance.Symbol.GetParameters("长度").FirstOrDefault().AsValueString()))
if (item.ItemName.Contains(instance.Symbol.GetParameters("长度").FirstOrDefault().AsValueString()))
{
count += 1;
item.Remarks += familyName + "\r\n";
}
}
if (familyName.Contains("明装筒灯"))
else if (familyName.Contains("明装筒灯"))
{
if (li[i].ElementAt(3).Contains(instance.Symbol.Name))
if (item.Description.Contains(instance.Symbol.Name))
{
count += 1;
item.Remarks += familyName + "\r\n";
}
}
else
{
count += 1;
item.Remarks += familyName + "\r\n";
}
}
//var categoryValue = instance.Category.Id.IntegerValue;
//if (categoryValue == -2001060 || categoryValue == -2008087 || categoryValue == -2001350)//插座、开关、专用设备
//{
// count += 1;
//}
//else if (categoryValue == -2001120)//照明设备
//{
// if (li[i].ElementAt(3).Contains(instance.Symbol.Name))
// {
// count += 1;
// }
//}
//else if (categoryValue == -2000080 || categoryValue == -2001100)//家具、家具系统
//{
// if (li[i].ElementAt(5) == "m")
// {
// }
// else
// {
// count += 1;
// }
//}
//else if (categoryValue == -2000023 || categoryValue == -2000014)//门、窗
//{
// if (li[i].ElementAt(5) == "m2")
// {
// }
// else
// {
// count += 1;
// }
//}
};
}
}
SubItem item = new SubItem()
{
RootCategory = li[i].ElementAt(1),
SubCategory = li[i].ElementAt(2),
ItemName = li[i].ElementAt(3),
Description = li[i].ElementAt(4),
Unit = li[i].ElementAt(5),
};
switch (unit)
{
case "m":
@@ -536,30 +524,27 @@ namespace RookieStation.Statistics.ExecuteCmds
else if (revitType == "cabletray")
{
double ctTotalLength = 0.0;
var cts = new FilteredElementCollector(doc).OfClass(typeof(CableTray)).Cast<CableTray>();
foreach (var ct in cts)
{
ctTotalLength += ct.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsDouble();
item.Remarks += ct.Name + "\r\n";
}
SubItem item = new SubItem()
{
RootCategory = li[i].ElementAt(1),
SubCategory = li[i].ElementAt(2),
ItemName = li[i].ElementAt(3),
Description = li[i].ElementAt(4),
Unit = li[i].ElementAt(5),
Quantity = RsRevitUtils.ConvertFeetToMetre(ctTotalLength)
};
item.Quantity = RsRevitUtils.ConvertFeetToMetre(ctTotalLength);
items.Add(item);
}
else if (revitType == "curtainsystem")
{
double area = 0.0;
var curtainSystems = new FilteredElementCollector(doc).OfClass(typeof(CurtainSystem)).OfCategory(BuiltInCategory.OST_CurtaSystem).Cast<CurtainSystem>();
foreach (var curtainSystem in curtainSystems)
{
if (levenshtein(name, curtainSystem.Name) > similarity)
if (item.ItemName == curtainSystem.Name)
{
item.Remarks += curtainSystem.Name + "\r\n";
var geometryElement = curtainSystem.get_Geometry(new Options());
foreach (GeometryObject geomObj in geometryElement)
{
@@ -570,17 +555,17 @@ namespace RookieStation.Statistics.ExecuteCmds
}
}
}
//else//如果没有找到同名族类型,则按面积计算
//{
// var rooms = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).Cast<Room>();
// foreach (var room in rooms)
// {
// area += room.get_Parameter(BuiltInParameter.ROOM_AREA).AsDouble();
// }
//}
}
item.Quantity = RsRevitUtils.ConvertSquareFeetToSquareMetre(area);
SubItem item = new SubItem()
{
RootCategory = li[i].ElementAt(1),
SubCategory = li[i].ElementAt(2),
ItemName = li[i].ElementAt(3),
Description = li[i].ElementAt(4),
Unit = li[i].ElementAt(5),
Quantity = RsRevitUtils.ConvertSquareFeetToSquareMetre(area)
};
items.Add(item);
}
else//无法统计的量,采用总场地面积计
@@ -592,15 +577,8 @@ namespace RookieStation.Statistics.ExecuteCmds
otherArea += room.get_Parameter(BuiltInParameter.ROOM_AREA).AsDouble();
}
SubItem item = new SubItem()
{
RootCategory = li[i].ElementAt(1),
SubCategory = li[i].ElementAt(2),
ItemName = li[i].ElementAt(3),
Description = li[i].ElementAt(4),
Unit = li[i].ElementAt(5),
Quantity = RsRevitUtils.ConvertSquareFeetToSquareMetre(otherArea)
};
item.Quantity = RsRevitUtils.ConvertSquareFeetToSquareMetre(otherArea);
items.Add(item);
}
}
@@ -608,53 +586,12 @@ namespace RookieStation.Statistics.ExecuteCmds
return items;
}
public static float levenshtein(String str1, String str2)
{
int len1 = str1.Length;
int len2 = str2.Length;
int[,] dif = new int[len1 + 1, len2 + 1];
for (int a = 0; a <= len1; a++)
{
dif[a, 0] = a;
}
for (int a = 0; a <= len2; a++)
{
dif[0, a] = a;
}
int temp;
for (int i = 1; i <= len1; i++)
{
for (int j = 1; j <= len2; j++)
{
if (str1.ElementAt(i - 1) == str2.ElementAt(j - 1))
{
temp = 0;
}
else
{
temp = 1;
}
dif[i, j] = min(dif[i - 1, j - 1] + temp, dif[i, j - 1] + 1,
dif[i - 1, j] + 1);
}
}
float similarity = 1 - (float)dif[len1, len2] / Math.Max(len1, len2);
return similarity;
}
private static int min(params int[] arr)
{
int min = int.MaxValue;
foreach (int i in arr)
{
if (min > i)
{
min = i;
}
}
return min;
}
/// <summary>
/// 表头
/// </summary>
/// <param item.ItemName="doc"></param>
/// <param item.ItemName="package"></param>
/// <returns></returns>
private static ExcelWorksheet CreateTableHeader(Document doc, ExcelPackage package)
{
var rooms = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).Cast<Room>();
@@ -685,10 +622,13 @@ namespace RookieStation.Statistics.ExecuteCmds
sheet.SetValue(2, 2, Properties.Settings.Default.SchoolName);
sheet.Cells[2, 2].Style.Font.Color.SetColor(System.Drawing.Color.Red);
sheet.SetValue(2, 3, "预算总价");
sheet.SetValue(2, 4, "-");
//sheet.SetValue(2, 4, "-");
sheet.Cells[2, 4].Style.Numberformat.Format = "#,##0.00";
sheet.Cells[2, 4].Style.Font.Color.SetColor(System.Drawing.Color.Red);
sheet.SetValue(2, 6, "项目面积");
sheet.Cells["F2:G2"].Merge = true;
sheet.SetValue(2, 8, area);
sheet.Cells[2, 8].Style.Numberformat.Format = "#,##0.00";
sheet.Cells[2, 8].Style.Font.Color.SetColor(System.Drawing.Color.Red);
sheet.SetValue(2, 9, "预算日期");
sheet.SetValue(2, 10, DateTime.Now.ToString("D"));

View File

@@ -24,6 +24,7 @@ namespace RookieStation.ProjectConfig
internal static string LogFolder = AddinDirectory + "\\RsLibrary\\Log\\";
internal static string DbFolder = AddinDirectory + "\\RsLibrary\\";
internal static string MainMaterialFolder = AddinDirectory + "\\RsLibrary\\MainMaterials\\";
#else
@@ -34,6 +35,7 @@ namespace RookieStation.ProjectConfig
internal static string LogFolder = AddinDirectory + "\\Log\\";
internal static string DbFolder = AddinDirectory + "\\";
internal static string MainMaterialFolder = AddinDirectory + "\\MainMaterials\\";
#endif

View File

@@ -7,12 +7,84 @@ using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace RookieStation.Utils
{
internal static class CommonUtils
{
/// <summary>
/// 取得中文字符
/// </summary>
/// <param item.ItemName="oriText"></param>
/// <returns></returns>
public static string GetChineseWord(string oriText)
{
string x = @"[\u4E00-\u9FFF]+";
MatchCollection Matches = Regex.Matches
(oriText, x, RegexOptions.IgnoreCase);
StringBuilder sb = new StringBuilder();
foreach (Match NextMatch in Matches)
{
sb.Append(NextMatch.Value);
}
return sb.ToString();
}
/// <summary>
/// 比较字符串相似度
/// </summary>
/// <param item.ItemName="str1"></param>
/// <param item.ItemName="str2"></param>
/// <returns></returns>
public static float levenshtein(String str1, String str2)
{
int len1 = str1.Length;
int len2 = str2.Length;
int[,] dif = new int[len1 + 1, len2 + 1];
for (int a = 0; a <= len1; a++)
{
dif[a, 0] = a;
}
for (int a = 0; a <= len2; a++)
{
dif[0, a] = a;
}
int temp;
for (int i = 1; i <= len1; i++)
{
for (int j = 1; j <= len2; j++)
{
if (str1.ElementAt(i - 1) == str2.ElementAt(j - 1))
{
temp = 0;
}
else
{
temp = 1;
}
dif[i, j] = min(dif[i - 1, j - 1] + temp, dif[i, j - 1] + 1,
dif[i - 1, j] + 1);
}
}
float similarity = 1 - (float)dif[len1, len2] / Math.Max(len1, len2);
return similarity;
}
private static int min(params int[] arr)
{
int min = int.MaxValue;
foreach (int i in arr)
{
if (min > i)
{
min = i;
}
}
return min;
}
public static String GetEnumDescription(this Type e, int? value)
{
FieldInfo[] fields = e.GetFields();

View File

@@ -13,6 +13,12 @@
"SccProvider" = "8:"
"Hierarchy"
{
"Entry"
{
"MsmKey" = "8:_02094458B1124B9BB73E8D249B7B2335"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_032CB90F0BF943239BB69AAB64E6E14F"
@@ -75,6 +81,18 @@
}
"Entry"
{
"MsmKey" = "8:_1A9EDF70859E409592E35E31AEDC26DE"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_1AB9102E95934295AC08274702F82876"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_21A557C5E98D44DAA1A1C8B107B5D7F9"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
@@ -255,12 +273,24 @@
}
"Entry"
{
"MsmKey" = "8:_689F545FD72E436E954CE49088FC52D5"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_69CFE5CC346949CC8C772A6308CC7D75"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_6A85FF95D7764D46905FFFBB9BD5F0F4"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_6B17F4D39BED4015A225CC9774765826"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
@@ -327,6 +357,12 @@
}
"Entry"
{
"MsmKey" = "8:_89D4725F90F24CE08D05A39C4CCFC1BA"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_8B93DE5BD9D04559925F2D0A028817D1"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
@@ -339,6 +375,12 @@
}
"Entry"
{
"MsmKey" = "8:_92BC7EFB9EB247C6BE29CD0CD52C1166"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_94D83AC6917400F3B63679A37661FBFB"
"OwnerKey" = "8:_7CA1C332699FD9CD43194849BF997D08"
"MsmSig" = "8:_UNDEFINED"
@@ -483,6 +525,12 @@
}
"Entry"
{
"MsmKey" = "8:_C93A254F3D5E4FDBAE49E9981D5FA10D"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_CA838E6409624FCD8795AD075EE07CE0"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
@@ -501,6 +549,12 @@
}
"Entry"
{
"MsmKey" = "8:_CD6689FCC66148918EC6F4D46B86573D"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_CD837656CA87438A9E5944CD44B6CE7B"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
@@ -585,6 +639,12 @@
}
"Entry"
{
"MsmKey" = "8:_F096D99831204118A26826E7C92C0142"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_F3DBE5F365DC458EBC7E4BD1CFCF285D"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
@@ -792,6 +852,26 @@
}
"File"
{
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_02094458B1124B9BB73E8D249B7B2335"
{
"SourcePath" = "8:..\\RookieStation\\bin\\Release\\RsLibrary\\MainMaterials\\白色乳胶漆.png"
"TargetName" = "8:白色乳胶漆.png"
"Tag" = "8:"
"Folder" = "8:_39AC4D3278AD4B5FBAB245C54BDCB334"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_032CB90F0BF943239BB69AAB64E6E14F"
{
"SourcePath" = "8:..\\RookieStation\\bin\\Release\\RsLibrary\\FamilyLibrary\\门\\幕墙门-双扇无边框.rfa"
@@ -983,6 +1063,46 @@
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_1A9EDF70859E409592E35E31AEDC26DE"
{
"SourcePath" = "8:..\\RookieStation\\bin\\Release\\RsLibrary\\MainMaterials\\灰色地砖.png"
"TargetName" = "8:灰色地砖.png"
"Tag" = "8:"
"Folder" = "8:_39AC4D3278AD4B5FBAB245C54BDCB334"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_1AB9102E95934295AC08274702F82876"
{
"SourcePath" = "8:..\\RookieStation\\bin\\Release\\RsLibrary\\MainMaterials\\白色铝塑板.png"
"TargetName" = "8:白色铝塑板.png"
"Tag" = "8:"
"Folder" = "8:_39AC4D3278AD4B5FBAB245C54BDCB334"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_21A557C5E98D44DAA1A1C8B107B5D7F9"
{
"SourcePath" = "8:..\\RookieStation\\bin\\Release\\RsLibrary\\FamilyLibrary\\家具\\寄件接待台-带收检台.rfa"
@@ -1576,6 +1696,26 @@
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_689F545FD72E436E954CE49088FC52D5"
{
"SourcePath" = "8:..\\RookieStation\\bin\\Release\\RsLibrary\\MainMaterials\\木饰面.png"
"TargetName" = "8:木饰面.png"
"Tag" = "8:"
"Folder" = "8:_39AC4D3278AD4B5FBAB245C54BDCB334"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_69CFE5CC346949CC8C772A6308CC7D75"
{
"SourcePath" = "8:..\\RookieStation\\bin\\Release\\RsLibrary\\Texture\\取件区-左.png"
@@ -1596,6 +1736,26 @@
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_6A85FF95D7764D46905FFFBB9BD5F0F4"
{
"SourcePath" = "8:..\\RookieStation\\bin\\Release\\RsLibrary\\MainMaterials\\桥架.png"
"TargetName" = "8:桥架.png"
"Tag" = "8:"
"Folder" = "8:_39AC4D3278AD4B5FBAB245C54BDCB334"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_6B17F4D39BED4015A225CC9774765826"
{
"SourcePath" = "8:..\\RookieStation\\bin\\Release\\RsLibrary\\FamilyLibrary\\标识标牌\\菜鸟使命.rfa"
@@ -1829,6 +1989,26 @@
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_89D4725F90F24CE08D05A39C4CCFC1BA"
{
"SourcePath" = "8:..\\RookieStation\\bin\\Release\\RsLibrary\\MainMaterials\\明装筒灯.png"
"TargetName" = "8:明装筒灯.png"
"Tag" = "8:"
"Folder" = "8:_39AC4D3278AD4B5FBAB245C54BDCB334"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_8B93DE5BD9D04559925F2D0A028817D1"
{
"SourcePath" = "8:..\\RookieStation\\bin\\Release\\RsLibrary\\FamilyLibrary\\出入口\\直线形收检台.rfa"
@@ -1869,6 +2049,26 @@
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_92BC7EFB9EB247C6BE29CD0CD52C1166"
{
"SourcePath" = "8:..\\RookieStation\\bin\\Release\\RsLibrary\\MainMaterials\\明装射灯.png"
"TargetName" = "8:明装射灯.png"
"Tag" = "8:"
"Folder" = "8:_39AC4D3278AD4B5FBAB245C54BDCB334"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_94D83AC6917400F3B63679A37661FBFB"
{
"AssemblyRegister" = "3:1"
@@ -2282,6 +2482,26 @@
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_C93A254F3D5E4FDBAE49E9981D5FA10D"
{
"SourcePath" = "8:..\\RookieStation\\bin\\Release\\RsLibrary\\MainMaterials\\灰色乳胶漆.png"
"TargetName" = "8:灰色乳胶漆.png"
"Tag" = "8:"
"Folder" = "8:_39AC4D3278AD4B5FBAB245C54BDCB334"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_CA838E6409624FCD8795AD075EE07CE0"
{
"SourcePath" = "8:..\\RookieStation\\bin\\Release\\RsLibrary\\FamilyLibrary\\标识标牌\\精工背发光字.rfa"
@@ -2342,6 +2562,26 @@
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_CD6689FCC66148918EC6F4D46B86573D"
{
"SourcePath" = "8:..\\RookieStation\\bin\\Release\\RsLibrary\\MainMaterials\\吊灯.png"
"TargetName" = "8:吊灯.png"
"Tag" = "8:"
"Folder" = "8:_39AC4D3278AD4B5FBAB245C54BDCB334"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_CD837656CA87438A9E5944CD44B6CE7B"
{
"SourcePath" = "8:..\\RookieStation\\bin\\Release\\RsLibrary\\FamilyLibrary\\标识标牌\\亚克力水晶字.rfa"
@@ -2633,6 +2873,26 @@
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_F096D99831204118A26826E7C92C0142"
{
"SourcePath" = "8:..\\RookieStation\\bin\\Release\\RsLibrary\\MainMaterials\\黑钛不锈钢(哑光).png"
"TargetName" = "8:黑钛不锈钢(哑光).png"
"Tag" = "8:"
"Folder" = "8:_39AC4D3278AD4B5FBAB245C54BDCB334"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_F3DBE5F365DC458EBC7E4BD1CFCF285D"
{
"AssemblyRegister" = "3:1"
@@ -2932,6 +3192,17 @@
}
}
}
"{9EF0B969-E518-4E46-987F-47570745A589}:_39AC4D3278AD4B5FBAB245C54BDCB334"
{
"Name" = "8:MainMaterials"
"AlwaysCreate" = "11:FALSE"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Property" = "8:_47091386A10D44E0BAD296C443B6BAE7"
"Folders"
{
}
}
"{9EF0B969-E518-4E46-987F-47570745A589}:_935FCE4D5F1B41D29B0881394E7A6B15"
{
"Name" = "8:Document"
@@ -2987,15 +3258,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:菜鸟驿站工具集"
"ProductCode" = "8:{5DCFF0F8-3C6C-4C34-B888-63FE8034843E}"
"PackageCode" = "8:{F481155F-8AF8-48C7-A715-4BA4074E52A3}"
"ProductCode" = "8:{4B2A717E-F947-4900-B5F1-1A37FC1A5984}"
"PackageCode" = "8:{504731B2-B217-4AED-AEF6-5511412AB677}"
"UpgradeCode" = "8:{127EC3EC-7539-468B-84EA-E1ECDD6204E6}"
"AspNetVersion" = "8:2.0.50727.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE"
"ProductVersion" = "8:1.0.3"
"ProductVersion" = "8:1.0.4"
"Manufacturer" = "8:YTX Engineering"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"

View File

BIN
说明文档.docx Normal file

Binary file not shown.