命名规范化

This commit is contained in:
GG Z
2021-06-11 15:42:50 +08:00
parent a3f6bdcc32
commit 5e1bd8ca9a
37 changed files with 2288 additions and 2090 deletions

View File

@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace RookieStation.PackAreaModule
{
@@ -17,22 +18,21 @@ namespace RookieStation.PackAreaModule
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
string addin_path = typeof(RsApp).Assembly.Location;
string assembly_directory = System.IO.Path.GetDirectoryName(addin_path);
AssemblyLoader loader = new AssemblyLoader(assembly_directory);
string addinPath = typeof(RsApp).Assembly.Location;
string assemblyDirectory = System.IO.Path.GetDirectoryName(addinPath);
AssemblyLoader loader = new AssemblyLoader(assemblyDirectory);
try
{
loader.HookAssemblyResolve();
WpfShelfCards cards_number = new WpfShelfCards(uiapp);
WpfShelfCards shelfCards = new WpfShelfCards(uiapp);
System.Windows.Interop.WindowInteropHelper mainUI = new System.Windows.Interop.WindowInteropHelper(cards_number)
System.Windows.Interop.WindowInteropHelper mainui = new System.Windows.Interop.WindowInteropHelper(shelfCards)
{
Owner = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle
};
cards_number.ShowDialog();
shelfCards.ShowDialog();
}
catch (Exception ex)
{
@@ -43,7 +43,16 @@ namespace RookieStation.PackAreaModule
{
loader.UnhookAssemblyResolve();
}
//if (shelfcards.IsPlace)
//{
// PlaceCards(shelfcards, uidoc);
//}
//else
//{
// NumberCards(shelfcards, uidoc);
//}
return Result.Succeeded;
//if (IsVisible("端牌编号"))
//{
// WinIntPtr.ShowAndActive("端牌编号");

View File

@@ -15,11 +15,18 @@ namespace RookieStation.CommonTools
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
//var dpid = new DockablePaneId(PaneIdentifiers.GetManagerPaneIdentifier());
var library_directory = UserConstant.FamilyLibraryDirectory;
System.Diagnostics.Process.Start(library_directory);
try
{
var libraryDirectory = UserConstant.FamilyLibraryDirectory;
System.Diagnostics.Process.Start(libraryDirectory);
}
catch (Exception)
{
TaskDialog.Show("温馨提示", "路径不存在,无法浏览文件");
return Result.Failed;
}
return Result.Succeeded;
}
}

View File

@@ -28,7 +28,7 @@ namespace RookieStation
List<Face> reffaces = new List<Face>();
var ins = instances.FirstOrDefault();
var p = RsRevitUtils.GetXYZByElement(ins);
var p = RsRevitUtils.GetLocationPointByElement(ins);
var v = ins.FacingOrientation;
Line line = Line.CreateUnbound(p, v);
//createoffest需要根据线的方向和参考方向进行叉乘

View File

@@ -38,20 +38,19 @@ namespace RookieStation.PackAreaModule
Document doc = uidoc.Document;
revitWindow = uiapp.MainWindowHandle;
WpfEntranceGate entrancegateLayout = CommonUtils.GenerateWindow<WpfEntranceGate>();
return doc.InvokeGroup<Result>(tg =>
{
if (entrancegateLayout.DialogResult != true)
WpfEntranceGate entranceGateLayout = CommonUtils.GenerateWindow<WpfEntranceGate>();
if (entranceGateLayout.DialogResult != true)
{
return Result.Cancelled;
}
return doc.InvokeGroup<Result>(tg =>
{
try
{
FamilySymbol linesymbol = RsRevitUtils.GetGuideSymbol(doc);
FamilySymbol guideSymbol = RsRevitUtils.GetGuideSymbol(doc);
eleIdsAdded.Clear();
uiapp.Application.DocumentChanged += Application_DocumentChanged;
uidoc.PromptForFamilyInstancePlacement(linesymbol);
uidoc.PromptForFamilyInstancePlacement(guideSymbol);
uiapp.Application.DocumentChanged -= Application_DocumentChanged;
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
@@ -60,13 +59,13 @@ namespace RookieStation.PackAreaModule
{
return Result.Cancelled;
}
Line refer_line = RsRevitUtils.GetGuideGeometryAndDeleteGuide(doc, eleIdsAdded);
Line line = RsRevitUtils.GetGuideGeometryAndDeleteGuide(doc, eleIdsAdded);
uiapp.Application.DocumentChanged -= Application_DocumentChanged;
double interval = (330 + entrancegateLayout.passage_width) / 304.8;
double interval = (330 + entranceGateLayout.PassageWidth) / 304.8;
double offest = 0.0;
//布置闸机的数量
List<XYZ> pts = GetInstancePointsByLine(refer_line, interval);
List<XYZ> pts = GetInstancePointsByLine(line, interval);
List<FamilyInstance> instances = new List<FamilyInstance>();
doc.Invoke(ts =>
{
@@ -74,43 +73,43 @@ namespace RookieStation.PackAreaModule
}, "创建闸机位置");
doc.Invoke(ts =>
{
RsRevitUtils.AdjustInstances(doc, instances, refer_line, offest);
RsRevitUtils.AdjustInstances(doc, instances, line, offest);
}, "调整闸机位置");
}
return Result.Succeeded;
}, "布置入口闸机");
}
private void CreateGates(UIDocument uidoc, List<XYZ> pts, out List<FamilyInstance> fis, out double offest)
private void CreateGates(UIDocument uidoc, List<XYZ> points, out List<FamilyInstance> fis, out double offest)
{
Document doc = uidoc.Document;
fis = new List<FamilyInstance>();
Level level = uidoc.ActiveView.GenLevel;
Family gate_family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Gate\\闸机.rfa");
ElementId symbol_id = gate_family.GetFamilySymbolIds().FirstOrDefault();
FamilySymbol gate_symbol = doc.GetElement(symbol_id) as FamilySymbol;
offest = gate_symbol.GetParameters("深度").FirstOrDefault().AsDouble() / 2;
gate_symbol.Activate();
foreach (var pt in pts)
Family gateFamily = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Gate\\闸机.rfa");
ElementId symbolId = gateFamily.GetFamilySymbolIds().FirstOrDefault();
FamilySymbol gateSymbol = doc.GetElement(symbolId) as FamilySymbol;
offest = gateSymbol.GetParameters("深度").FirstOrDefault().AsDouble() / 2;
gateSymbol.Activate();
foreach (XYZ p in points)
{
var instance = doc.Create.NewFamilyInstance(pt, gate_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
var instance = doc.Create.NewFamilyInstance(p, gateSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
fis.Add(instance);
}
}
private List<XYZ> GetInstancePointsByLine(Line referline, double interval)
private List<XYZ> GetInstancePointsByLine(Line line, double interval)
{
int n = 50;
List<XYZ> pts = new List<XYZ>();
for (int i = 0; i < n; i++)
{
double parameter = (i + 0.5) * interval;
if (!referline.IsInside(parameter + (interval / 2)))
if (!line.IsInside(parameter + (interval / 2)))
{
break;
}
pts.Add(referline.Evaluate(parameter, false));
pts.Add(line.Evaluate(parameter, false));
}
return pts;

View File

@@ -44,18 +44,18 @@ namespace RookieStation.PackAreaModule
Document doc = uidoc.Document;
revitWindow = uiapp.MainWindowHandle;
WpfExitGate gate_layout = CommonUtils.GenerateWindow<WpfExitGate>();
WpfExitGate gateLayout = CommonUtils.GenerateWindow<WpfExitGate>();
if (gate_layout.DialogResult == true)
if (gateLayout.DialogResult == true)
{
isPassageStart = gate_layout.isStartPassage;
isPassageStart = gateLayout.IsStartPassage;
}
else
{
return Result.Cancelled;
}
double interval = (2 * (1030 + gate_layout.passage_width) + 100) / 304.8;
double gate_front_offest = 1630 / 304.8;
double interval = (2 * (1030 + gateLayout.PassageWidth) + 100) / 304.8;
double gateFrontOffest = 1630 / 304.8;
List<FamilyInstance> instances = new List<FamilyInstance>();
using (TransactionGroup tg = new TransactionGroup(doc, "布置出口收检台"))
@@ -63,11 +63,11 @@ namespace RookieStation.PackAreaModule
tg.Start();
try
{
FamilySymbol line_symbol = RsRevitUtils.GetGuideSymbol(doc); ;
FamilySymbol guideSymbol = RsRevitUtils.GetGuideSymbol(doc); ;
eleIdsAdded.Clear();
uiapp.Application.DocumentChanged += Application_DocumentChanged;
uidoc.PromptForFamilyInstancePlacement(line_symbol);
uidoc.PromptForFamilyInstancePlacement(guideSymbol);
uiapp.Application.DocumentChanged -= Application_DocumentChanged;
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
@@ -77,7 +77,7 @@ namespace RookieStation.PackAreaModule
return Result.Cancelled;
}
//直线向量
Line refer_line = RsRevitUtils.GetGuideGeometryAndDeleteGuide(doc, eleIdsAdded);
Line referline = RsRevitUtils.GetGuideGeometryAndDeleteGuide(doc, eleIdsAdded);
uiapp.Application.DocumentChanged -= Application_DocumentChanged;
int orders = UserConstant.Orders;
@@ -89,46 +89,46 @@ namespace RookieStation.PackAreaModule
}
int m = isPassageStart
? (int)Math.Floor((refer_line.Length * 304.8 / 1630) + 0.5)
: (int)Math.Floor(((refer_line.Length * 304.8) - 200) / 1630 + 0.5);
? (int)Math.Floor((referline.Length * 304.8 / 1630) + 0.5)
: (int)Math.Floor(((referline.Length * 304.8) - 200) / 1630 + 0.5);
if (m < n)
{
n = m;
}
List<XYZ> pts = new List<XYZ>();
List<XYZ> locationPoint = new List<XYZ>();
doc.Invoke(ts =>
{
Family gate_family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Gate\\L型收检台.rfa");
IEnumerable<ElementId> left_symbolId = from id in gate_family.GetFamilySymbolIds()
Family gateFamily = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Gate\\L型收检台.rfa");
IEnumerable<ElementId> leftSymbolId = from id in gateFamily.GetFamilySymbolIds()
where doc.GetElement(id).Name == "左"
select id;
IEnumerable<ElementId> right_symbolId = from id in gate_family.GetFamilySymbolIds()
IEnumerable<ElementId> rightSymbolId = from id in gateFamily.GetFamilySymbolIds()
where doc.GetElement(id).Name == "右"
select id;
FamilySymbol right_symbol = doc.GetElement(right_symbolId.FirstOrDefault()) as FamilySymbol;
FamilySymbol rightSymbol = doc.GetElement(rightSymbolId.FirstOrDefault()) as FamilySymbol;
//ElementId symbolId = family.GetFamilySymbolIds().FirstOrDefault();
FamilySymbol left_symbol = doc.GetElement(left_symbolId.FirstOrDefault()) as FamilySymbol;
FamilySymbol leftSymbol = doc.GetElement(leftSymbolId.FirstOrDefault()) as FamilySymbol;
Level level = uidoc.ActiveView.GenLevel;
if (isPassageStart)//起始是通道
{
for (int i = 0; i < n; i++)
{
XYZ p = refer_line.Evaluate(i * interval, false);
pts.Add(p);
XYZ p = referline.Evaluate(i * interval, false);
locationPoint.Add(p);
}
foreach (XYZ location_XYZ in pts)
foreach (XYZ point in locationPoint)
{
left_symbol.Activate();
FamilyInstance left_instance = doc.Create.NewFamilyInstance(location_XYZ, left_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instances.Add(left_instance);
leftSymbol.Activate();
FamilyInstance leftInstance = doc.Create.NewFamilyInstance(point, leftSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instances.Add(leftInstance);
if (instances.Count() == n + 1)
{
break;
}
right_symbol.Activate();
FamilyInstance right_instance = doc.Create.NewFamilyInstance(location_XYZ, right_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instances.Add(right_instance);
rightSymbol.Activate();
FamilyInstance rightInstance = doc.Create.NewFamilyInstance(point, rightSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instances.Add(rightInstance);
if (instances.Count() == n + 1)
{
break;
@@ -144,25 +144,25 @@ namespace RookieStation.PackAreaModule
{
for (int i = 0; i < n; i++)
{
XYZ p = refer_line.Evaluate((i * interval) + 1830 / 304.8, false);
XYZ p = referline.Evaluate((i * interval) + 1830 / 304.8, false);
pts.Add(p);
locationPoint.Add(p);
}
foreach (var pt in pts)
foreach (var pt in locationPoint)
{
left_symbol.Activate();
var left_instance = doc.Create.NewFamilyInstance(pt, left_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
leftSymbol.Activate();
var leftInstance = doc.Create.NewFamilyInstance(pt, leftSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
//offest = symbol.GetParameters("深度").FirstOrDefault().AsDouble() / 2;
instances.Add(left_instance);
instances.Add(leftInstance);
if (instances.Count() == n)
{
break;
}
right_symbol.Activate();
var right_instance = doc.Create.NewFamilyInstance(pt, right_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instances.Add(right_instance);
rightSymbol.Activate();
var rightInstance = doc.Create.NewFamilyInstance(pt, rightSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instances.Add(rightInstance);
if (instances.Count() == n)
{
break;
@@ -172,7 +172,7 @@ namespace RookieStation.PackAreaModule
}, "加载并创建收检台");
doc.Invoke(ts =>
{
RsRevitUtils.AdjustInstances(doc, instances, refer_line, gate_front_offest);
RsRevitUtils.AdjustInstances(doc, instances, referline, gateFrontOffest);
}, "调整收检台位置");
//if (tg.GetStatus() == TransactionStatus.Started)
//{

View File

@@ -39,40 +39,35 @@ namespace RookieStation.Finishes
if (floorCovering.DialogResult == true)
{
length = floorCovering.cLength / 304.8;
width = floorCovering.cWidth / 304.8;
gap = floorCovering.cGap / 304.8;
length = floorCovering.PavementLength / 304.8;
width = floorCovering.PavementWidth / 304.8;
gap = floorCovering.PavementGap / 304.8;
}
else
{
return Result.Cancelled;
}
using (TransactionGroup tg = new TransactionGroup(doc, "地面铺装"))
return doc.InvokeGroup(tg =>
{
try
{
var v = new FilteredElementCollector(doc).OfClass(typeof(View))
.Cast<View>()
.FirstOrDefault(x => x.ViewType == ViewType.FloorPlan && x.GenLevel.Elevation == 0);
var baselevel = new FilteredElementCollector(doc)
.OfClass(typeof(Level))
.Cast<Level>()
.FirstOrDefault(x => x.Elevation == 0);
//var v = new FilteredElementCollector(doc).OfClass(typeof(View))
// .Cast<View>()
// .FirstOrDefault(x => x.ViewType == ViewType.FloorPlan && x.GenLevel.Elevation == 0);
//if (uidoc.ActiveView.ViewType != ViewType.FloorPlan)
//{
// uidoc.RequestViewChange(v);
//}
var baseLevel = doc.ActiveView.GenLevel;
List<ElementId> modelCurveIds = new List<ElementId>();
tg.Start();
if (uidoc.ActiveView.ViewType != ViewType.FloorPlan)
{
uidoc.RequestViewChange(v);
}
SelectFilter<Room> selfilter = new SelectFilter<Room>();
Reference roomrefer = uidoc.Selection.PickObject(ObjectType.Element, selfilter, "请选择房间");
Room room = doc.GetElement(roomrefer) as Room;
SelectFilter<Room> roomFilter = new SelectFilter<Room>();
Reference roomReference = uidoc.Selection.PickObject(ObjectType.Element, roomFilter, "请选择房间");
Room room = doc.GetElement(roomReference) as Room;
var roompoint = RsRevitUtils.GetXYZByElement(room);
var roompoint = RsRevitUtils.GetLocationPointByElement(room);
var segments = room.GetBoundarySegments(new SpatialElementBoundaryOptions()).FirstOrDefault();
doc.Invoke(ts =>
@@ -87,15 +82,15 @@ namespace RookieStation.Finishes
}, "模型线创建");
//Reference edge = uidoc.Selection.PickObject(ObjectType.Edge, "请选择边界");
SelectFilter<ModelLine> mlfilter = new SelectFilter<ModelLine>();
Reference refline = uidoc.Selection.PickObject(ObjectType.Element, mlfilter, "请选择基准边线");
SelectFilter<ModelLine> mlFilter = new SelectFilter<ModelLine>();
Reference refline = uidoc.Selection.PickObject(ObjectType.Element, mlFilter, "请选择基准边线");
//模型线选取
var ml = doc.GetElement(refline) as ModelLine;
Line line = ml.GeometryCurve as Line;
Line line1 = RsRevitUtils.GetLongestSegmentLine(segments, line);
XYZ basepoint = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择基准点(位于基准线上)");
double alength = basepoint.DistanceTo(line.GetEndPoint(0)) + basepoint.DistanceTo(line.GetEndPoint(1));
if (line.Length - alength > 0.001)
Line referline = ml.GeometryCurve as Line;
Line longestLine = RsRevitUtils.GetLongestSegmentLine(segments, referline);
XYZ basePoint = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择基准点(位于基准线上)");
double lengthCount = basePoint.DistanceTo(referline.GetEndPoint(0)) + basePoint.DistanceTo(referline.GetEndPoint(1));
if (referline.Length - lengthCount > 0.001)
{
MessageBox.Show("请选择基准线上的点", "温馨提示");
return Result.Cancelled;
@@ -104,13 +99,13 @@ namespace RookieStation.Finishes
//{
//}
//基准线端点
var endp1 = line.GetEndPoint(0);
var endp2 = line.GetEndPoint(1);
var endpoint1 = referline.GetEndPoint(0);
var endpoint2 = referline.GetEndPoint(1);
//基准点向端点的向量
XYZ v1 = endp1 - basepoint;
XYZ v2 = endp2 - basepoint;
XYZ v1 = endpoint1 - basePoint;
XYZ v2 = endpoint2 - basePoint;
//用于确认布置方向
var v0 = roompoint - basepoint;
var v0 = roompoint - basePoint;
List<Curve> curves = new List<Curve>();
List<FamilyInstance> instances = new List<FamilyInstance>();
//Curve currefer = null;
@@ -118,61 +113,61 @@ namespace RookieStation.Finishes
double interval = length + gap;
List<XYZ> pts = new List<XYZ>();
List<XYZ> lastps = new List<XYZ>();
List<XYZ> lastpoints = new List<XYZ>();
XYZ zdir1 = null;
XYZ zdir2 = null;
XYZ offestvector = null;
XYZ offestVector = null;
double d1 = 0.0;
double d2 = 0.0;
//切分基准线后两侧向量不为0
if (!v1.IsAlmostEqualTo(XYZ.Zero))
{
if (endp1.DistanceTo(basepoint) < length)
if (endpoint1.DistanceTo(basePoint) < length)
{
System.Windows.MessageBox.Show("基准点与基准线端点距离太近");
return Result.Cancelled;
}
zdir1 = v1.CrossProduct(v0).Normalize();
//偏移的方向,直线的侧方向
offestvector = zdir1.CrossProduct(v1).Normalize();
Line l1 = Line.CreateBound(basepoint, ml.GeometryCurve.GetEndPoint(0));
offestVector = zdir1.CrossProduct(v1).Normalize();
Line l1 = Line.CreateBound(basePoint, ml.GeometryCurve.GetEndPoint(0));
for (int i = 0; i < 10000; i++)
{
var parameter = i * interval;
if (!l1.IsInside(parameter + interval - gap / 2))
{
var lastp1 = pts.Last() - offestvector * width / 2;
var lastp1 = pts.Last() - offestVector * width / 2;
d1 = lastp1.DistanceTo(endp1) - length / 2 - gap;
d1 = lastp1.DistanceTo(endpoint1) - length / 2 - gap;
var lastfinalpoint = lastp1 + (l1.Direction * (d1 / 2 + length / 2 + gap)) + (offestvector * width / 2);
var lastfinalpoint = lastp1 + (l1.Direction * (d1 / 2 + length / 2 + gap)) + (offestVector * width / 2);
lastps.Add(lastfinalpoint);
lastpoints.Add(lastfinalpoint);
break;
}
XYZ p = l1.Evaluate(parameter, false);
XYZ finalpoint = p + (l1.Direction * interval / 2) + (offestvector * width / 2);
XYZ finalPoint = p + (l1.Direction * interval / 2) + (offestVector * width / 2);
//当选择的基准点为端点时
if (v2.IsAlmostEqualTo(XYZ.Zero))
{
finalpoint = p + (l1.Direction * (interval - gap) / 2) + (offestvector * width / 2);
finalPoint = p + (l1.Direction * (interval - gap) / 2) + (offestVector * width / 2);
}
pts.Add(finalpoint);
pts.Add(finalPoint);
}
}
if (!v2.IsAlmostEqualTo(XYZ.Zero))
{
if (endp2.DistanceTo(basepoint) < length)
if (endpoint2.DistanceTo(basePoint) < length)
{
System.Windows.MessageBox.Show("基准点与基准线端点距离太近");
return Result.Cancelled;
}
zdir2 = v2.CrossProduct(v0).Normalize();
offestvector = zdir2.CrossProduct(v2).Normalize();
Line l2 = Line.CreateBound(basepoint, ml.GeometryCurve.GetEndPoint(1));
offestVector = zdir2.CrossProduct(v2).Normalize();
Line l2 = Line.CreateBound(basePoint, ml.GeometryCurve.GetEndPoint(1));
for (int i = 0; i < 10000; i++)
{
@@ -181,31 +176,29 @@ namespace RookieStation.Finishes
{
//var lastdistance = pts.Last().DistanceTo(endp1) - interval / 2 - gap / 2;
var lastp2 = pts.Last() - offestvector * width / 2;
var lastp2 = pts.Last() - offestVector * width / 2;
d2 = lastp2.DistanceTo(endp2) - length / 2 - gap;
d2 = lastp2.DistanceTo(endpoint2) - length / 2 - gap;
var lastfinalpoint = lastp2 + (l2.Direction * (d2 / 2 + length / 2 + gap)) + (offestvector * width / 2);
var lastFinalPoint = lastp2 + (l2.Direction * (d2 / 2 + length / 2 + gap)) + (offestVector * width / 2);
lastps.Add(lastfinalpoint);
lastpoints.Add(lastFinalPoint);
break;
}
XYZ p = l2.Evaluate(parameter, false);
//附加的基准线的水平垂直偏移距离
var finalpoint = p + (l2.Direction * interval / 2) + (offestvector * width / 2);
var finalpoint = p + (l2.Direction * interval / 2) + (offestVector * width / 2);
if (v1.IsAlmostEqualTo(XYZ.Zero))
{
finalpoint = p + (l2.Direction * (interval - gap) / 2) + (offestvector * width / 2);
finalpoint = p + (l2.Direction * (interval - gap) / 2) + (offestVector * width / 2);
}
pts.Add(finalpoint);
}
//var lastl2 = pts.Last().DistanceTo(endp2);
}
using (Transaction trans = new Transaction(doc, "地面铺装"))
doc.Invoke(ts =>
{
trans.Start();
//删除模型线
doc.Delete(modelCurveIds);
family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "FloorFinish\\地砖.rfa");
@@ -215,28 +208,27 @@ namespace RookieStation.Finishes
foreach (var p in pts)
{
var fi = doc.Create
.NewFamilyInstance(p, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
.NewFamilyInstance(p, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instances.Add(fi);
}
foreach (var p in lastps)
foreach (var p in lastpoints)
{
var fi = doc.Create
.NewFamilyInstance(p, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
.NewFamilyInstance(p, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instances.Add(fi);
}
trans.Commit();
}
using (Transaction trans = new Transaction(doc, "调整地砖"))
}, "地面铺装");
doc.Invoke(ts =>
{
trans.Start();
XYZ veroffestdir = null;
if (zdir1 != null)
{
veroffestdir = zdir1.CrossProduct(line.Direction).Normalize();
veroffestdir = zdir1.CrossProduct(referline.Direction).Normalize();
}
if (zdir2 != null)
{
veroffestdir = zdir2.CrossProduct(line.Direction).Normalize();
veroffestdir = zdir2.CrossProduct(referline.Direction).Normalize();
}
//旋转角度
double angle = XYZ.BasisY.AngleTo(veroffestdir);
@@ -261,7 +253,7 @@ namespace RookieStation.Finishes
{
FamilyInstance fi = instances[i];
var filp = RsRevitUtils.GetXYZByElement(fi);
var filp = RsRevitUtils.GetLocationPointByElement(fi);
Line zaxis = Line.CreateUnbound(filp, XYZ.BasisZ);
//旋转,移动
@@ -271,10 +263,10 @@ namespace RookieStation.Finishes
if (i >= instances.Count - n)
{
var loc = RsRevitUtils.GetXYZByElement(instances[i]);
var loc = RsRevitUtils.GetLocationPointByElement(instances[i]);
var dis1 = loc.DistanceTo(endp1);
var dis2 = loc.DistanceTo(endp2);
var dis1 = loc.DistanceTo(endpoint1);
var dis2 = loc.DistanceTo(endpoint2);
if (dis1 < interval)
{
@@ -302,44 +294,41 @@ namespace RookieStation.Finishes
// fi.flipHand();
//}
}
}, "调整地砖");
trans.Commit();
}
using (Transaction trans = new Transaction(doc, "复制地砖"))
doc.Invoke(ts =>
{
List<ElementId> copyids = new List<ElementId>();
trans.Start();
List<ElementId> idsCopied = new List<ElementId>();
for (int i = 0; i < instances.Count; i++)
{
FamilyInstance fi = instances[i];
int num = (int)Math.Floor(line1.Length / (width + gap));
double rem = line1.Length - num * (width + gap);
int num = (int)Math.Floor(longestLine.Length / (width + gap));
double rem = longestLine.Length - num * (width + gap);
for (int j = 1; j <= num; j++)
{
ICollection<ElementId> eles;
if (j == num)
{
eles = ElementTransformUtils.CopyElement(doc, fi.Id, offestvector * ((rem / 2) + (width + gap) * (j - 0.5) + gap));
eles = ElementTransformUtils.CopyElement(doc, fi.Id, offestVector * ((rem / 2) + (width + gap) * (j - 0.5) + gap));
FamilyInstance copyinstance = doc.GetElement(eles.FirstOrDefault()) as FamilyInstance;
copyinstance.GetParameters("宽").FirstOrDefault().Set(rem);
copyids.AddRange(eles.ToList());
idsCopied.AddRange(eles.ToList());
break;
}
eles = ElementTransformUtils.CopyElement(doc, fi.Id, offestvector * (width + gap) * j);
copyids.AddRange(eles.ToList());
eles = ElementTransformUtils.CopyElement(doc, fi.Id, offestVector * (width + gap) * j);
idsCopied.AddRange(eles.ToList());
}
}
foreach (var id in copyids)
foreach (var id in idsCopied)
{
FamilyInstance copyinstance = doc.GetElement(id) as FamilyInstance;
if (copyinstance.Room == null)
FamilyInstance instanceCopied = doc.GetElement(id) as FamilyInstance;
if (instanceCopied.Room == null)
{
doc.Delete(id);
}
}
trans.Commit();
}
}, "复制地砖");
#region MyRegion
@@ -487,26 +476,9 @@ namespace RookieStation.Finishes
// }
//}
//ModelCurve mc = doc.Create.NewModelCurve();
//var geoelem = room.get_Geometry(new Options());
//foreach (var geomObj in geoelem)
//{
// Solid geomSolid = geomObj as Solid;
// if (null != geomSolid)
// {
// foreach (Face geomFace in geomSolid.Faces)
// {
// break;
// }
// break;
// }
//}
//Do Something.
#endregion MyRegion
tg.Assimilate();
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
@@ -514,10 +486,10 @@ namespace RookieStation.Finishes
{
tg.RollBack();
}
return Result.Cancelled;
}
return Result.Succeeded;
}
return Result.Succeeded;
}, "地面铺装");
}
private List<XYZ> GetIntersectPoints(List<Curve> curves)

View File

@@ -27,11 +27,11 @@ namespace RookieStation.PackAreaModule
DocumentSet docset = uiapp.Application.Documents;
Family family = null;
FamilySymbol symbol;
double lrdistance = 0.0;
double fbdistance = 0.0;
double leftRightDistance = 0.0;
double frontDistance = 0.0;
var roomcounts = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).GetElementCount();
if (roomcounts == 0)
var roomCount = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).GetElementCount();
if (roomCount == 0)
{
TaskDialog.Show("温馨提示", "项目中当前没有房间");
return Result.Cancelled;
@@ -40,8 +40,8 @@ namespace RookieStation.PackAreaModule
if (placeLamps.DialogResult == true)
{
lrdistance = placeLamps.LRDistance / 304.8;
fbdistance = placeLamps.LRDistance / 304.8;
leftRightDistance = placeLamps.LeftRightDistance / 304.8;
frontDistance = placeLamps.FrontDistance / 304.8;
}
else
{
@@ -49,7 +49,7 @@ namespace RookieStation.PackAreaModule
}
double interval = 2000 / 304.8;
using (TransactionGroup tg = new TransactionGroup(doc, "布置灯具"))
return doc.InvokeGroup(tg =>
{
try
{
@@ -57,51 +57,48 @@ namespace RookieStation.PackAreaModule
.Cast<View>()
.FirstOrDefault(x => x.ViewType == ViewType.FloorPlan && x.GenLevel.Elevation == 0);
var baselevel = new FilteredElementCollector(doc)
var baseLevel = new FilteredElementCollector(doc)
.OfClass(typeof(Level))
.Cast<Level>()
.FirstOrDefault(x => x.Elevation == 0);
List<ElementId> modelCurveIds = new List<ElementId>();
tg.Start();
if (uidoc.ActiveView.ViewType != ViewType.FloorPlan)
{
uidoc.RequestViewChange(v);
}
SelectFilter<Room> selfilter = new SelectFilter<Room>();
Reference roomrefer = uidoc.Selection.PickObject(ObjectType.Element, selfilter, "请选择房间");
Room room = doc.GetElement(roomrefer) as Room;
SelectFilter<Room> roomFilter = new SelectFilter<Room>();
Reference roomReference = uidoc.Selection.PickObject(ObjectType.Element, roomFilter, "请选择房间");
Room room = doc.GetElement(roomReference) as Room;
var roompoint = RsRevitUtils.GetXYZByElement(room);
var roomLocationPoint = RsRevitUtils.GetLocationPointByElement(room);
IList<BoundarySegment> segments = room.GetBoundarySegments(new SpatialElementBoundaryOptions()).FirstOrDefault();
using (Transaction ts = new Transaction(doc, "模型线创建"))
doc.Invoke(ts =>
{
ts.Start();
foreach (var seg in segments)
foreach (var segment in segments)
{
Curve cur = seg.GetCurve();
Curve curve = segment.GetCurve();
Plane plane = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ());
var mc = doc.Create.NewModelCurve(cur, SketchPlane.Create(doc, plane));
var mc = doc.Create.NewModelCurve(curve, SketchPlane.Create(doc, plane));
modelCurveIds.Add(mc.Id);
}
}, "模型线创建");
ts.Commit();
}
//Reference edge = uidoc.Selection.PickObject(ObjectType.Edge, "请选择边界");
SelectFilter<ModelLine> mlfilter = new SelectFilter<ModelLine>();
Reference refline = uidoc.Selection.PickObject(ObjectType.Element, mlfilter, "请选择基准边线");
Reference referline = uidoc.Selection.PickObject(ObjectType.Element, mlfilter, "请选择基准边线");
//模型线选取
var ml = doc.GetElement(refline) as ModelLine;
var ml = doc.GetElement(referline) as ModelLine;
Line line = ml.GeometryCurve as Line;
Line line1 = RsRevitUtils.GetLongestSegmentLine(segments, line);
//var m = doc.GetElement(refer.ElementId);
XYZ basepoint = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择基准点(位于基准线上)");
double alength = basepoint.DistanceTo(line.GetEndPoint(0)) + basepoint.DistanceTo(line.GetEndPoint(1));
if (line.Length - alength > 0.001)
XYZ basePoint = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选择基准点(位于基准线上)");
double lengthCount = basePoint.DistanceTo(line.GetEndPoint(0)) + basePoint.DistanceTo(line.GetEndPoint(1));
if (line.Length - lengthCount > 0.001)
{
System.Windows.MessageBox.Show("请选择基准线上的点", "温馨提示");
return Result.Cancelled;
@@ -109,11 +106,11 @@ namespace RookieStation.PackAreaModule
//if (basepoint.IsAlmostEqualTo(ml.GeometryCurve.GetEndPoint(0)) || basepoint.IsAlmostEqualTo(ml.GeometryCurve.GetEndPoint(1)))
//{
//}
var endp1 = line.GetEndPoint(0);
var endp2 = line.GetEndPoint(1);
var v1 = endp1 - basepoint;
var v2 = endp2 - basepoint;
var v0 = roompoint - basepoint;
var endpoint1 = line.GetEndPoint(0);
var endpoint2 = line.GetEndPoint(1);
var v1 = endpoint1 - basePoint;
var v2 = endpoint2 - basePoint;
var v0 = roomLocationPoint - basePoint;
List<Curve> curves = new List<Curve>();
List<FamilyInstance> instances = new List<FamilyInstance>();
//Curve currefer = null;
@@ -123,9 +120,9 @@ namespace RookieStation.PackAreaModule
List<XYZ> lastps = new List<XYZ>();
XYZ zdir1 = null;
XYZ zdir2 = null;
XYZ offestvector = null;
XYZ offestVector = null;
if (!v1.IsAlmostEqualTo(XYZ.Zero) && endp1.DistanceTo(basepoint) > interval)
if (!v1.IsAlmostEqualTo(XYZ.Zero) && endpoint1.DistanceTo(basePoint) > interval)
{
//if (endp1.DistanceTo(basepoint) < interval)
//{
@@ -134,28 +131,28 @@ namespace RookieStation.PackAreaModule
//}
zdir1 = v1.CrossProduct(v0).Normalize();
//偏移的方向,直线的侧方向
offestvector = zdir1.CrossProduct(v1).Normalize();
Line l1 = Line.CreateBound(basepoint, line.GetEndPoint(0));
offestVector = zdir1.CrossProduct(v1).Normalize();
Line l1 = Line.CreateBound(basePoint, line.GetEndPoint(0));
for (int i = 0; i < 1000; i++)
{
var parameter = i * interval;
if (!l1.IsInside(parameter + lrdistance + interval / 2))
if (!l1.IsInside(parameter + leftRightDistance + interval / 2))
{
break;
}
XYZ p = l1.Evaluate(parameter, false);
XYZ finalpoint = p + (l1.Direction * interval / 2) + (offestvector * fbdistance);
XYZ finalPoint = p + (l1.Direction * interval / 2) + (offestVector * frontDistance);
if (v2.IsAlmostEqualTo(XYZ.Zero))
{
finalpoint = p + (l1.Direction * lrdistance) + (offestvector * fbdistance);
finalPoint = p + (l1.Direction * leftRightDistance) + (offestVector * frontDistance);
}
pts.Add(finalpoint);
pts.Add(finalPoint);
}
}
if (!v2.IsAlmostEqualTo(XYZ.Zero) && endp2.DistanceTo(basepoint) > interval)
if (!v2.IsAlmostEqualTo(XYZ.Zero) && endpoint2.DistanceTo(basePoint) > interval)
{
//if (endp2.DistanceTo(basepoint) < length)
//{
@@ -163,23 +160,23 @@ namespace RookieStation.PackAreaModule
// return Result.Cancelled;
//}
zdir2 = v2.CrossProduct(v0).Normalize();
offestvector = zdir2.CrossProduct(v2).Normalize();
offestVector = zdir2.CrossProduct(v2).Normalize();
var x = zdir2.CrossProduct(v2);
Line l2 = Line.CreateBound(basepoint, line.GetEndPoint(1));
Line l2 = Line.CreateBound(basePoint, line.GetEndPoint(1));
for (int i = 0; i < 1000; i++)
{
var parameter = i * interval;
if (!l2.IsInside(parameter + lrdistance + interval / 2))
if (!l2.IsInside(parameter + leftRightDistance + interval / 2))
{
break;
}
XYZ p = l2.Evaluate(parameter, false);
//附加的基准线的水平垂直偏移距离
var finalpoint = p + (l2.Direction * interval / 2) + (offestvector * fbdistance);
var finalpoint = p + (l2.Direction * interval / 2) + (offestVector * frontDistance);
if (v1.IsAlmostEqualTo(XYZ.Zero))
{
finalpoint = p + (l2.Direction * lrdistance) + (offestvector * fbdistance);
finalpoint = p + (l2.Direction * leftRightDistance) + (offestVector * frontDistance);
}
pts.Add(finalpoint);
@@ -187,9 +184,8 @@ namespace RookieStation.PackAreaModule
//var lastl2 = pts.Last().DistanceTo(endp2);
}
using (Transaction trans = new Transaction(doc, "载入布置灯具"))
doc.Invoke(ts =>
{
trans.Start();
//删除模型线
doc.Delete(modelCurveIds);
family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Lamp\\成品吊灯.rfa");
@@ -199,45 +195,40 @@ namespace RookieStation.PackAreaModule
foreach (var p in pts)
{
var fi = doc.Create
.NewFamilyInstance(p, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
.NewFamilyInstance(p, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instances.Add(fi);
}
foreach (var p in lastps)
{
var fi = doc.Create
.NewFamilyInstance(p, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
.NewFamilyInstance(p, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instances.Add(fi);
}
trans.Commit();
}
using (Transaction trans = new Transaction(doc, "复制灯具"))
}, "载入布置灯具");
doc.Invoke(ts =>
{
trans.Start();
for (int i = 0; i < instances.Count; i++)
{
FamilyInstance fi = instances[i];
int num = (int)Math.Floor((line1.Length - 2 * fbdistance) / interval);
int num = (int)Math.Floor((line1.Length - 2 * frontDistance) / interval);
double rem = line1.Length - num * interval;
for (int j = 1; j <= num; j++)
{
ElementTransformUtils.CopyElement(doc, fi.Id, offestvector * interval * j);
ElementTransformUtils.CopyElement(doc, fi.Id, offestVector * interval * j);
}
}
trans.Commit();
}
tg.Assimilate();
}, "复制灯具");
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
if (tg.GetStatus() == TransactionStatus.Started)
{
tg.RollBack();
}
return Result.Cancelled;
}
}
//if (tg.GetStatus() == TransactionStatus.Started)
//{
// tg.RollBack();
//}
return Result.Succeeded;
}
return Result.Succeeded;
}, "布置灯具");
}
}
}

View File

@@ -49,93 +49,96 @@ namespace RookieStation.ShippingAreaModule
WpfReceptionArea receptionAreaPlacement = CommonUtils.GenerateWindow<WpfReceptionArea>();
//初始值
//基层厚度
double base_layer_thickness = 15 / 304.8;
double baseLayerThickness = 15 / 304.8;
//踢脚线高度
double Skirting_line_height = 50 / 304.8;
double skirtingLineHeight = 50 / 304.8;
//踢脚线厚度
double Skirting_line_thickness = 1.2 / 304.8;
double skirtingLineThickness = 1.2 / 304.8;
//铝塑板长度
double aluminum_plastic_panel_length = 1220 / 304.8;
double aluminumPlasticPanelLength = 0;
//铝塑板高度
double aluminum_plastic_panel_height = 2400 / 304.8;
double aluminumPlasticPanelHeight = 0;
//铝塑板厚度
double aluminum_plastic_panel_thickness = 3 / 304.8;
double aluminumPlasticPanelThickness = 3 / 304.8;
//分缝
double gap = 2 / 304.8;
//灰色乳胶漆厚度
double grey_emulsion_paint_width = 1 / 304.8;
double greyEmulsionPaintWidth = 1 / 304.8;
//发光字族类型
string glow_text_symbol;
string glowTextSymbol;
//墙间距
double lamps_wall_distance = 900 / 304.8;
double lampsWallDistance = 0;
//灯间距
double lamps_interval = 900 / 304.8;
double lampsInterval = 0;
//灯高度
double lampsHeight = 0;
if (receptionAreaPlacement.DialogResult == true)
{
//铝塑板长度
aluminum_plastic_panel_length = receptionAreaPlacement.aluminump_lastic_panel_length / 304.8;
aluminumPlasticPanelLength = receptionAreaPlacement.AluminumpLasticPanelLength / 304.8;
//铝塑板高度
aluminum_plastic_panel_height = receptionAreaPlacement.aluminump_lastic_panel_height / 304.8;
aluminumPlasticPanelHeight = receptionAreaPlacement.AluminumpLasticPanelHeight / 304.8;
//分缝
gap = receptionAreaPlacement.aluminump_lastic_panel_gap / 304.8;
gap = receptionAreaPlacement.AluminumpLasticPanelGgap / 304.8;
glow_text_symbol = receptionAreaPlacement.glow_text_symbol;
glowTextSymbol = receptionAreaPlacement.GlowTextSymbol;
lamps_wall_distance = receptionAreaPlacement.lamp_wall_distance / 304.8;
lamps_interval = receptionAreaPlacement.lamps_interval / 304.8;
lampsWallDistance = receptionAreaPlacement.LampWallDistance / 304.8;
lampsInterval = receptionAreaPlacement.LampsInterval / 304.8;
lampsHeight = receptionAreaPlacement.LampsHeight / 304.8;
}
else
{
return Result.Cancelled;
}
Level baselevel = uidoc.ActiveView.GenLevel;
Level baseLevel = uidoc.ActiveView.GenLevel;
Family family = null;
FamilySymbol symbol;
return doc.InvokeGroup<Result>(tg =>
{
try
{
FamilySymbol linesymbol = RsRevitUtils.GetGuideSymbol(doc);
FamilySymbol guideSymbol = RsRevitUtils.GetGuideSymbol(doc);
eleIdsAdded.Clear();
uiapp.Application.DocumentChanged += Application_DocumentChanged;
uidoc.PromptForFamilyInstancePlacement(linesymbol);
uidoc.PromptForFamilyInstancePlacement(guideSymbol);
uiapp.Application.DocumentChanged -= Application_DocumentChanged;
//在此处无法取消订阅
//uiapp.Application.DocumentChanged -= Application_DocumentChanged;
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
var interval = gap + aluminum_plastic_panel_length;
var interval = gap + aluminumPlasticPanelLength;
if (eleIdsAdded.Count == 0)
{
return Result.Cancelled;
}
Line refer_line = RsRevitUtils.GetGuideGeometryAndDeleteGuide(doc, eleIdsAdded);
Line referline = RsRevitUtils.GetGuideGeometryAndDeleteGuide(doc, eleIdsAdded);
uiapp.Application.DocumentChanged -= Application_DocumentChanged;
double backgroundwall_length = refer_line.Length;
if (backgroundwall_length < 1500 / 304.8)
double backgroundWallLength = referline.Length;
if (backgroundWallLength < 1500 / 304.8)
{
TaskDialog.Show("温馨提示", "距离太接");
return Result.Cancelled;
}
List<ElementId> wallids = new List<ElementId>();
WallType base_layer_type = null;
base_layer_thickness = RsRevitUtils.GetWallWidthByWallTypeName(doc, "阻燃板", out base_layer_type);
List<ElementId> wallIds = new List<ElementId>();
WallType baseLayerType = null;
baseLayerThickness = RsRevitUtils.GetWallWidthByWallTypeName(doc, "阻燃板", out baseLayerType);
WallType grey_emulsion_paint_type = null;
grey_emulsion_paint_width = RsRevitUtils.GetWallWidthByWallTypeName(doc, "灰色乳胶漆", out grey_emulsion_paint_type);
WallType greyEmulsionPaintType = null;
greyEmulsionPaintWidth = RsRevitUtils.GetWallWidthByWallTypeName(doc, "灰色乳胶漆", out greyEmulsionPaintType);
WallType aluminum_plastic_panel_type = null;
aluminum_plastic_panel_thickness = RsRevitUtils.GetWallWidthByWallTypeName(doc, "铝塑板", out aluminum_plastic_panel_type);
WallType aluminumPlasticPanelType = null;
aluminumPlasticPanelThickness = RsRevitUtils.GetWallWidthByWallTypeName(doc, "铝塑板", out aluminumPlasticPanelType);
WallType Skirting_line_type = null;
Skirting_line_thickness = RsRevitUtils.GetWallWidthByWallTypeName(doc, "踢脚线", out Skirting_line_type);
WallType skirtingLineType = null;
skirtingLineThickness = RsRevitUtils.GetWallWidthByWallTypeName(doc, "踢脚线", out skirtingLineType);
//铝塑板块数
int n = (int)Math.Floor(refer_line.Length / interval);
double rem = refer_line.Length % (gap + aluminum_plastic_panel_length);
if (base_layer_type == null || aluminum_plastic_panel_type == null || Skirting_line_type == null || grey_emulsion_paint_type == null)
int n = (int)Math.Floor(referline.Length / interval);
double rem = referline.Length % (gap + aluminumPlasticPanelLength);
if (baseLayerType == null || aluminumPlasticPanelType == null || skirtingLineType == null || greyEmulsionPaintType == null)
{
TaskDialog.Show("温馨提示", "需要新建装饰所需的墙类型,类型名称需分别包含阻燃板,灰色乳胶漆,铝塑板,踢脚线");
return Result.Cancelled;
@@ -145,76 +148,51 @@ namespace RookieStation.ShippingAreaModule
//长度不满足设置的铝塑板长度时
if (n == 0)
{
var offestline = refer_line.CreateOffset(aluminum_plastic_panel_thickness / 2 + base_layer_thickness, -XYZ.BasisZ);
var wall = Wall.Create(doc, offestline, aluminum_plastic_panel_type.Id, doc.ActiveView.GenLevel.Id, aluminum_plastic_panel_height, Skirting_line_height, false, false);
wallids.Add(wall.Id);
var offestline = referline.CreateOffset(aluminumPlasticPanelThickness / 2 + baseLayerThickness, -XYZ.BasisZ);
var wall = Wall.Create(doc, offestline, aluminumPlasticPanelType.Id, doc.ActiveView.GenLevel.Id, aluminumPlasticPanelHeight, skirtingLineHeight, false, false);
wallIds.Add(wall.Id);
}
else
{
for (int i = 0; i < n + 1; i++)
{
var startpoint = refer_line.Evaluate(i * interval, false);
var endpoint = refer_line.Evaluate(((i + 1) * interval) - gap, false);
var startpoint = referline.Evaluate(i * interval, false);
var endpoint = referline.Evaluate(((i + 1) * interval) - gap, false);
if (i == n)
{
endpoint = refer_line.GetEndPoint(1);
endpoint = referline.GetEndPoint(1);
}
Line line = Line.CreateBound(startpoint, endpoint);
var offestline = line.CreateOffset(aluminum_plastic_panel_thickness / 2 + base_layer_thickness, -XYZ.BasisZ);
var wall = Wall.Create(doc, offestline, aluminum_plastic_panel_type.Id, doc.ActiveView.GenLevel.Id, aluminum_plastic_panel_height, Skirting_line_height, false, false);
var offestline = line.CreateOffset(aluminumPlasticPanelThickness / 2 + baseLayerThickness, -XYZ.BasisZ);
var wall = Wall.Create(doc, offestline, aluminumPlasticPanelType.Id, doc.ActiveView.GenLevel.Id, aluminumPlasticPanelHeight, skirtingLineHeight, false, false);
//不允许连接
WallUtils.DisallowWallJoinAtEnd(wall, 0);
//curves.Add()
wallids.Add(wall.Id);
wallIds.Add(wall.Id);
}
}
var skirting_offestline = refer_line.CreateOffset(Skirting_line_thickness / 2 + base_layer_thickness, -XYZ.BasisZ);
var skirtingwall = Wall.Create(doc, skirting_offestline, Skirting_line_type.Id, doc.ActiveView.GenLevel.Id, Skirting_line_height, 0, false, false);
wallids.Add(skirtingwall.Id);
var skirtingOffestLine = referline.CreateOffset(skirtingLineThickness / 2 + baseLayerThickness, -XYZ.BasisZ);
var skirtingwall = Wall.Create(doc, skirtingOffestLine, skirtingLineType.Id, doc.ActiveView.GenLevel.Id, skirtingLineHeight, 0, false, false);
wallIds.Add(skirtingwall.Id);
var base_layer_offestline = refer_line.CreateOffset(base_layer_thickness / 2, -XYZ.BasisZ);
var baselayerwall = Wall.Create(doc, base_layer_offestline, base_layer_type.Id, doc.ActiveView.GenLevel.Id, UserConstant.Height / 304.8, 0, false, false);
wallids.Add(baselayerwall.Id);
var baseLayerOffestLine = referline.CreateOffset(baseLayerThickness / 2, -XYZ.BasisZ);
var baseLayerWall = Wall.Create(doc, baseLayerOffestLine, baseLayerType.Id, doc.ActiveView.GenLevel.Id, UserConstant.Height / 304.8, 0, false, false);
wallIds.Add(baseLayerWall.Id);
//高度大于3000才有灰色乳胶漆
if (UserConstant.Height > 3000)
{
double baseheight = aluminum_plastic_panel_height + Skirting_line_height;
var grey_emulsion_paint_offestline = refer_line.CreateOffset(base_layer_thickness + grey_emulsion_paint_width / 2, -XYZ.BasisZ);
var greypaintwall = Wall.Create(doc, grey_emulsion_paint_offestline, grey_emulsion_paint_type.Id, doc.ActiveView.GenLevel.Id, UserConstant.Height / 304.8 - baseheight, baseheight, false, false);
wallids.Add(greypaintwall.Id);
double baseHeight = aluminumPlasticPanelHeight + skirtingLineHeight;
var greyEmulsionPaintOffestLine = referline.CreateOffset(baseLayerThickness + greyEmulsionPaintWidth / 2, -XYZ.BasisZ);
Wall greyPaintWall = Wall.Create(doc, greyEmulsionPaintOffestLine, greyEmulsionPaintType.Id, doc.ActiveView.GenLevel.Id, UserConstant.Height / 304.8 - baseHeight, baseHeight, false, false);
wallIds.Add(greyPaintWall.Id);
}
doc.Regenerate();
doc.Create.NewGroup(wallids);
doc.Create.NewGroup(wallIds);
}, "背景墙创建");
//SelectFilter<Wall> wallfilter = new SelectFilter<Wall>();
//var wallrefer = uidoc.Selection.PickObject(ObjectType.Element, wallfilter, "请选择作为背景墙的墙体");
//var wall = doc.GetElement(wallrefer) as Wall;
//WallFaceSelectionFilter selfilter = new WallFaceSelectionFilter(wall.Id);
//var facerefer = uidoc.Selection.PickObject(ObjectType.Face, selfilter, "请选择要装饰的墙面");
//PlanarFace pf = wall.GetGeometryObjectFromReference(facerefer) as PlanarFace;
//XYZ normal = pf.FaceNormal;
//XYZ p1 = uidoc.Selection.PickObject(ObjectType.PointOnElement, selfilter, "请选取背景墙左侧端点").GlobalPoint;
//XYZ p2 = uidoc.Selection.PickObject(ObjectType.PointOnElement, selfilter, "请选取背景墙右侧端点").GlobalPoint;
//XYZ p1 = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选取背景墙左侧端点");
//XYZ p2 = uidoc.Selection.PickPoint(UserConstant.SnapAll, "请选取背景墙右侧端点");
//两点的水平距离
//if (UserConstant.Height / 3 * 2 < 2200)
//{
// TaskDialog.Show("温馨提示", "层高设置有误");
// return Result.Cancelled;
//}
#region 使
FamilyInstance signage = null;
@@ -225,27 +203,22 @@ namespace RookieStation.ShippingAreaModule
symbol = doc.GetElement(symbolId) as FamilySymbol;
symbol.Activate();
//var x = family.FamilyPlacementType;
//signage = doc.Create.NewFamilyInstance(facerefer, p2 + new XYZ(0, 0, height + 100 / 304.8), symbol, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
var endPoint = referline.GetEndPoint(0);
var endpoint = refer_line.GetEndPoint(0);
endpoint += (Skirting_line_height + aluminum_plastic_panel_height) * XYZ.BasisZ;
signage = doc.Create.NewFamilyInstance(endpoint, symbol, StructuralType.NonStructural);
endPoint += (skirtingLineHeight + aluminumPlasticPanelHeight) * XYZ.BasisZ;
signage = doc.Create.NewFamilyInstance(endPoint, symbol, StructuralType.NonStructural);
//标准面要朝上,族要面向背侧
//symbol.GetParameters("背景墙长度").FirstOrDefault().Set(distance);
}, "菜鸟的使命");
doc.Invoke(ts =>
{
//族的正面要超前
RsRevitUtils.AdjustInstance(doc, signage, refer_line, grey_emulsion_paint_width + base_layer_thickness);
RsRevitUtils.AdjustInstance(doc, signage, referline, greyEmulsionPaintWidth + baseLayerThickness);
}, "调整菜鸟使命");
#endregion 使
double reception_length = refer_line.Length / 3 * 2;
double reception_wall_distance = 1000 / 304.8;
double receptionLength = referline.Length / 3 * 2;
double receptionWallDistance = 1000 / 304.8;
FamilyInstance reception = null;
doc.Invoke(ts =>
{
@@ -253,48 +226,48 @@ namespace RookieStation.ShippingAreaModule
ElementId symbolId = family.GetFamilySymbolIds().FirstOrDefault();
symbol = doc.GetElement(symbolId) as FamilySymbol;
symbol.Activate();
var wall_center_point = refer_line.Evaluate(0.5, true);
var wallCenterPoint = referline.Evaluate(0.5, true);
reception = doc.Create.NewFamilyInstance(wall_center_point, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
reception = doc.Create.NewFamilyInstance(wallCenterPoint, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
symbol.GetParameters("台面长度").FirstOrDefault().Set(reception_length);
symbol.GetParameters("台面长度").FirstOrDefault().Set(receptionLength);
//symbol.GetParameters("台面长度").FirstOrDefault().AsDouble();
}, "接待台布置");
doc.Invoke(ts =>
{
RsRevitUtils.AdjustInstance(doc, reception, refer_line, reception_wall_distance);
RsRevitUtils.AdjustInstance(doc, reception, referline, receptionWallDistance);
}, "调整接待台");
FamilyInstance logo = null;
doc.Invoke(ts =>
{
family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Sign\\菜鸟LOGO.rfa");
ElementId symbolId = family.GetFamilySymbolIds().FirstOrDefault(id => doc.GetElement(id).Name == glow_text_symbol);
ElementId symbolId = family.GetFamilySymbolIds().FirstOrDefault(id => doc.GetElement(id).Name == glowTextSymbol);
symbol = doc.GetElement(symbolId) as FamilySymbol;
symbol.Activate();
var wall_center_point = refer_line.Evaluate(0.5, true);
var wallCenterPoint = referline.Evaluate(0.5, true);
logo = doc.Create.NewFamilyInstance(wall_center_point, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
logo = doc.Create.NewFamilyInstance(wallCenterPoint, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
//symbol.GetParameters("背景墙长度").FirstOrDefault().Set(reception_length);
//width = symbol.GetParameters("台面宽度").FirstOrDefault().AsDouble();
}, "菜鸟LOG布置");
doc.Invoke(ts =>
{
RsRevitUtils.AdjustInstance(doc, logo, refer_line, aluminum_plastic_panel_thickness + base_layer_thickness);
RsRevitUtils.AdjustInstance(doc, logo, referline, aluminumPlasticPanelThickness + baseLayerThickness);
}, "调整lOGO");
doc.Invoke(ts =>
{
family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Lamp\\圆形吊灯.rfa");
family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Lamp\\吊灯.rfa");
ElementId symbolId = family.GetFamilySymbolIds().FirstOrDefault();
symbol = doc.GetElement(symbolId) as FamilySymbol;
symbol.Activate();
var normal_direction = refer_line.Direction;
List<XYZ> lamp_location_points = new List<XYZ>();
var lamps_location_line = refer_line.CreateOffset(lamps_wall_distance, -XYZ.BasisZ);
var center_point = lamps_location_line.Evaluate(0.5, true);
n = (int)Math.Floor(backgroundwall_length / lamps_interval);
var referlineDirection = referline.Direction;
List<XYZ> lampLocationPoints = new List<XYZ>();
var lampsLocationLine = referline.CreateOffset(lampsWallDistance, -XYZ.BasisZ);
var centerPoint = lampsLocationLine.Evaluate(0.5, true);
n = (int)Math.Floor(backgroundWallLength / lampsInterval);
//单侧的数量
int m = (int)Math.Floor((n + 1.0) / 2);
if ((n + 1) % 2 == 0)
@@ -302,48 +275,34 @@ namespace RookieStation.ShippingAreaModule
//开始间隔为0.5
for (int i = 0; i < m; i++)
{
XYZ p = center_point.Add(normal_direction * (i + 0.5) * lamps_interval);
XYZ reversep = center_point.Add(-normal_direction * (i + 0.5) * lamps_interval);
XYZ p = centerPoint.Add(referlineDirection * (i + 0.5) * lampsInterval) + XYZ.BasisZ * lampsHeight;
XYZ reversePoint = centerPoint.Add(-referlineDirection * (i + 0.5) * lampsInterval) + XYZ.BasisZ * lampsHeight;
lamp_location_points.Add(p);
lamp_location_points.Add(reversep);
lampLocationPoints.Add(p);
lampLocationPoints.Add(reversePoint);
}
foreach (XYZ p in lamp_location_points)
foreach (XYZ p in lampLocationPoints)
{
doc.Create.NewFamilyInstance(p, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
doc.Create.NewFamilyInstance(p, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
}
}
else
{
lamp_location_points.Add(center_point);
lampLocationPoints.Add(centerPoint);
//i=0时居中不在单侧,开始间隔为1
for (int i = 0; i < m; i++)
{
XYZ p = center_point.Add(normal_direction * (i + 1) * lamps_interval);
XYZ reversep = center_point.Add(-normal_direction * (i + 1) * lamps_interval);
lamp_location_points.Add(p);
lamp_location_points.Add(reversep);
XYZ p = centerPoint.Add(referlineDirection * (i + 1) * lampsInterval);
XYZ reversePoint = centerPoint.Add(-referlineDirection * (i + 1) * lampsInterval);
lampLocationPoints.Add(p);
lampLocationPoints.Add(reversePoint);
}
foreach (XYZ p in lamp_location_points)
foreach (XYZ p in lampLocationPoints)
{
doc.Create.NewFamilyInstance(p, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
doc.Create.NewFamilyInstance(p, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
}
}
}, "吊灯布置");
//doc.Invoke(ts =>
//{
// if (backgroundwall.CanFlipFacing && backgroundwall.CanFlipHand && !backgroundwall.FacingOrientation.IsAlmostEqualTo(normal))
// {
// backgroundwall.flipFacing();
// backgroundwall.flipHand();
// }
// if (frontdesk.CanFlipFacing && backgroundwall.CanFlipHand && !frontdesk.FacingOrientation.IsAlmostEqualTo(normal))
// {
// frontdesk.flipFacing();
// frontdesk.flipHand();
// }
//}, "调整");
}
return Result.Succeeded;
@@ -392,37 +351,17 @@ namespace RookieStation.ShippingAreaModule
private Reference GetWallSideFaceReference(Wall wall, XYZ normal)
{
var facerefer = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Interior).FirstOrDefault();
var facerefer1 = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior).FirstOrDefault();
var interFaceReference = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Interior).FirstOrDefault();
var exterFaceReference = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior).FirstOrDefault();
PlanarFace pf = wall.GetGeometryObjectFromReference(facerefer) as PlanarFace;
PlanarFace pf = wall.GetGeometryObjectFromReference(interFaceReference) as PlanarFace;
if (pf.FaceNormal.IsAlmostEqualTo(normal))
{
return facerefer;
return interFaceReference;
}
else
{
return facerefer1;
}
}
public class WallFaceSelectionFilter : ISelectionFilter
{
private ElementId eid = null;
public WallFaceSelectionFilter(ElementId elementId)
{
eid = elementId;
}
public bool AllowElement(Element element)
{
return element is Wall && eid == element.Id;
}
public bool AllowReference(Reference refer, XYZ point)
{
return true;
return exterFaceReference;
}
}
}

View File

@@ -73,126 +73,126 @@ namespace RookieStation.PackAreaModule
{
return Result.Cancelled;
}
Line refer_line = RsRevitUtils.GetGuideGeometryAndDeleteGuide(doc, eleIdsAdded);
Line referline = RsRevitUtils.GetGuideGeometryAndDeleteGuide(doc, eleIdsAdded);
uiapp.Application.DocumentChanged -= Application_DocumentChanged;
//始终位于左侧,Z轴朝上
var zaxis = XYZ.BasisZ;
Family shelf_family = null;
FamilySymbol shelf_symbol = null;
double shelf_spacing = vm.Spacing / 304.8;
var zAxis = XYZ.BasisZ;
Family shelfFamily = null;
FamilySymbol shelfSymbol = null;
double shelfSpacing = vm.ShelfSpacing / 304.8;
//通道宽度
double passage_width = vm.PassageWidth / 304.8;
double parallel_referline_offest = vm.ParalelReferOffest / 304.8;
double vertical_referline_offest = vm.VerticalReferOffest / 304.8;
double passageWidth = vm.PassageWidth / 304.8;
double parallelReferlineOffest = vm.ParallelReferlineOffest / 304.8;
double verticalReferlineOffest = vm.VerticalReferlineOffest / 304.8;
for (int i = 0; i < shelves.Count; i++)
{
//List<XYZ> all_points = new List<XYZ>();
List<XYZ> first_row_points = new List<XYZ>();
List<XYZ> firstRowPoints = new List<XYZ>();
Shelf shelf = shelves[i];
double shelf_width = shelf.Width / 304.8;
double line_parameter = 0.0;
double shelfWidth = shelf.Width / 304.8;
double lineParameter = 0.0;
int n = 100;//循环次数
XYZ p = XYZ.Zero;
XYZ pointOnReferline = XYZ.Zero;
if (parallel_referline_offest < 0.001)//起点无间距
if (parallelReferlineOffest < 0.001)//起点无间距
{
for (int j = 0; j < n; j++)
{
if (!refer_line.IsInside((line_parameter + shelf_width)))
if (!referline.IsInside((lineParameter + shelfWidth)))
{
break;
}
if (j % 2 == 0)
{
p = refer_line.Evaluate(line_parameter, false);
line_parameter += shelf_spacing + shelf_width;
pointOnReferline = referline.Evaluate(lineParameter, false);
lineParameter += shelfSpacing + shelfWidth;
}
else
{
p = refer_line.Evaluate(line_parameter, false);
line_parameter += shelf_width;
pointOnReferline = referline.Evaluate(lineParameter, false);
lineParameter += shelfWidth;
}
first_row_points.Add(p);
firstRowPoints.Add(pointOnReferline);
}
}
else//起点有距离
{
line_parameter = parallel_referline_offest;
lineParameter = parallelReferlineOffest;
for (int j = 0; j < n; j++)
{
if (!refer_line.IsInside(line_parameter + shelf_width))
if (!referline.IsInside(lineParameter + shelfWidth))
{
break;
}
if (j % 2 == 0)
{
p = refer_line.Evaluate(line_parameter, false);
line_parameter += shelf_width;
pointOnReferline = referline.Evaluate(lineParameter, false);
lineParameter += shelfWidth;
}
else
{
p = refer_line.Evaluate(line_parameter, false);
line_parameter += shelf_spacing + shelf_width;
pointOnReferline = referline.Evaluate(lineParameter, false);
lineParameter += shelfSpacing + shelfWidth;
}
first_row_points.Add(p);
firstRowPoints.Add(pointOnReferline);
}
}
double l = shelf.Length / 304.8;
XYZ normal_vertical_offest_vector = zaxis.CrossProduct(refer_line.Direction).Normalize();
XYZ normalVerticalOffestVector = zAxis.CrossProduct(referline.Direction).Normalize();
List<FamilyInstance> instances = new List<FamilyInstance>();
XYZ final_point = XYZ.Zero;
XYZ finalPoint = XYZ.Zero;
doc.Invoke(ts =>
{
shelf_family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Shelf\\单联货架.rfa");
var shelf_symbol_ids = shelf_family.GetFamilySymbolIds();
foreach (var id in shelf_symbol_ids)
shelfFamily = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Shelf\\单联货架.rfa");
var shelfSymbolIds = shelfFamily.GetFamilySymbolIds();
foreach (var id in shelfSymbolIds)
{
FamilySymbol temp_symbol = doc.GetElement(id) as FamilySymbol;
if (temp_symbol.Name == shelf.SymbolName)
FamilySymbol tempSymbol = doc.GetElement(id) as FamilySymbol;
if (tempSymbol.Name == shelf.SymbolName)
{
shelf_symbol = temp_symbol;
shelfSymbol = tempSymbol;
break;
}
}
shelf_symbol.Activate();
shelfSymbol.Activate();
}, "加载货架,激活类型");
switch (shelf.NumOfGroup)
{
case NumOfGroup.Single:
for (int j = 0; j < first_row_points.Count; j++)
for (int j = 0; j < firstRowPoints.Count; j++)
{
XYZ pt = first_row_points[j];
XYZ offest_direction = normal_vertical_offest_vector * (vertical_referline_offest + l / 2);
XYZ tempPoint = firstRowPoints[j];
XYZ offestVector = normalVerticalOffestVector * (verticalReferlineOffest + l / 2);
//垂直基准线平移 平行基准线平移
final_point = pt + offest_direction + refer_line.Direction * shelf_width / 2;
finalPoint = tempPoint + offestVector + referline.Direction * shelfWidth / 2;
//附加通道和(单联、多联)货架长度的偏移
if (i > 0)
{
double total_length = GetTotalLength(shelves, i);
double totalLength = GetTotalLength(shelves, i);
//附加排在前面通道和所有货架的长度
XYZ additional_dir = normal_vertical_offest_vector * (i * passage_width + total_length);
final_point += additional_dir;
XYZ additional_dir = normalVerticalOffestVector * (i * passageWidth + totalLength);
finalPoint += additional_dir;
}
FamilyInstance instance = null;
//all_points.Add(final_point);
doc.Invoke(ts =>
{
instance = doc.Create.NewFamilyInstance(final_point, shelf_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instance = doc.Create.NewFamilyInstance(finalPoint, shelfSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instances.Add(instance);
}, "创建货架");
//位于直线右侧时,需要进行左右翻转
doc.Invoke(ts =>
{
if (parallel_referline_offest < 0.001)
if (parallelReferlineOffest < 0.001)
{
if (j % 2 != 0 && instance.CanFlipHand)
{
@@ -213,49 +213,49 @@ namespace RookieStation.PackAreaModule
case NumOfGroup.Double:
for (int j = 0; j < first_row_points.Count; j++)
for (int j = 0; j < firstRowPoints.Count; j++)
{
XYZ pt = first_row_points[j];
XYZ tempPoint = firstRowPoints[j];
//偏移距离
XYZ offest_direction = normal_vertical_offest_vector * (vertical_referline_offest + l);
XYZ offestVector = normalVerticalOffestVector * (verticalReferlineOffest + l);
//基础偏移距离,移动半个长度到直线的一侧,垂直基准线平移 平行基准线平移
final_point = pt + offest_direction + refer_line.Direction * shelf_width / 2;
finalPoint = tempPoint + offestVector + referline.Direction * shelfWidth / 2;
//附加通道和(单联、多联)货架长度的偏移
if (i > 0)
{
double totallength = GetTotalLength(shelves, i);
XYZ additionaldir = normal_vertical_offest_vector * (i * passage_width + totallength);
final_point += additionaldir;
XYZ additionaldir = normalVerticalOffestVector * (i * passageWidth + totallength);
finalPoint += additionaldir;
}
FamilyInstance end_instance = null;
FamilyInstance start_instance = null;
FamilyInstance endInstance = null;
FamilyInstance startInstance = null;
doc.Invoke(ts =>
{
end_instance = doc.Create.NewFamilyInstance(final_point + l / 2 * normal_vertical_offest_vector, shelf_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
endInstance = doc.Create.NewFamilyInstance(finalPoint + l / 2 * normalVerticalOffestVector, shelfSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
start_instance = doc.Create.NewFamilyInstance(final_point - l / 2 * normal_vertical_offest_vector, shelf_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
startInstance = doc.Create.NewFamilyInstance(finalPoint - l / 2 * normalVerticalOffestVector, shelfSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instances.Add(start_instance);
instances.Add(startInstance);
instances.Add(end_instance);
instances.Add(endInstance);
}, "创建货架");
doc.Invoke(ts =>
{
if (parallel_referline_offest < 0.001)
if (parallelReferlineOffest < 0.001)
{
if (j % 2 != 0 && start_instance.CanFlipHand && end_instance.CanFlipHand)
if (j % 2 != 0 && startInstance.CanFlipHand && endInstance.CanFlipHand)
{
start_instance.flipHand();
end_instance.flipHand();
startInstance.flipHand();
endInstance.flipHand();
}
}
else
{
if (j % 2 == 0 && start_instance.CanFlipHand && end_instance.CanFlipHand)
if (j % 2 == 0 && startInstance.CanFlipHand && endInstance.CanFlipHand)
{
start_instance.flipHand();
end_instance.flipHand();
startInstance.flipHand();
endInstance.flipHand();
}
}
}, "翻转货架");
@@ -267,34 +267,34 @@ namespace RookieStation.PackAreaModule
case NumOfGroup.Three:
for (int j = 0; j < first_row_points.Count; j++)
for (int j = 0; j < firstRowPoints.Count; j++)
{
XYZ pt = first_row_points[j];
XYZ offestdir = normal_vertical_offest_vector * (vertical_referline_offest + l * 3 / 2);
XYZ tempPoint = firstRowPoints[j];
XYZ offestVector = normalVerticalOffestVector * (verticalReferlineOffest + l * 3 / 2);
//垂直基准线平移 平行基准线平移
final_point = pt + offestdir + refer_line.Direction * shelf_width / 2;
finalPoint = tempPoint + offestVector + referline.Direction * shelfWidth / 2;
//附加通道和(单联、多联)货架长度的偏移
if (i > 0)
{
double totallength = GetTotalLength(shelves, i);
XYZ additionaldir = normal_vertical_offest_vector * (i * passage_width + totallength);
final_point += additionaldir;
XYZ additionaldir = normalVerticalOffestVector * (i * passageWidth + totallength);
finalPoint += additionaldir;
}
FamilyInstance end_instance = null;
FamilyInstance center_instance = null;
FamilyInstance start_instance = null;
doc.Invoke(ts =>
{
center_instance = doc.Create.NewFamilyInstance(final_point, shelf_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
end_instance = doc.Create.NewFamilyInstance(final_point + l * normal_vertical_offest_vector, shelf_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
start_instance = doc.Create.NewFamilyInstance(final_point - l * normal_vertical_offest_vector, shelf_symbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
center_instance = doc.Create.NewFamilyInstance(finalPoint, shelfSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
end_instance = doc.Create.NewFamilyInstance(finalPoint + l * normalVerticalOffestVector, shelfSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
start_instance = doc.Create.NewFamilyInstance(finalPoint - l * normalVerticalOffestVector, shelfSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instances.Add(center_instance);
instances.Add(end_instance);
instances.Add(start_instance);
}, "创建货架");
doc.Invoke(ts =>
{
if (parallel_referline_offest < 0.001)
if (parallelReferlineOffest < 0.001)
{
if (j % 2 != 0 && start_instance.CanFlipHand && center_instance.CanFlipHand && end_instance.CanFlipHand)
{
@@ -324,7 +324,7 @@ namespace RookieStation.PackAreaModule
doc.Invoke(ts =>
{
XYZ veroffestdir = zaxis.CrossProduct(refer_line.Direction).Normalize();
XYZ veroffestdir = zAxis.CrossProduct(referline.Direction).Normalize();
//旋转角度
double angle = XYZ.BasisY.AngleTo(veroffestdir);
//判断相对于Y轴是正向角度逆时针还是逆向角度顺时针
@@ -338,7 +338,7 @@ namespace RookieStation.PackAreaModule
for (int j = 0; j < instances.Count; j++)
{
FamilyInstance instance = instances[j];
var location_XYZ = RsRevitUtils.GetXYZByElement(instance);
var location_XYZ = RsRevitUtils.GetLocationPointByElement(instance);
Line zline = Line.CreateUnbound(location_XYZ, XYZ.BasisZ);
//旋转,移动
@@ -453,10 +453,10 @@ namespace RookieStation.PackAreaModule
foreach (var ins in card_instances)
{
var lp = RsRevitUtils.GetXYZByElement(ins);
var lp = RsRevitUtils.GetLocationPointByElement(ins);
foreach (var card in card_instances)
{
var lpt = RsRevitUtils.GetXYZByElement(card);
var lpt = RsRevitUtils.GetLocationPointByElement(card);
if (!card.Id.Equals(ins.Id) && lp.IsAlmostEqualTo(lpt))
{
ids_delete.Add(ins.Id);

View File

@@ -24,12 +24,6 @@ namespace RookieStation.Finishes
Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
Document doc = uidoc.Document;
var roomcounts = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).GetElementCount();
if (roomcounts == 0)
{
TaskDialog.Show("温馨提示", "项目中当前没有房间");
return Result.Cancelled;
}
ElementCategoryFilter ecf = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
ElementCategoryFilter ecf1 = new ElementCategoryFilter(BuiltInCategory.OST_StackedWalls);
LogicalOrFilter lof = new LogicalOrFilter(ecf, ecf1);
@@ -63,29 +57,35 @@ namespace RookieStation.Finishes
{
return Result.Cancelled;
}
WallType walltype = finishes.WallType;
bool iscontinue = true;
WallType wallType = finishes.WallType;
double wallWidth = wallType.Width;
double wallHeight = finishes.WallHeight;
double wallBaseOffest = finishes.WallBaseOffest;
string placeType = finishes.PlaceType;
bool isContinue = true;
try
{
while (iscontinue)
while (isContinue)
{
if (placeType == "房间")
{
var roomCount = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).GetElementCount();
if (roomCount == 0)
{
TaskDialog.Show("温馨提示", "项目中当前没有房间");
return Result.Failed;
}
Reference refer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter<Room>(), "请选择布置的房间");
//walltype包含了叠层墙和基本墙属于不同族如果出现名称一样则会过滤出来两个
//var walltypes = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).OfClass(typeof(WallType)).WhereElementIsElementType();
//var walls = new FilteredElementCollector(doc).OfClass(typeof(Wall));
//var walltype = walltypes.Where(x => x.Name == "常规 - 200mm").FirstOrDefault() as WallType;
Room room = uidoc.Document.GetElement(refer) as Room;
List<CurveLoop> curveLoopList = new List<CurveLoop>();
List<ElementId> walltojoin = new List<ElementId>();
List<List<ElementId>> walltojoinlist = new List<List<ElementId>>();
List<List<ElementId>> wallToJoinList = new List<List<ElementId>>();
var opts = new SpatialElementBoundaryOptions();
//{
// SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish
//};
double wallwidth = walltype.Width;
double wallheight = finishes.WallHeight;
//BuiltInCategory builtInCategory = (BuiltInCategory)walltype.Category.Id.IntegerValue;
//if (walltype.Kind == WallKind.Stacked)
//{
@@ -113,11 +113,10 @@ namespace RookieStation.Finishes
curveLoop.Append(boundarySegment.GetCurve());
walltojoin.Add(boundarySegment.ElementId);
}
walltojoinlist.Add(walltojoin);
wallToJoinList.Add(walltojoin);
curveLoopList.Add(curveLoop);
}
}
doc.Invoke(ts =>
{
Plane plane = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ());
@@ -125,29 +124,30 @@ namespace RookieStation.Finishes
for (int i = 0; i < curveLoopList.Count; i++)
{
//切线方向叉乘参数中的向量,内侧叉乘-z
var offestcurveloop = CurveLoop.CreateViaOffset(curveLoopList[i], wallwidth / 2, -XYZ.BasisZ);
for (int j = 0; j < offestcurveloop.Count(); j++)
var offest_curveloop = CurveLoop.CreateViaOffset(curveLoopList[i], wallWidth / 2, -XYZ.BasisZ);
for (int j = 0; j < offest_curveloop.Count(); j++)
{
Curve curve = offestcurveloop.ElementAt(j);
Curve curve = offest_curveloop.ElementAt(j);
////c的方向叉乘参数中的向量内侧叉乘-z
//var lc = c.CreateOffset(100 / 304.8, -XYZ.BasisZ);
//var x = curve.ComputeDerivatives(0.5, true).BasisX.CrossProduct(-XYZ.BasisZ).Normalize() * 100 / 304.8;
//var mc = doc.Create.NewModelCurve(lc, SketchPlane.Create(doc, plane));
//var mc = doc.Create.NewModelCurve(c, SketchPlane.Create(doc, plane));
var w = Wall.Create(doc, curve, walltype.Id, doc.ActiveView.GenLevel.Id, wallheight / 304.8, 0 / 304.8, false, false);
w.get_Parameter(BuiltInParameter.WALL_ATTR_ROOM_BOUNDING).Set(0);
var wallCreated = Wall.Create(doc, curve, wallType.Id, doc.ActiveView.GenLevel.Id, wallHeight / 304.8, wallBaseOffest / 304.8, false, false);
wallCreated.get_Parameter(BuiltInParameter.WALL_ATTR_ROOM_BOUNDING).Set(0);
doc.Regenerate();
//让门窗可以剪切出来
if (walltojoinlist[i][j].IntegerValue > 0)
//连接墙体让门窗可以剪切出来
if (wallToJoinList[i][j].IntegerValue > 0)
{
Element elemtojoin = doc.GetElement(walltojoinlist[i][j]);
Element elemToJoin = doc.GetElement(wallToJoinList[i][j]);
try
{
JoinGeometryUtils.JoinGeometry(doc, elemtojoin, w);
JoinGeometryUtils.JoinGeometry(doc, elemToJoin, wallCreated);
}
catch (Exception)
catch (Exception ex)
{
Log.WriteLog(ex.Message);
}
}
@@ -155,7 +155,89 @@ namespace RookieStation.Finishes
//offestcurves.Add(lc);
}
}
}, "创建饰面");
}, "创建房间饰面");
}
else if (placeType == "墙面")
{
Reference referFace = uidoc.Selection.PickObject(ObjectType.Face, new SelectFilter<Wall>(), "请选择布置的墙面");
Wall wall = doc.GetElement(referFace) as Wall;
Face face = wall.GetGeometryObjectFromReference(referFace) as Face;
var bottomFace = GetWallBottomFace(wall);
Curve instersectCurve = null;
face.Intersect(bottomFace, out instersectCurve);
doc.Invoke(ts =>
{
Curve curve = instersectCurve.CreateOffset(wallWidth / 2, XYZ.BasisZ);
var wallCreated = Wall.Create(doc, curve, wallType.Id, doc.ActiveView.GenLevel.Id, wallHeight / 304.8, wallBaseOffest / 304.8, false, false);
doc.Regenerate();
try
{
JoinGeometryUtils.JoinGeometry(doc, wall, wallCreated);
}
catch (Exception ex)
{
Log.WriteLog(ex.Message);
}
}, "创建墙面饰面");
//var loops = face.GetEdgesAsCurveLoops().OrderBy(x => x.GetExactLength());
////
//var cl = loops.LastOrDefault().GetEnumerator();
////face.Intersect(vp.SketchPlane.GetPlane())
//while (cl.MoveNext())
//{
// var c = cl.Current;
//}
}
else if (placeType == "整墙")
{
Reference refer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter<Wall>(), "请选择布置的墙体");
Wall wall = uidoc.Document.GetElement(refer) as Wall;
Face face = wall.GetGeometryObjectFromReference(refer) as Face;
var bottomFace = GetWallBottomFace(wall);
var sideFaces = GetWallSideFaces(wall);
//CurveLoop loop = new CurveLoop();
List<Curve> curs = new List<Curve>();
Curve IntersectCurve = null;
foreach (var sideFace in sideFaces)
{
bottomFace.Intersect(sideFace, out IntersectCurve);
curs.Add(IntersectCurve);
//ModelCurve ml = doc.Create.NewModelCurve(cur, doc.ActiveView.SketchPlane);
//loop.Append(cur);
}
//var loop = CurveLoop.Create(curs);
//var offestcurveloop = CurveLoop.CreateViaOffset(loop, wallwidth / 2, XYZ.BasisZ);
doc.Invoke(ts =>
{
for (int i = 0; i < curs.Count(); i++)
{
Curve curve = curs.ElementAt(i).CreateOffset(wallWidth / 2, -XYZ.BasisZ);
var wallCreated = Wall.Create(doc, curve, wallType.Id, doc.ActiveView.GenLevel.Id, wallHeight / 304.8, wallBaseOffest / 304.8, false, false);
doc.Regenerate();
try
{
JoinGeometryUtils.JoinGeometry(doc, wall, wallCreated);
}
catch (Exception ex)
{
Log.WriteLog(ex.Message);
}
//WallUtils.AllowWallJoinAtEnd(w, 0);
//offestcurves.Add(lc);
}
}, "创建墙体饰面");
}
//walltype包含了叠层墙和基本墙属于不同族如果出现名称一样则会过滤出来两个
//var walltypes = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).OfClass(typeof(WallType)).WhereElementIsElementType();
//var walls = new FilteredElementCollector(doc).OfClass(typeof(Wall));
//var walltype = walltypes.Where(x => x.Name == "常规 - 200mm").FirstOrDefault() as WallType;
}
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
@@ -165,5 +247,77 @@ namespace RookieStation.Finishes
return Result.Succeeded;
}
public List<Face> GetWallSideFaces(Wall wall)
{
Options opt = new Options();
opt.ComputeReferences = true;
opt.DetailLevel = ViewDetailLevel.Fine;
GeometryElement ge = wall.get_Geometry(opt);
List<Face> lstpf = new List<Face>();
foreach (GeometryObject obj in ge)
{
Solid solid = obj as Solid;
if (solid != null)
{
foreach (Face face in solid.Faces)
{
PlanarFace pf = face as PlanarFace;
if (pf != null)
{
if (pf.FaceNormal.DotProduct(XYZ.BasisZ) == 0)
{
lstpf.Add(pf);
}
//if (pf.FaceNormal.CrossProduct(wall.Orientation).IsZeroLength())
//{
// lstpf.Add(pf);
//}
}
var cy = face as CylindricalFace;
if (cy != null)
{
lstpf.Add(cy);
}
}
return lstpf;
}
}
return null;
}
public PlanarFace GetWallBottomFace(Wall wall)
{
Options opt = new Options();
opt.ComputeReferences = true;
opt.DetailLevel = ViewDetailLevel.Fine;
GeometryElement ge = wall.get_Geometry(opt);
PlanarFace pf = null;
foreach (GeometryObject obj in ge)
{
Solid solid = obj as Solid;
if (solid != null)
{
foreach (Face face in solid.Faces)
{
PlanarFace temppf = face as PlanarFace;
if (temppf != null)
{
if (temppf.FaceNormal.IsAlmostEqualTo(-XYZ.BasisZ))
{
pf = temppf;
break;
}
//if (pf.FaceNormal.CrossProduct(wall.Orientation).IsZeroLength())
//{
// lstpf.Add(pf);
//}
}
}
return pf;
}
}
return null;
}
}
}

View File

@@ -19,7 +19,7 @@ namespace RookieStation
Three = 3,
}
public enum LengthType
public enum ShelfLength
{
[Description("1000")]
x1000 = 1,
@@ -34,7 +34,7 @@ namespace RookieStation
x2000 = 4,
}
public enum WidthType
public enum ShelfWidth
{
[Description("400")]
x400 = 1,

View File

@@ -10,9 +10,9 @@ namespace RookieStation
public class Shelf
{
//public bool IsSelected { get; set; }
public LengthType LengthType { get; set; }
public ShelfLength ShelfLength { get; set; }
public WidthType WidthType { get; set; }
public ShelfWidth ShelfWidth { get; set; }
public NumOfGroup NumOfGroup { get; set; }
//public int StartNumber { get; set; }
//public int EndNumber { get; set; }
@@ -21,7 +21,7 @@ namespace RookieStation
{
get
{
string strlength = CommonUtils.GetEnumDescription(LengthType);
string strlength = CommonUtils.GetEnumDescription(ShelfLength);
return Convert.ToDouble(strlength);
}
}
@@ -30,11 +30,11 @@ namespace RookieStation
{
get
{
string strwidth = CommonUtils.GetEnumDescription(WidthType);
string strwidth = CommonUtils.GetEnumDescription(ShelfWidth);
return Convert.ToDouble(strwidth);
}
}
public string SymbolName => String.Format("{0}{1}{2}{3}", CommonUtils.GetEnumDescription(LengthType), "mmx", CommonUtils.GetEnumDescription(WidthType), "mm");
public string SymbolName => String.Format("{0}{1}{2}{3}", CommonUtils.GetEnumDescription(ShelfLength), "mmx", CommonUtils.GetEnumDescription(ShelfWidth), "mm");
}
}

View File

@@ -92,7 +92,6 @@
<Compile Include="CmdExportWorkSchedule.cs" />
<Compile Include="CmdLogoExtrusion.cs" />
<Compile Include="CmdPlaceWallFinishes.cs" />
<Compile Include="TestCmd.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>

View File

@@ -55,7 +55,7 @@ namespace RookieStation
LargeImage = ConvertFromBitmap(Properties.Resources.cainiao),
Image = ConvertFromBitmap(Properties.Resources.cainiao)
};
var projectbtn = (PushButton)projectPanel.AddItem(projectPBD);
var projectBtn = (PushButton)projectPanel.AddItem(projectPBD);
//前台布置
RibbonPanel receptionAreaPanel = application.CreateRibbonPanel(TabName, ReceptionPanelName);
PushButtonData receptionLayoutPBD = new PushButtonData("寄件区布置", "前台布置", AddInPath, "RookieStation.ShippingAreaModule.CmdPlaceReceptionArea")
@@ -63,8 +63,8 @@ namespace RookieStation
LargeImage = ConvertFromBitmap(Properties.Resources.Reception),
Image = ConvertFromBitmap(Properties.Resources.Reception)
};
var receptionbtn = (PushButton)receptionAreaPanel.AddItem(receptionLayoutPBD);
receptionbtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
var receptionBtn = (PushButton)receptionAreaPanel.AddItem(receptionLayoutPBD);
receptionBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
//出入口布置
RibbonPanel packAreaPanel = application.CreateRibbonPanel(TabName, EntranceAndExitGatePanelName);
PushButtonData entrancegateLayoutPBD = new PushButtonData("入口布置", "入口闸机", AddInPath, "RookieStation.PackAreaModule.CmdPlaceEntranceGate")
@@ -77,38 +77,38 @@ namespace RookieStation
LargeImage = ConvertFromBitmap(Properties.Resources.ExitGate),
Image = ConvertFromBitmap(Properties.Resources.ExitGate)
};
//var gatebtn = (PushButton)gatePanel.AddItem(exportGateLayoutPBD);
//var gateBtn = (PushButton)gatePanel.AddItem(exportGateLayoutPBD);
//IList<RibbonItem> gateItemsStacked = packAreaPanel.AddStackedItems(entrancegateLayoutPBD, exitGateLayoutPBD);
//var entrancebtn = (PushButton)gateItemsStacked[0];
//var exitbtn = (PushButton)gateItemsStacked[1];
var entrancebtn = (PushButton)packAreaPanel.AddItem(entrancegateLayoutPBD);
var exitbtn = (PushButton)packAreaPanel.AddItem(exitGateLayoutPBD);
entrancebtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
exitbtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
//var entranceBtn = (PushButton)gateItemsStacked[0];
//var exitBtn = (PushButton)gateItemsStacked[1];
var entranceBtn = (PushButton)packAreaPanel.AddItem(entrancegateLayoutPBD);
var exitBtn = (PushButton)packAreaPanel.AddItem(exitGateLayoutPBD);
entranceBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
exitBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
PushButtonData placeShelvesPBD = new PushButtonData("货架布置", "货架布置", AddInPath, "RookieStation.PackAreaModule.CmdPlaceShelves")
{
LargeImage = ConvertFromBitmap(Properties.Resources.Shelf),
Image = ConvertFromBitmap(Properties.Resources.Shelf)
};
var placeShelvesbtn = (PushButton)packAreaPanel.AddItem(placeShelvesPBD);
placeShelvesbtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
var placeShelvesBtn = (PushButton)packAreaPanel.AddItem(placeShelvesPBD);
placeShelvesBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
PushButtonData placeShelveCardsPBD = new PushButtonData("货架端牌", "货架端牌", AddInPath, "RookieStation.PackAreaModule.CmdArrangeShelfCards")
{
LargeImage = ConvertFromBitmap(Properties.Resources.ShelfCard),
Image = ConvertFromBitmap(Properties.Resources.ShelfCard)
};
var placeShelveCardsbtn = (PushButton)packAreaPanel.AddItem(placeShelveCardsPBD);
var placeShelveCardsBtn = (PushButton)packAreaPanel.AddItem(placeShelveCardsPBD);
PushButtonData placeLampsPBD = new PushButtonData("灯具布置", "灯具布置", AddInPath, "RookieStation.PackAreaModule.CmdPlaceLamps")
{
LargeImage = ConvertFromBitmap(Properties.Resources.Lamp),
Image = ConvertFromBitmap(Properties.Resources.Lamp)
};
var placeLampsbtn = (PushButton)packAreaPanel.AddItem(placeLampsPBD);
placeLampsbtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
var placeLampsBtn = (PushButton)packAreaPanel.AddItem(placeLampsPBD);
placeLampsBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
//饰面,完成面
RibbonPanel finishesPanel = application.CreateRibbonPanel(TabName, FinishesPanelName);
@@ -117,16 +117,17 @@ namespace RookieStation
LargeImage = ConvertFromBitmap(Properties.Resources.FloorFinishes),
Image = ConvertFromBitmap(Properties.Resources.FloorFinishes)
};
var floorcoveringbtn = (PushButton)finishesPanel.AddItem(floorfinishesPBD);
floorcoveringbtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
var floorcoveringBtn = (PushButton)finishesPanel.AddItem(floorfinishesPBD);
floorcoveringBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
PushButtonData wallcoveringPBD = new PushButtonData("墙饰面", "墙饰面", AddInPath, "RookieStation.Finishes.CmdPlaceWallFinishes")
{
LargeImage = ConvertFromBitmap(Properties.Resources.WallFinishes),
Image = ConvertFromBitmap(Properties.Resources.WallFinishes)
};
var wallcoveringbtn = (PushButton)finishesPanel.AddItem(wallcoveringPBD);
wallcoveringbtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
var wallcoveringBtn = (PushButton)finishesPanel.AddItem(wallcoveringPBD);
wallcoveringBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
//统计面板
RibbonPanel statisticsPanel = application.CreateRibbonPanel(TabName, StatisticsPanelName);

View File

@@ -13,7 +13,7 @@ namespace RookieStation
/// <summary>
/// 基于参考线的偏移(垂距)
/// </summary>
public double VerticalReferOffest { get; set; }
public double VerticalReferlineOffest { get; set; }
/// <summary>
/// 通道宽度
@@ -23,12 +23,12 @@ namespace RookieStation
/// <summary>
/// 基于参考线的偏移(起点水平)
/// </summary>
public double ParalelReferOffest { get; set; }
public double ParallelReferlineOffest { get; set; }
/// <summary>
/// 货架间距
/// </summary>
public double Spacing { get; set; }
public double ShelfSpacing { get; set; }
public ShelvesPlacementViewModel()
{
@@ -44,32 +44,32 @@ namespace RookieStation
for (int i = 0; i < sc.Count; i++)
{
Shelf shelf = new Shelf();
string shelf_string = sc[i];
string[] shelf_chars = shelf_string.Split(',');
foreach (NumOfGroup ng in Enum.GetValues(typeof(NumOfGroup)))
string shelfInfo = sc[i];
string[] shelfChars = shelfInfo.Split(',');
foreach (NumOfGroup numDescription in Enum.GetValues(typeof(NumOfGroup)))
{
string description = CommonUtils.GetEnumDescription(ng);
if (description == shelf_chars[0])
string description = CommonUtils.GetEnumDescription(numDescription);
if (description == shelfChars[0])
{
shelf.NumOfGroup = ng;
shelf.NumOfGroup = numDescription;
break;
}
}
foreach (LengthType lt in Enum.GetValues(typeof(LengthType)))
foreach (ShelfLength lengthDescription in Enum.GetValues(typeof(ShelfLength)))
{
string description = CommonUtils.GetEnumDescription(lt);
if (description == shelf_chars[1])
string description = CommonUtils.GetEnumDescription(lengthDescription);
if (description == shelfChars[1])
{
shelf.LengthType = lt;
shelf.ShelfLength = lengthDescription;
break;
}
}
foreach (WidthType wt in Enum.GetValues(typeof(WidthType)))
foreach (ShelfWidth widthDescription in Enum.GetValues(typeof(ShelfWidth)))
{
string description = CommonUtils.GetEnumDescription(wt);
if (description == shelf_chars[2])
string description = CommonUtils.GetEnumDescription(widthDescription);
if (description == shelfChars[2])
{
shelf.WidthType = wt;
shelf.ShelfWidth = widthDescription;
break;
}
}

View File

@@ -1,52 +0,0 @@
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RookieStation
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class TestCmd : 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;
Document doc = uidoc.Document;
DocumentSet docset = uiapp.Application.Documents;
ICollection<Element> sys = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_FurnitureSystems).OfClass(typeof(FamilyInstance)).ToElements();
foreach (FamilyInstance sy in sys)
{
if (sy.Symbol.FamilyName.Contains("亚克力"))
{
TaskDialog.Show("提示", "存在");
}
}
using (Transaction trans = new Transaction(doc, "cmd"))
{
try
{
trans.Start();
//Do Something.
trans.Commit();
}
catch (Exception ex)
{
message = ex.Message;
if (trans.GetStatus() == TransactionStatus.Started)
{
trans.RollBack();
}
return Result.Cancelled;
}
}
return Result.Succeeded;
}
}
}

View File

@@ -178,9 +178,9 @@ namespace RookieStation.Utils
{
tg.Start();
var result = func(tg);
TResult result = func(tg);
var status = tg.GetStatus();
TransactionStatus status = tg.GetStatus();
switch (status)
{
case TransactionStatus.Started:

View File

@@ -14,31 +14,31 @@ namespace RookieStation.Utils
/// <summary>
/// 英尺转米
/// </summary>
/// <param name="valuetoconvert"></param>
/// <param name="valueToConvert"></param>
/// <returns></returns>
public static double FtConvertToM(double valuetoconvert)
public static double FtConvertToM(double valueToConvert)
{
return UnitUtils.ConvertFromInternalUnits(valuetoconvert, DisplayUnitType.DUT_METERS);
return UnitUtils.ConvertFromInternalUnits(valueToConvert, DisplayUnitType.DUT_METERS);
}
/// <summary>
/// 平方英尺转平方米
/// </summary>
/// <param name="valuetoconvert"></param>
/// <param name="valueToConvert"></param>
/// <returns></returns>
public static double SFConvertToSM(double valuetoconvert)
public static double SFConvertToSM(double valueToConvert)
{
return UnitUtils.ConvertFromInternalUnits(valuetoconvert, DisplayUnitType.DUT_SQUARE_METERS);
return UnitUtils.ConvertFromInternalUnits(valueToConvert, DisplayUnitType.DUT_SQUARE_METERS);
}
/// <summary>
/// 英尺转换成毫米单位
/// </summary>
/// <param name="valuetoconvert"></param>
/// <param name="valueToConvert"></param>
/// <returns></returns>
public static double FtConvertToMM(double valuetoconvert)
public static double FtConvertToMM(double valueToConvert)
{
return UnitUtils.ConvertFromInternalUnits(valuetoconvert, DisplayUnitType.DUT_MILLIMETERS);
return UnitUtils.ConvertFromInternalUnits(valueToConvert, DisplayUnitType.DUT_MILLIMETERS);
}
/// <summary>
@@ -46,14 +46,14 @@ namespace RookieStation.Utils
/// </summary>
/// <param name="wallTypeName">墙类型包含的字符串</param>
/// <returns></returns>
public static double GetWallWidthByWallTypeName(Document doc, string wallTypeName, out WallType walltype)
public static double GetWallWidthByWallTypeName(Document doc, string wallTypeName, out WallType wallType)
{
double thickness = 0.0;
var walltypelist = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).OfClass(typeof(WallType)).Cast<WallType>();
walltype = walltypelist.FirstOrDefault(t => t.Name.Contains(wallTypeName));
if (walltype != null)
wallType = walltypelist.FirstOrDefault(t => t.Name.Contains(wallTypeName));
if (wallType != null)
{
thickness = walltype.Width;
thickness = wallType.Width;
//var compounds = walltype.GetCompoundStructure();
//for (int i = 0; i < compounds.LayerCount; i++)
//{
@@ -68,7 +68,7 @@ namespace RookieStation.Utils
/// </summary>
/// <param name="instance"></param>
/// <returns></returns>
public static XYZ GetXYZByElement(Element instance)
public static XYZ GetLocationPointByElement(Element instance)
{
return instance.Location is LocationPoint lp ? lp.Point : null;
}
@@ -77,19 +77,19 @@ namespace RookieStation.Utils
/// 调整族实例位置
/// </summary>
/// <param name="doc"></param>
/// <param name="fis">需要偏移的族实例</param>
/// <param name="refer_line">用于调整偏移和角度的参考线</param>
/// <param name="instances">需要偏移的族实例</param>
/// <param name="referLine">用于调整偏移和角度的参考线</param>
/// <param name="offest">偏移量</param>
public static void AdjustInstances(Document doc, List<FamilyInstance> fis, Line refer_line, double offest)
public static void AdjustInstances(Document doc, List<FamilyInstance> instances, Line referLine, double offest)
{
var zdir = XYZ.BasisZ;
XYZ zdir = XYZ.BasisZ;
//通过第三点垂直于直线的单位向量(无论左右侧)*偏移距离(一半的闸机长度)
XYZ offestdir = zdir.CrossProduct(refer_line.Direction).Normalize() * offest;
XYZ offestVector = zdir.CrossProduct(referLine.Direction).Normalize() * offest;
//旋转角度
double angle = XYZ.BasisY.AngleTo(offestdir);
double angle = XYZ.BasisY.AngleTo(offestVector);
//判断相对于Y轴是正向角度逆时针还是逆向角度顺时针
XYZ z = offestdir.CrossProduct(XYZ.BasisY).Normalize();
XYZ z = offestVector.CrossProduct(XYZ.BasisY).Normalize();
if (z.IsAlmostEqualTo(XYZ.BasisZ))
{
//逆向旋转,角度取负值
@@ -97,13 +97,13 @@ namespace RookieStation.Utils
//var ml = doc.Create.NewModelCurve(Line.CreateBound(XYZ.Zero, re), SketchPlane.Create(doc, Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ())));
}
foreach (var fi in fis)
foreach (FamilyInstance instance in instances)
{
var p = GetXYZByElement(fi);
XYZ p = GetLocationPointByElement(instance);
Line l = Line.CreateUnbound(p, XYZ.BasisZ);
//旋转,移动
ElementTransformUtils.RotateElement(doc, fi.Id, l, angle);
ElementTransformUtils.MoveElement(doc, fi.Id, offestdir);
ElementTransformUtils.RotateElement(doc, instance.Id, l, angle);
ElementTransformUtils.MoveElement(doc, instance.Id, offestVector);
}
}
@@ -112,30 +112,30 @@ namespace RookieStation.Utils
/// </summary>
/// <param name="doc"></param>
/// <param name="fi"></param>
/// <param name="refer_line"></param>
/// <param name="referLine"></param>
/// <param name="offest"></param>
public static void AdjustInstance(Document doc, FamilyInstance fi, Line refer_line, double offest)
public static void AdjustInstance(Document doc, FamilyInstance fi, Line referLine, double offest)
{
//朝着向量方向左侧偏移
var zdir = XYZ.BasisZ;
XYZ zdir = XYZ.BasisZ;
//通过第三点垂直于直线的单位向量(无论左右侧)*偏移距离(一半的闸机长度)
XYZ offest_direction = zdir.CrossProduct(refer_line.Direction).Normalize() * offest;
XYZ offestVector = zdir.CrossProduct(referLine.Direction).Normalize() * offest;
//旋转角度
double angle = XYZ.BasisY.AngleTo(offest_direction);
double angle = XYZ.BasisY.AngleTo(offestVector);
//判断相对于Y轴是正向角度逆时针还是逆向角度顺时针
XYZ z = offest_direction.CrossProduct(XYZ.BasisY).Normalize();
XYZ z = offestVector.CrossProduct(XYZ.BasisY).Normalize();
if (z.IsAlmostEqualTo(XYZ.BasisZ))
{
//逆向旋转,角度取负值
angle = -angle;
}
var p = GetXYZByElement(fi);
XYZ p = GetLocationPointByElement(fi);
Line l = Line.CreateUnbound(p, XYZ.BasisZ);
//旋转,移动
ElementTransformUtils.RotateElement(doc, fi.Id, l, angle + Math.PI);
ElementTransformUtils.MoveElement(doc, fi.Id, offest_direction);
ElementTransformUtils.MoveElement(doc, fi.Id, offestVector);
}
/// <summary>
@@ -144,14 +144,14 @@ namespace RookieStation.Utils
public static void AddProjectTemplate()
{
//Autodesk.Revit.ApplicationServices.Application.CurrentUsersDataFolderPath
string oriDatei = @"" + Environment.GetEnvironmentVariable("appdata") + @"\Autodesk\Revit\Autodesk Revit 2020\Revit.ini";
string tmpDatei = UserConstant.FamilyLibraryDirectory + "\\Rs.ini";
string oriDateFilePath = @"" + Environment.GetEnvironmentVariable("appdata") + @"\Autodesk\Revit\Autodesk Revit 2020\Revit.ini";
string tmpDateFilePath = UserConstant.FamilyLibraryDirectory + "\\Rs.ini";
if (System.IO.File.Exists(oriDatei))
if (System.IO.File.Exists(oriDateFilePath))
{
using (StreamReader sr = new StreamReader(oriDatei, Encoding.Unicode))
using (StreamReader sr = new StreamReader(oriDateFilePath, Encoding.Unicode))
{
StreamWriter sw = new StreamWriter(tmpDatei, false, Encoding.Unicode);
StreamWriter sw = new StreamWriter(tmpDateFilePath, false, Encoding.Unicode);
string inputLine = "";
while ((inputLine = sr.ReadLine()) != null)
@@ -172,34 +172,34 @@ namespace RookieStation.Utils
sw.Close();
}
System.IO.File.Replace(tmpDatei, oriDatei, null);
System.IO.File.Replace(tmpDateFilePath, oriDateFilePath, null);
}
}
public static FamilySymbol GetGuideSymbol(Document doc)
{
FamilySymbol linesymbol = null;
FamilySymbol lineSymbol = null;
doc.Invoke(ts =>
{
Family linefamily = GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "定位线.rfa");
linesymbol = doc.GetElement(linefamily.GetFamilySymbolIds().FirstOrDefault()) as FamilySymbol;
Family lineFamily = GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "定位线.rfa");
lineSymbol = doc.GetElement(lineFamily.GetFamilySymbolIds().FirstOrDefault()) as FamilySymbol;
}, "载入定位线并布置");
return linesymbol;
return lineSymbol;
}
public static Line GetGuideGeometryAndDeleteGuide(Document doc, List<ElementId> eleIdsAdded)
{
ElementId referlineid = eleIdsAdded.FirstOrDefault();
FamilyInstance referline = doc.GetElement(referlineid) as FamilyInstance;
LocationCurve lc = referline.Location as LocationCurve;
Line referlinegeom = lc.Curve as Line;
ElementId referLineId = eleIdsAdded.FirstOrDefault();
FamilyInstance guideLine = doc.GetElement(referLineId) as FamilyInstance;
LocationCurve lc = guideLine.Location as LocationCurve;
Line line = lc.Curve as Line;
doc.Invoke(ts =>
{
doc.Delete(referlineid);
doc.Delete(referLineId);
}, "删除参考线");
return referlinegeom;
return line;
}
/// <summary>
@@ -210,7 +210,7 @@ namespace RookieStation.Utils
/// <returns>所有的面</returns>
public static List<Face> GetFaceByElement(Element item, Options options)
{
List<Face> listFace = new List<Face>();
List<Face> faces = new List<Face>();
//根据打开的方式得到几何信息
GeometryElement geometry = item.get_Geometry(options);
foreach (GeometryObject geomObj in geometry)
@@ -223,14 +223,14 @@ namespace RookieStation.Utils
foreach (GeometryObject instObj in geomInstance.GetInstanceGeometry())
{
//三维的实体
Solid instsolid = instObj as Solid;
if (instsolid == null || instsolid.Faces.Size == 0 || instsolid.Edges.Size == 0)
Solid instSolid = instObj as Solid;
if (instSolid == null || instSolid.Faces.Size == 0 || instSolid.Edges.Size == 0)
{
continue;
}
foreach (Face face in instsolid.Faces)
foreach (Face face in instSolid.Faces)
{
listFace.Add(face);
faces.Add(face);
}
}
}
@@ -246,12 +246,12 @@ namespace RookieStation.Utils
{
foreach (Face face in solid.Faces)
{
listFace.Add(face);
faces.Add(face);
}
}
}
}
return listFace;
return faces;
}
/// <summary>
@@ -261,7 +261,7 @@ namespace RookieStation.Utils
/// <returns></returns>
public static List<Face> GetFacesByFamilyInstance(FamilyInstance instance, Options options)
{
List<Face> listFace = new List<Face>();
List<Face> faces = new List<Face>();
//根据打开的方式得到几何信息
GeometryElement geometry = instance.get_Geometry(options);
foreach (GeometryObject geomObj in geometry)
@@ -280,14 +280,14 @@ namespace RookieStation.Utils
foreach (GeometryObject instObj in instanceGeometry)
{
//三维的实体
Solid instsolid = instObj as Solid;
if (instsolid == null || instsolid.Faces.Size == 0 || instsolid.Edges.Size == 0)
Solid instSolid = instObj as Solid;
if (instSolid == null || instSolid.Faces.Size == 0 || instSolid.Edges.Size == 0)
{
continue;
}
foreach (Face face in instsolid.Faces)
foreach (Face face in instSolid.Faces)
{
listFace.Add(face);
faces.Add(face);
}
}
}
@@ -303,12 +303,12 @@ namespace RookieStation.Utils
{
foreach (Face face in solid.Faces)
{
listFace.Add(face);
faces.Add(face);
}
}
}
}
return listFace;
return faces;
}
/// <summary>
@@ -318,7 +318,7 @@ namespace RookieStation.Utils
/// <returns></returns>
public static List<Face> GetFamilyInstanceFaces(FamilyInstance instance, Options options)
{
List<Face> listFace = new List<Face>();
List<Face> faces = new List<Face>();
//根据打开的方式得到几何信息
GeometryElement geometry = instance.get_Geometry(options);
@@ -334,14 +334,14 @@ namespace RookieStation.Utils
foreach (GeometryObject instObj in geomInstance.GetInstanceGeometry())
{
//三维的实体
Solid instsolid = instObj as Solid;
if (instsolid == null || instsolid.Faces.Size == 0 || instsolid.Edges.Size == 0)
Solid instSolid = instObj as Solid;
if (instSolid == null || instSolid.Faces.Size == 0 || instSolid.Edges.Size == 0)
{
continue;
}
foreach (Face face in instsolid.Faces)
foreach (Face face in instSolid.Faces)
{
listFace.Add(face);
faces.Add(face);
}
}
}
@@ -357,12 +357,12 @@ namespace RookieStation.Utils
{
foreach (Face face in solid.Faces)
{
listFace.Add(face);
faces.Add(face);
}
}
}
}
return listFace;
return faces;
}
/// <summary>
@@ -399,20 +399,20 @@ namespace RookieStation.Utils
/// 获取已载入同名族,若无,则载入
/// </summary>
/// <param name="doc"></param>
/// <param name="familyname"></param>
/// <param name="familyName"></param>
/// <returns></returns>
internal static Family GetLoadedFamily(Document doc, string familyname)
internal static Family GetLoadedFamily(Document doc, string familyName)
{
Family family;
family = new FilteredElementCollector(doc)
.OfClass(typeof(Family))
.Cast<Family>()
.Where(f => f.Name == Path.GetFileNameWithoutExtension(familyname))
.Where(f => f.Name == Path.GetFileNameWithoutExtension(familyName))
.FirstOrDefault();
if (family == null)
{
doc.LoadFamily(familyname, new RsFamilyLoadOption(), out family);
doc.LoadFamily(familyName, new RsFamilyLoadOption(), out family);
}
return family;
@@ -422,23 +422,23 @@ namespace RookieStation.Utils
/// 获取垂直于基准线的最长边
/// </summary>
/// <param name="segments"></param>
/// <param name="baseline"></param>
/// <param name="baseLine"></param>
/// <returns></returns>
public static Line GetLongestSegmentLine(IList<BoundarySegment> segments, Line baseline)
public static Line GetLongestSegmentLine(IList<BoundarySegment> segments, Line baseLine)
{
Line line = null;
//var m = doc.GetElement(refer.ElementId);
foreach (var seg in segments)
{
Line templine = seg.GetCurve() as Line;
Line tempLine = seg.GetCurve() as Line;
//判断是否垂直
double dotp = Math.Abs(templine.Direction.DotProduct(baseline.Direction));
double dotp = Math.Abs(tempLine.Direction.DotProduct(baseLine.Direction));
if (dotp < 0.0001)
{
if (line == null || line.Length < templine.Length)
if (line == null || line.Length < tempLine.Length)
{
line = templine;
line = tempLine;
}
}
}

View File

@@ -15,6 +15,19 @@ namespace RookieStation
{
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
//Application revitApplication = applicationData.Application;
//ApplicationOptions options = ApplicationOptions.Get();
//switch (options.Availability)
//{
// case ApplicationAvailablity.ArchitectureDiscipline:
// return revitApplication.IsArchitectureEnabled;
// case ApplicationAvailablity.StructuralAnalysis:
// return revitApplication.IsStructuralAnalysisEnabled;
// case ApplicationAvailablity.MEP:
// return revitApplication.IsSystemsEnabled;
//}
if (null != applicationData.ActiveUIDocument)
{
Autodesk.Revit.DB.View view = applicationData.ActiveUIDocument.Document.ActiveView;

View File

@@ -30,7 +30,7 @@
Margin="2"
Header="通道宽度(mm)">
<TextBox
x:Name="tbpassage_width"
x:Name="tbPassage_width"
PreviewTextInput="tb_PreviewTextInput"
Text="600"
TextAlignment="Center" />

View File

@@ -20,7 +20,7 @@ namespace RookieStation
/// </summary>
public partial class WpfEntranceGate
{
public double passage_width = 0.0;
public double PassageWidth { get; set; }
public WpfEntranceGate()
{
@@ -29,10 +29,11 @@ namespace RookieStation
private void btnConfirm_Click(object sender, RoutedEventArgs e)
{
bool a = double.TryParse(tbpassage_width.Text, out passage_width);
double passageWidth;
bool a = double.TryParse(tbPassage_width.Text, out passageWidth);
if (a)
{
PassageWidth = passageWidth;
DialogResult = true;
}
}

View File

@@ -55,7 +55,7 @@
Margin="2"
Header="通道宽度(mm)">
<TextBox
x:Name="tbpassage_width"
x:Name="tbPassagewidth"
PreviewTextInput="tb_PreviewTextInput"
Text="600"
TextAlignment="Center" />

View File

@@ -20,9 +20,9 @@ namespace RookieStation
/// </summary>
public partial class WpfExitGate
{
public bool isStartPassage = true;
public bool IsStartPassage { get; set; }
public double passage_width = 0.0;
public double PassageWidth { get; set; }
public WpfExitGate()
@@ -32,15 +32,17 @@ namespace RookieStation
private void btnConfirm_Click(object sender, RoutedEventArgs e)
{
bool a = double.TryParse(tbpassage_width.Text, out passage_width);
double passageWidth;
bool a = double.TryParse(tbPassagewidth.Text, out passageWidth);
if (rbStartPassage.IsChecked == true)
{
isStartPassage = true;
PassageWidth = passageWidth;
IsStartPassage = true;
}
else if (rbStartInspection.IsChecked == true)
{
isStartPassage = false;
IsStartPassage = false;
}
if (a)
{

View File

@@ -35,7 +35,7 @@
Margin="2"
Header="砖长mm">
<TextBox
x:Name="tbLength"
x:Name="tbPavementLength"
InputMethod.IsInputMethodEnabled="False"
PreviewTextInput="tb_PreviewTextInput"
Text="600"
@@ -47,7 +47,7 @@
Margin="2"
Header="砖宽mm">
<TextBox
x:Name="tbWidth"
x:Name="tbPavementWidth"
InputMethod.IsInputMethodEnabled="False"
PreviewTextInput="tb_PreviewTextInput"
Text="600"
@@ -59,7 +59,7 @@
Margin="2"
Header="铺装缝隙mm">
<TextBox
x:Name="tbGap"
x:Name="tbPavementGap"
InputMethod.IsInputMethodEnabled="False"
PreviewTextInput="tb_PreviewTextInput"
Text="2"

View File

@@ -20,11 +20,11 @@ namespace RookieStation
/// </summary>
public partial class WpfFloorFinishes
{
public double cLength;
public double PavementLength { get; set; }
public double cWidth;
public double PavementWidth { get; set; }
public double cGap;
public double PavementGap { get; set; }
public WpfFloorFinishes()
@@ -34,11 +34,15 @@ namespace RookieStation
private void btnConfirm_Click(object sender, RoutedEventArgs e)
{
var a = double.TryParse(tbLength.Text, out cLength);
var b = double.TryParse(tbWidth.Text, out cWidth);
var c = double.TryParse(tbGap.Text, out cGap);
double length, width, gap;
var a = double.TryParse(tbPavementLength.Text, out length);
var b = double.TryParse(tbPavementWidth.Text, out width);
var c = double.TryParse(tbPavementGap.Text, out gap);
if (a && b && c)
{
PavementLength = length;
PavementWidth = width;
PavementGap = gap;
DialogResult = true;
}
else

View File

@@ -20,8 +20,8 @@ namespace RookieStation
/// </summary>
public partial class WpfLampsLayout
{
public double LRDistance;
public double FBDistance;
public double LeftRightDistance { get; set; }
public double FrontDistance { get; set; }
public WpfLampsLayout()
{
@@ -30,10 +30,13 @@ namespace RookieStation
private void btnConfirm_Click(object sender, RoutedEventArgs e)
{
bool a = double.TryParse(tbDistanceLR.Text, out LRDistance);
bool b = double.TryParse(tbDistanceFB.Text, out FBDistance);
double lrDistance, fDistance;
bool a = double.TryParse(tbDistanceLR.Text, out lrDistance);
bool b = double.TryParse(tbDistanceFB.Text, out fDistance);
if (a && b)
{
LeftRightDistance = lrDistance;
FrontDistance = fDistance;
DialogResult = true;
}
}

View File

@@ -3,12 +3,13 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:RookieStation"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Width="485"
Height="220"
MinWidth="550"
MinHeight="250"
Width="126"
Height="338"
MinWidth="220"
MinHeight="480"
mc:Ignorable="d">
<Window.Resources>
<ResourceDictionary>
@@ -20,67 +21,65 @@
</Window.Resources>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="0.8*" />
<RowDefinition Height="0.7*" />
<RowDefinition Height="0.4*" />
<RowDefinition Height="0.7*" />
<RowDefinition Height="0.2*" />
</Grid.RowDefinitions>
<!--<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>-->
<WrapPanel>
<GroupBox
Grid.Row="0"
Grid.Column="0"
Margin="2"
HorizontalAlignment="Left"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Header="背景墙(mm)">
<StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="铝塑板长度:" />
<TextBox
x:Name="tbaluminump_lastic_panel_length"
Width="80"
<hc:TextBox
x:Name="tbAluminumpLasticPanelLength"
Width="180"
hc:InfoElement.Title="铝塑板长度:"
hc:InfoElement.TitlePlacement="Left"
PreviewTextInput="tb_PreviewTextInput"
Text="1220"
TextAlignment="Center" />
</StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="铝塑板高度:" />
<TextBox
x:Name="tbaluminump_lastic_panel_height"
Width="80"
<hc:TextBox
x:Name="tbAluminumpLasticPanelHeight"
Width="180"
hc:InfoElement.Title="铝塑板高度:"
hc:InfoElement.TitlePlacement="Left"
PreviewTextInput="tb_PreviewTextInput"
Text="2400"
TextAlignment="Center" />
</StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" />
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="铝塑板分缝:" />
<TextBox
x:Name="tbaluminump_lastic_panel_gap"
Width="80"
<hc:TextBox
x:Name="tbAluminumpLasticPanelGap"
Width="180"
hc:InfoElement.Title="铝塑板分缝"
hc:InfoElement.TitlePlacement="Left"
PreviewTextInput="tb_PreviewTextInput"
Text="2"
TextAlignment="Center" />
</StackPanel>
</StackPanel>
</GroupBox>
<GroupBox
Margin="2"
HorizontalAlignment="Left"
Grid.Row="1"
Grid.Column="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Header="发光字(mm)">
<StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="样式:" />
<ComboBox x:Name="cbbsymbol" Width="150">
<hc:ComboBox
x:Name="cbbsymbol"
Width="180"
hc:InfoElement.Title="样式:"
hc:InfoElement.TitlePlacement="Left">
<ComboBoxItem Content="955mm x 250mm" IsSelected="True" />
<ComboBoxItem Content="1150mm x 300mm" />
<ComboBoxItem Content="1350mm x 350mm" />
</ComboBox>
</StackPanel>
</hc:ComboBox>
<!--<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="离地高度:" />
<TextBox
@@ -92,38 +91,42 @@
</StackPanel>
</GroupBox>
<GroupBox
Margin="2"
HorizontalAlignment="Left"
Grid.Row="2"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Header="吊灯(mm)">
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="间距:" />
<TextBox
x:Name="tblamps_interval"
Width="80"
HorizontalAlignment="Right"
<hc:TextBox
x:Name="tbLampsInterval"
Width="180"
hc:InfoElement.Title="间距:"
hc:InfoElement.TitlePlacement="Left"
PreviewTextInput="tb_PreviewTextInput"
Text="900"
TextAlignment="Center" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="墙距:" />
<TextBox
x:Name="tblamp_wall_distance"
Width="80"
HorizontalAlignment="Right"
<hc:TextBox
x:Name="tbLampsHeight"
Width="180"
hc:InfoElement.Title="高度:"
hc:InfoElement.TitlePlacement="Left"
PreviewTextInput="tb_PreviewTextInput"
Text="2400"
TextAlignment="Center" />
<hc:TextBox
x:Name="tbLampWallDistance"
Width="180"
HorizontalAlignment="Center"
hc:InfoElement.Title="墙距:"
hc:InfoElement.TitlePlacement="Left"
PreviewTextInput="tb_PreviewTextInput"
Text="1000"
TextAlignment="Center" />
</StackPanel>
</StackPanel>
</GroupBox>
</WrapPanel>
<Button
x:Name="btnConfirm"
Grid.Row="1"
Grid.Column="0"
Grid.Row="3"
Grid.Column="1"
Width="80"
Height="30"
Click="btnConfirm_Click"

View File

@@ -1,4 +1,5 @@
using System;
using Autodesk.Revit.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -20,36 +21,51 @@ namespace RookieStation.ShippingAreaModule
/// </summary>
public partial class WpfReceptionArea
{
public double aluminump_lastic_panel_length;
public double aluminump_lastic_panel_height;
public double lamps_interval;
public double lamp_wall_distance;
public string glow_text_symbol;
public double AluminumpLasticPanelHeight;
public double AluminumpLasticPanelLength;
public double LampsInterval;
public double LampsHeight;
public double LampWallDistance;
public string GlowTextSymbol;
//public double glow_text_elevation;
public double aluminump_lastic_panel_gap;
public double AluminumpLasticPanelGgap;
public WpfReceptionArea()
{
InitializeComponent();
tbaluminump_lastic_panel_height.Text = (UserConstant.Height / 3 * 2).ToString();
tbAluminumpLasticPanelHeight.Text = (UserConstant.Height / 3 * 2).ToString();
}
private void btnConfirm_Click(object sender, RoutedEventArgs e)
{
bool b = double.TryParse(tbaluminump_lastic_panel_height.Text, out aluminump_lastic_panel_height);
bool c = double.TryParse(tbaluminump_lastic_panel_length.Text, out aluminump_lastic_panel_length);
bool d = double.TryParse(tblamps_interval.Text, out lamps_interval);
bool f = double.TryParse(tblamp_wall_distance.Text, out lamp_wall_distance);
//bool h = double.TryParse(tbglow_text_elevation.Text, out glow_text_elevation);
bool i = double.TryParse(tbaluminump_lastic_panel_gap.Text, out aluminump_lastic_panel_gap);
double panelheight, panellength, lampsInterval, lampWallDistance, lampsHeight, panelGap;
glow_text_symbol = cbbsymbol.Text;
if (b && c && d && f && i)
bool b = double.TryParse(tbAluminumpLasticPanelHeight.Text, out panelheight);
bool c = double.TryParse(tbAluminumpLasticPanelLength.Text, out panellength);
bool d = double.TryParse(tbLampsInterval.Text, out lampsInterval);
bool f = double.TryParse(tbLampWallDistance.Text, out lampWallDistance);
//bool h = double.TryParse(tbglow_text_elevation.Text, out glow_text_elevation);
bool g = double.TryParse(tbLampsHeight.Text, out lampsHeight);
bool i = double.TryParse(tbAluminumpLasticPanelGap.Text, out panelGap);
if (b && c && d && g && f && i)
{
AluminumpLasticPanelHeight = panelheight;
AluminumpLasticPanelLength = panellength;
LampsInterval = lampsInterval;
LampWallDistance = lampWallDistance;
LampsHeight = lampsHeight;
AluminumpLasticPanelGgap = panelGap;
GlowTextSymbol = cbbsymbol.Text;
DialogResult = true;
}
else
{
TaskDialog.Show("温馨提示", "参数有误");
}
}
private void tb_PreviewTextInput(object sender, TextCompositionEventArgs e)

View File

@@ -37,11 +37,7 @@
Text="1"
TextAlignment="Center" />
</GroupBox>
<GroupBox
Grid.Row="0"
Grid.Column="1"
Margin="2"
Header="货架组合">
<GroupBox Grid.Row="0" Grid.Column="1" Margin="2" Header="货架组合">
<ComboBox x:Name="cbGroup">
<ComboBoxItem Content="单个货架" IsSelected="True" />
<ComboBoxItem Content="双联货架" />
@@ -54,13 +50,13 @@
Grid.Row="1"
Grid.Column="0"
HorizontalAlignment="Center"
Click="btnPlace_Click"
Click="btnConfirm_Click"
Content="布置" />
<Button
x:Name="btnNumber"
Grid.Row="1"
Grid.Column="1"
Click="btnNumber_Click"
Click="btnConfirm_Click"
Content="编号" />
</Grid>
</Window>

View File

@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace RookieStation
{
@@ -18,40 +19,184 @@ namespace RookieStation
private Document doc => uidoc.Document;
public int GroupNumber { get; set; }
public bool IsPlace { get; set; }
public bool IsContinue { get; set; }
public int CurrentNumber { get; set; }
public UIApplication UIApplication { get; set; }
public WpfShelfCards(UIApplication uIApplication)
{
UIApplication = uIApplication;
IsContinue = true;
InitializeComponent();
}
private void btnPlace_Click(object sender, RoutedEventArgs e)
private void btnConfirm_Click(object sender, RoutedEventArgs e)
{
GroupNumber = cbGroup.SelectedIndex + 1;
Button btn = sender as Button;
bool a = int.TryParse(tbCurrentNum.Text, out int num);
if (a)
{
GroupNumber = cbGroup.SelectedIndex + 1;
CurrentNumber = num;
Hide();
if (btn.Name == "btnPlace")
{
PlaceCards(this, uidoc);
}
else
{
NumberCards(this, uidoc);
}
}
else
{
TaskDialog.Show("温馨提示", "参数有误");
}
bool isCoutine = true;
}
private void tb_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
{
System.Text.RegularExpressions.Regex re = new System.Text.RegularExpressions.Regex("[^0-9]+");
e.Handled = re.IsMatch(e.Text);
}
private void NumberCards(WpfShelfCards wpfShelfCards, UIDocument uidoc)
{
Document doc = uidoc.Document;
int CurrentNumber = wpfShelfCards.CurrentNumber;
bool isContinue = wpfShelfCards.IsContinue;
int GroupNumber = wpfShelfCards.GroupNumber;
try
{
while (isCoutine)
while (isContinue)
{
List<FamilyInstance> instances = uidoc.Selection.PickElementsByRectangle(new CardsFilter(), "请框选要修改的端牌")
.Cast<FamilyInstance>()
.ToList();
//var selected = uidoc.Selection.GetElementIds();
if (instances.Count == 0)
{
continue;
}
Reference cards_refer = uidoc.Selection.PickObject(ObjectType.Element, new CardsSelectedFilter(instances), "请选择起始端牌");
var first_card = doc.GetElement(cards_refer) as FamilyInstance;
var location_point = RsRevitUtils.GetLocationPointByElement(first_card);
List<XYZ> location_points = new List<XYZ>();
instances.ForEach(f =>
{
var p = RsRevitUtils.GetLocationPointByElement(f);
location_points.Add(p);
});
var line_direction = location_points.LastOrDefault() - location_points.FirstOrDefault();
Line line = Line.CreateUnbound(location_points.FirstOrDefault(), line_direction);
//是否共线
foreach (var p in location_points)
{
if (line.Distance(p) > 0.01)
{
TaskDialog.Show("温馨提示", "所选端牌不在一条直线上");
return;
}
}
Dictionary<FamilyInstance, double> dict_instance_double = new Dictionary<FamilyInstance, double>();
foreach (var f in instances)
{
var p = RsRevitUtils.GetLocationPointByElement(f);
var distance = location_point.DistanceTo(p);
dict_instance_double.Add(f, distance);
}
var dict_sorted = dict_instance_double.OrderBy(x => x.Value);
int last_number = 0;
doc.Invoke(ts =>
{
if (GroupNumber == 1)
{
for (int i = 0; i < dict_sorted.Count(); i++)
{
var finstance = dict_sorted.ElementAt(i).Key;
string current_num_str = CurrentNumber.ToString();
if (CurrentNumber < 10)
{
current_num_str = $"0{current_num_str}";
}
finstance.GetParameters("货架号").FirstOrDefault().Set(current_num_str);
CurrentNumber += 1;
}
}
else if (GroupNumber == 2)
{
for (int i = 0; i < dict_sorted.Count(); i++)
{
last_number = CurrentNumber + 1;
string current_num_str = CurrentNumber.ToString();
string last_num_str = last_number.ToString();
if (CurrentNumber < 10)
{
current_num_str = $"0{current_num_str}";
}
if (last_number < 10)
{
last_num_str = $"0{last_number}";
}
var finstance = dict_sorted.ElementAt(i).Key;
finstance.GetParameters("货架号").FirstOrDefault().Set(string.Format("{0}{1}{2}", current_num_str, "~", last_num_str));
CurrentNumber = last_number + 1;
}
}
else
{
for (int i = 0; i < dict_sorted.Count(); i++)
{
last_number = CurrentNumber + 2;
string current_num_str = CurrentNumber.ToString();
string last_num_str = last_number.ToString();
if (CurrentNumber < 10)
{
current_num_str = $"0{current_num_str}";
}
if (last_number < 10)
{
last_num_str = $"0{last_number}";
}
var finstance = dict_sorted.ElementAt(i).Key;
finstance.GetParameters("货架号").FirstOrDefault().Set(string.Format("{0}{1}{2}", current_num_str, "~", last_num_str));
CurrentNumber = last_number + 1;
}
}
}, "端牌编号");
}
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
if (wpfShelfCards != null)
{
wpfShelfCards.tbCurrentNum.Text = CurrentNumber.ToString();
wpfShelfCards.ShowDialog();
}
}
}
private void PlaceCards(WpfShelfCards wpfShelfCards, UIDocument uidoc)
{
Document doc = uidoc.Document;
int CurrentNumber = wpfShelfCards.CurrentNumber;
bool isCoutinue = wpfShelfCards.IsContinue;
int GroupNumber = wpfShelfCards.GroupNumber;
try
{
while (isCoutinue)
{
doc.Invoke(ts =>
{
Reference refer_shelf = uidoc.Selection.PickObject(ObjectType.Element, new ShelfFilter(), "请选择布置端牌的货架");
FamilyInstance shelf = doc.GetElement(refer_shelf) as FamilyInstance;
int LastNum = CurrentNumber + GroupNumber - 1;
var location_XYZ = RsRevitUtils.GetXYZByElement(shelf);
int LastNum = CurrentNumber + wpfShelfCards.GroupNumber - 1;
var location_XYZ = RsRevitUtils.GetLocationPointByElement(shelf);
Reference front_face = shelf.GetReferences(FamilyInstanceReferenceType.Front).FirstOrDefault();
Reference back_face = shelf.GetReferences(FamilyInstanceReferenceType.Back).FirstOrDefault();
@@ -135,142 +280,12 @@ namespace RookieStation
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
tbCurrentNum.Text = CurrentNumber.ToString();
this.ShowDialog();
if (wpfShelfCards != null)
{
wpfShelfCards.tbCurrentNum.Text = CurrentNumber.ToString();
wpfShelfCards.ShowDialog();
}
}
private void tb_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
{
System.Text.RegularExpressions.Regex re = new System.Text.RegularExpressions.Regex("[^0-9]+");
e.Handled = re.IsMatch(e.Text);
}
private void btnNumber_Click(object sender, RoutedEventArgs e)
{
//Button btn = sender as Button;
GroupNumber = cbGroup.SelectedIndex + 1;
bool a = int.TryParse(tbCurrentNum.Text, out int num);
if (a)
{
CurrentNumber = num;
Hide();
}
else
{
TaskDialog.Show("温馨提示", "参数有误");
}
bool isContinue = true;
try
{
while (isContinue)
{
List<FamilyInstance> instances = uidoc.Selection.PickElementsByRectangle(new CardsFilter(), "请框选要修改的端牌")
.Cast<FamilyInstance>()
.ToList();
//var selected = uidoc.Selection.GetElementIds();
if (instances.Count == 0)
{
continue;
}
Reference cards_refer = uidoc.Selection.PickObject(ObjectType.Element, new CardsSelectedFilter(instances), "请选择起始端牌");
var first_card = doc.GetElement(cards_refer) as FamilyInstance;
var location_point = RsRevitUtils.GetXYZByElement(first_card);
List<XYZ> location_points = new List<XYZ>();
instances.ForEach(f =>
{
var p = RsRevitUtils.GetXYZByElement(f);
location_points.Add(p);
});
var line_direction = location_points.LastOrDefault() - location_points.FirstOrDefault();
Line line = Line.CreateUnbound(location_points.FirstOrDefault(), line_direction);
//是否共线
foreach (var p in location_points)
{
if (line.Distance(p) > 0.01)
{
TaskDialog.Show("温馨提示", "所选端牌不在一条直线上");
return;
}
}
Dictionary<FamilyInstance, double> dict_instance_double = new Dictionary<FamilyInstance, double>();
foreach (var f in instances)
{
var p = RsRevitUtils.GetXYZByElement(f);
var distance = location_point.DistanceTo(p);
dict_instance_double.Add(f, distance);
}
var dict_sorted = dict_instance_double.OrderBy(x => x.Value);
int last_number = 0;
doc.Invoke(ts =>
{
if (GroupNumber == 1)
{
for (int i = 0; i < dict_sorted.Count(); i++)
{
var finstance = dict_sorted.ElementAt(i).Key;
string current_num_str = CurrentNumber.ToString();
if (CurrentNumber < 10)
{
current_num_str = "0" + current_num_str;
}
finstance.GetParameters("货架号").FirstOrDefault().Set(current_num_str);
CurrentNumber += 1;
}
}
else if (GroupNumber == 2)
{
for (int i = 0; i < dict_sorted.Count(); i++)
{
last_number = CurrentNumber + 1;
string current_num_str = CurrentNumber.ToString();
string last_num_str = last_number.ToString();
if (CurrentNumber < 10)
{
current_num_str = "0" + current_num_str;
}
if (last_number < 10)
{
last_num_str = "0" + last_number;
}
var finstance = dict_sorted.ElementAt(i).Key;
finstance.GetParameters("货架号").FirstOrDefault().Set(string.Format("{0}{1}{2}", current_num_str, "~", last_number));
CurrentNumber = last_number + 1;
}
}
else
{
for (int i = 0; i < dict_sorted.Count(); i++)
{
last_number = CurrentNumber + 2;
string current_num_str = CurrentNumber.ToString();
string last_num_str = last_number.ToString();
if (CurrentNumber < 10)
{
current_num_str = "0" + current_num_str;
}
if (last_number < 10)
{
last_num_str = "0" + last_number;
}
var finstance = dict_sorted.ElementAt(i).Key;
finstance.GetParameters("货架号").FirstOrDefault().Set(string.Format("{0}{1}{2}", current_num_str, "~", last_num_str));
CurrentNumber = last_number + 1;
}
}
}, "端牌编号");
}
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
tbCurrentNum.Text = CurrentNumber.ToString();
this.ShowDialog();
}
}
}

View File

@@ -6,7 +6,7 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:RookieStation"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:util="clr-namespace:RookieStation.Utils"
xmlns:utils="clr-namespace:RookieStation.Utils"
Width="81"
Height="396"
MinWidth="400"
@@ -15,9 +15,9 @@
mc:Ignorable="d">
<Window.Resources>
<ResourceDictionary>
<util:EnumItemsSource x:Key="GroupEnumDescriptionSource" Type="{x:Type local:NumOfGroup}" />
<util:EnumItemsSource x:Key="LengthTypeEnumDescriptionSource" Type="{x:Type local:LengthType}" />
<util:EnumItemsSource x:Key="WidthTypeEnumDescriptionSource" Type="{x:Type local:WidthType}" />
<utils:EnumItemsSource x:Key="GroupEnumDescriptionSource" Type="{x:Type local:NumOfGroup}" />
<utils:EnumItemsSource x:Key="LengthTypeEnumDescriptionSource" Type="{x:Type local:ShelfLength}" />
<utils:EnumItemsSource x:Key="WidthTypeEnumDescriptionSource" Type="{x:Type local:ShelfWidth}" />
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml" />
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml" />
@@ -36,11 +36,7 @@
<RowDefinition Height="5*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<GroupBox
Grid.Row="0"
Grid.Column="0"
Margin="2"
Header="通道宽度">
<GroupBox Grid.Row="0" Grid.Column="0" Margin="2" Header="通道宽度">
<TextBox
x:Name="tbPassageWidth"
InputMethod.IsInputMethodEnabled="False"
@@ -48,11 +44,7 @@
Text="1500"
TextAlignment="Center" />
</GroupBox>
<GroupBox
Grid.Row="0"
Grid.Column="1"
Margin="2"
Header="起点距离">
<GroupBox Grid.Row="0" Grid.Column="1" Margin="2" Header="起点距离">
<TextBox
x:Name="tbDistance"
InputMethod.IsInputMethodEnabled="False"
@@ -60,11 +52,7 @@
Text="0"
TextAlignment="Center" />
</GroupBox>
<GroupBox
Grid.Row="0"
Grid.Column="2"
Margin="2"
Header="起点垂距 ">
<GroupBox Grid.Row="0" Grid.Column="2" Margin="2" Header="起点垂距 ">
<TextBox
x:Name="tbOffest"
InputMethod.IsInputMethodEnabled="False"
@@ -72,11 +60,7 @@
Text="0"
TextAlignment="Center" />
</GroupBox>
<GroupBox
Grid.Row="0"
Grid.Column="3"
Margin="2"
Header="货架间距 ">
<GroupBox Grid.Row="0" Grid.Column="3" Margin="2" Header="货架间距 ">
<TextBox
x:Name="tbSpacing"
InputMethod.IsInputMethodEnabled="False"
@@ -94,21 +78,9 @@
CanUserSortColumns="False"
ItemsSource="{Binding Data}">
<DataGrid.Columns>
<DataGridComboBoxColumn
MinWidth="100"
Header="成组"
ItemsSource="{Binding Source={StaticResource GroupEnumDescriptionSource}}"
SelectedValueBinding="{Binding NumOfGroup, Converter={StaticResource GroupEnumDescriptionSource}, Mode=TwoWay}" />
<DataGridComboBoxColumn
MinWidth="100"
Header="长度"
ItemsSource="{Binding Source={StaticResource LengthTypeEnumDescriptionSource}}"
SelectedValueBinding="{Binding LengthType, Converter={StaticResource LengthTypeEnumDescriptionSource}, Mode=TwoWay}" />
<DataGridComboBoxColumn
MinWidth="100"
Header="宽度"
ItemsSource="{Binding Source={StaticResource WidthTypeEnumDescriptionSource}}"
SelectedValueBinding="{Binding WidthType, Converter={StaticResource WidthTypeEnumDescriptionSource}, Mode=TwoWay}" />
<DataGridComboBoxColumn MinWidth="100" Header="成组" ItemsSource="{Binding Source={StaticResource GroupEnumDescriptionSource}}" SelectedValueBinding="{Binding NumOfGroup, Converter={StaticResource GroupEnumDescriptionSource}, Mode=TwoWay}" />
<DataGridComboBoxColumn MinWidth="100" Header="长度" ItemsSource="{Binding Source={StaticResource LengthTypeEnumDescriptionSource}}" SelectedValueBinding="{Binding ShelfLength, Converter={StaticResource LengthTypeEnumDescriptionSource}, Mode=TwoWay}" />
<DataGridComboBoxColumn MinWidth="100" Header="宽度" ItemsSource="{Binding Source={StaticResource WidthTypeEnumDescriptionSource}}" SelectedValueBinding="{Binding ShelfWidth, Converter={StaticResource WidthTypeEnumDescriptionSource}, Mode=TwoWay}" />
</DataGrid.Columns>
</DataGrid>
<TextBlock

View File

@@ -37,21 +37,21 @@ namespace RookieStation
{
//bool a = int.TryParse(cbLength.Text, out tLength);
//bool b = int.TryParse(cbWidth.Text, out tWidth);
double offest;
double distance;
double passagewidth;
double spacing;
bool a = double.TryParse(tbOffest.Text, out offest);
bool b = double.TryParse(tbDistance.Text, out distance);
bool c = double.TryParse(tbPassageWidth.Text, out passagewidth);
bool d = double.TryParse(tbSpacing.Text, out spacing);
double verticalDistance;
double parallelDistance;
double passageWidth;
double shelfSpacing;
bool a = double.TryParse(tbOffest.Text, out verticalDistance);
bool b = double.TryParse(tbDistance.Text, out parallelDistance);
bool c = double.TryParse(tbPassageWidth.Text, out passageWidth);
bool d = double.TryParse(tbSpacing.Text, out shelfSpacing);
if (a && b && c)
{
vm.VerticalReferOffest = offest;
vm.ParalelReferOffest = distance;
vm.PassageWidth = passagewidth;
vm.Spacing = spacing;
vm.VerticalReferlineOffest = verticalDistance;
vm.ParallelReferlineOffest = parallelDistance;
vm.PassageWidth = passageWidth;
vm.ShelfSpacing = shelfSpacing;
SaveShelvesData();
DialogResult = true;
}
@@ -68,7 +68,7 @@ namespace RookieStation
{
Shelf shelf = vm.Data[i];
string str = string.Format("{0}{1}{2}{3}{4}"
, CommonUtils.GetEnumDescription(shelf.NumOfGroup).ToString(), ",", CommonUtils.GetEnumDescription(shelf.LengthType), ",", CommonUtils.GetEnumDescription(shelf.WidthType));
, CommonUtils.GetEnumDescription(shelf.NumOfGroup).ToString(), ",", CommonUtils.GetEnumDescription(shelf.ShelfLength), ",", CommonUtils.GetEnumDescription(shelf.ShelfWidth));
sc.Add(str);
}
Properties.Settings.Default.Shelves = sc;
@@ -79,8 +79,8 @@ namespace RookieStation
{
var s = new Shelf()
{
LengthType = LengthType.x1500,
WidthType = WidthType.x400,
ShelfLength = ShelfLength.x1500,
ShelfWidth = ShelfWidth.x400,
NumOfGroup = NumOfGroup.Single,
};
vm.Data.Add(s);

View File

@@ -9,7 +9,7 @@
Width="351"
Height="116"
MinWidth="300"
MinHeight="200"
MinHeight="240"
mc:Ignorable="d">
<Window.Resources>
<ResourceDictionary>
@@ -24,47 +24,74 @@
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<!--<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5* " />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<ComboBox
</Grid.ColumnDefinitions>-->
<hc:ComboBox
x:Name="cbbWallTypes"
Grid.Row="0"
Grid.Column="1"
Width="200"
HorizontalAlignment="Center"
VerticalAlignment="Center"
hc:InfoElement.Title="饰面层类型:"
hc:InfoElement.TitlePlacement="Left"
DisplayMemberPath="Name"
SelectedIndex="0"
SelectedValuePath="Name" />
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="饰面层类型:" />
<TextBlock
<hc:TextBox
x:Name="tbWallHeight"
Grid.Row="1"
Grid.Column="1"
Width="200"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="饰面层高度:" />
hc:InfoElement.Title="饰面层高度:"
hc:InfoElement.TitlePlacement="Left"
PreviewTextInput="tb_PreviewTextInput"
Text="3000"
TextAlignment="Center"
ToolTip="饰面总高度" />
<hc:TextBox
x:Name="tbWallBase"
Grid.Row="2"
Grid.Column="1"
Width="200"
HorizontalAlignment="Center"
VerticalAlignment="Center"
hc:InfoElement.Title="饰面层底部偏移:"
hc:InfoElement.TitlePlacement="Left"
PreviewTextInput="tb_PreviewTextInput"
Text="0"
TextAlignment="Center"
ToolTip="饰面底部离地高度" />
<hc:ComboBox
x:Name="cbbPlaceType"
Grid.Row="3"
Grid.Column="1"
Width="200"
HorizontalAlignment="Center"
VerticalAlignment="Center"
hc:InfoElement.Title="布置方式:"
hc:InfoElement.TitlePlacement="Left"
PreviewTextInput="tb_PreviewTextInput"
Text="0"
ToolTip="饰面底部离地高度">
<ComboBoxItem Content="房间" IsSelected="True" />
<ComboBoxItem Content="墙面" />
<ComboBoxItem Content="整墙" />
</hc:ComboBox>
<Button
x:Name="btnPlace"
Grid.Row="2"
Grid.Row="4"
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Click="btnConfirm_Click"
Content="布置" />
<TextBox
x:Name="tbWallHeight"
Grid.Row="1"
Grid.Column="1"
Width="120"
HorizontalAlignment="Center"
VerticalAlignment="Center"
PreviewTextInput="tb_PreviewTextInput"
Text="3000"
TextAlignment="Center" />
</Grid>
</Window>

View File

@@ -29,6 +29,8 @@ namespace RookieStation
public WallType WallType { get; set; }
public double WallHeight { get; set; }
public double WallBaseOffest { get; set; }
public string PlaceType { get; set; }
public WpfWallFinishes(List<WallType> WallTypes)
{
@@ -40,9 +42,14 @@ namespace RookieStation
{
WallType = cbbWallTypes.SelectedItem as WallType;
double wallheight = 0.0;
double wallbase = 0.0;
bool b = double.TryParse(tbWallHeight.Text, out wallheight);
if (WallType != null && b)
bool c = double.TryParse(tbWallBase.Text, out wallbase);
//PlaceType = cbbPlaceType.SelectionBoxItem.ToString();
PlaceType = cbbPlaceType.Text;
if (WallType != null && b && c)
{
WallHeight = wallheight;
WallHeight = wallheight;
DialogResult = true;
}

View File

@@ -1,5 +1,6 @@
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.DB.Electrical;
using Autodesk.Revit.DB.Plumbing;
using Autodesk.Revit.UI;
@@ -26,7 +27,7 @@ namespace RookieStation.Statistics
UIDocument uidoc = uiapp.ActiveUIDocument;
Document doc = uidoc.Document;
string filename = UserConstant.AddinDirectory + "\\RsLibrary\\Document\\样板工程量清单.xlsx";
string fileName = UserConstant.AddinDirectory + "\\RsLibrary\\Document\\样板工程量清单.xlsx";
SaveFileDialog sfd = new SaveFileDialog()
{
Filter = "Excel文件|*.xlsx"
@@ -35,122 +36,171 @@ namespace RookieStation.Statistics
//{
// Multiselect = false,
//};
string destinationfilename = string.Empty;
string destinationFileName = string.Empty;
if (sfd.ShowDialog() == DialogResult.OK)
{
destinationfilename = sfd.FileName;
destinationFileName = sfd.FileName;
File.Copy(filename, destinationfilename, true);
File.Copy(fileName, destinationFileName, true);
}
if (destinationfilename == string.Empty)
if (destinationFileName == string.Empty)
{
return Result.Cancelled;
}
//白色乳胶漆
double wall_blankemulsionpaint_area = 0.0;
double blankEmulsionPaintArea = 0.0;
//灰色乳胶漆
double wall_greyemulsionpaint_area = 0.0;
double greyEmulsionPaintArea = 0.0;
//踢脚线
double wall_Skirting_length = 0.0;
double skirtingWallLength = 0.0;
//铝塑板
double wall_aluminum_plastic_panel_area = 0.0;
double aluminumPlasticPanelArea = 0.0;
//轻钢龙骨
double wall_steel_panel_area = 0.0;
double steelWallArea = 0.0;
//水泥砂浆
double cementMortarArea = 0.0;
//桥架
double cabletray_length = 0.0;
double cableTrayLength = 0.0;
//消防管
double pipe_length = 0.0;
double pipeLength = 0.0;
//寄件台
double reception_desk_length = 0;
double receptionDeskLength = 0;
//绿动箱
int green_recycling_box_num = 0;
int Trash_can_num = 0;
int shelf_num = 0;
string shelf_size = string.Empty;
int shelf_card_num = 0;
int high_cam = 0;
int cainiao_duty_num = 0;
int greenRecyclingBoxCount = 0;
//绿动垃圾箱
int trashCanCount = 0;
//货架数量
int shelfCount = 0;
//货架尺寸
string shelfSize = string.Empty;
//端牌
int shelfCardCount = 0;
//高拍仪
int highCameraCount = 0;
//菜鸟使命字
int cainiaoDutyCount = 0;
//防撞条长度
double containment_length = 0.0;
double containmentLength = 0.0;
//标识牌
int signage_num = 0;
int signageCount = 0;
//地贴
int ground_signage_num = 0;
int groundSignageCount = 0;
//侧招灯箱
int light_box_num = 0;
int lightBoxCount = 0;
//海报
int poster_num = 0;
int posterCount = 0;
//亚克力不发光字
int text_num = 0;
int textCount = 0;
//闸机
int extrance_gate_num = 0;
int extranceGateCount = 0;
//收检台
int exit_gate_desk_num = 0;
int exitGateDeskCount = 0;
//配电箱
int switching_cabinet_num = 0;
int switchingCabinetCount = 0;
//从开关
int switch_num = 0;
int switchCount = 0;
//插座
int socket_num = 0;
int socketCount = 0;
//射灯
int spotlight_num = 0;
int spotLightCount = 0;
//筒灯
int downlight_num = 0;
int downlightCount = 0;
//筒灯应急模块
int downlightEmergencyModuleCount = 0;
//吊灯
int chandelier_num = 0;
int bracket_light_num = 0;
int chandelierCount = 0;
//支架灯
int bracketLightCount = 0;
//镀锌方管骨架
double galvanizeFrame = 0.0;
//卷帘门
double curtainedDoorArea = 0.0;
//文化墙
double cultureWallArea = 0.0;
//半透明玻璃贴
double halfGlassPasteArea = 0.0;
//伸缩隔离栏
int railIsolateCount = 0;
//菜小鸟雕塑
int cainiaoSculptureCount = 0;
//面积
double floorArea = 0.0;
//门头石
double doorStoneArea = 0.0;
//台阶饰面
double stairStoneArea = 0.0;
var walls = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).OfClass(typeof(Wall));
foreach (Wall wall in walls)
{
if (wall.Name.Contains("灰色乳胶漆"))
{
wall_greyemulsionpaint_area += wall.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();
greyEmulsionPaintArea += wall.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();
}
else if (wall.Name.Contains("白色乳胶漆"))
{
wall_blankemulsionpaint_area += wall.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();
blankEmulsionPaintArea += wall.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();
}
else if (wall.Name.Contains("黑钛不锈钢"))
{
wall_Skirting_length += wall.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsDouble();
skirtingWallLength += wall.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsDouble();
}
else if (wall.Name.Contains("铝塑板"))
{
wall_aluminum_plastic_panel_area += wall.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();
aluminumPlasticPanelArea += wall.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();
var re = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Interior).FirstOrDefault();
PlanarFace p = wall.GetGeometryObjectFromReference(re) as PlanarFace;
var cs = p.GetEdgesAsCurveLoops().OrderByDescending(l => l.GetExactLength());
galvanizeFrame += cs.First().GetExactLength();
}
else if (wall.Name.Contains("轻钢龙骨"))
{
wall_steel_panel_area += wall.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();
steelWallArea += wall.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();
}
else if (wall.Name.Contains("水泥砂浆"))
{
cementMortarArea += wall.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();
}
}
var floors = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors).OfClass(typeof(Floor));
foreach (Floor floor in floors)
{
floorArea += floor.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();
}
var pipes = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_PipeCurves).OfClass(typeof(Pipe));
foreach (Pipe p in pipes)
{
pipe_length += p.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsDouble();
pipeLength += p.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsDouble();
}
var cts = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_CableTray).OfClass(typeof(CableTray));
foreach (CableTray ct in cts)
var cableTrays = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_CableTray).OfClass(typeof(CableTray));
foreach (CableTray ct in cableTrays)
{
cabletray_length += ct.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsDouble();
cableTrayLength += ct.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsDouble();
}
var lights = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_LightingFixtures).OfClass(typeof(FamilyInstance));
foreach (FamilyInstance light in lights)
{
if (light.Symbol.FamilyName.Contains("支架灯"))
{
bracket_light_num += 1;
bracketLightCount += 1;
}
else if (light.Symbol.FamilyName.Contains("筒灯"))
{
downlight_num += 1;
if (light.Symbol.get_Parameter(BuiltInParameter.WINDOW_TYPE_ID).AsString() == "E")
{
downlightEmergencyModuleCount += 1;
}
else
{
downlightCount += 1;
}
}
else if (light.Symbol.FamilyName.Contains("吊灯"))
{
chandelier_num += 1;
chandelierCount += 1;
}
else if (light.Symbol.FamilyName.Contains("射灯"))
{
spotlight_num += 1;
spotLightCount += 1;
}
}
var sockets = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_ElectricalFixtures).OfClass(typeof(FamilyInstance));
@@ -159,11 +209,11 @@ namespace RookieStation.Statistics
{
if (socket.Symbol.FamilyName.Contains("二三孔"))
{
socket_num += 1;
socketCount += 1;
}
else if (socket.Symbol.FamilyName.Contains("数据信息"))
{
socket_num += 1;
socketCount += 1;
}
}
var switchs = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_LightingDevices).OfClass(typeof(FamilyInstance));
@@ -171,41 +221,40 @@ namespace RookieStation.Statistics
{
if (swit.Symbol.FamilyName.Contains("单联") && swit.Name.Contains("单控"))
{
switch_num += 1;
switchCount += 1;
}
}
var furnitures = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Furniture).OfClass(typeof(FamilyInstance));
foreach (FamilyInstance furn in furnitures)
{
if (furn.Symbol.FamilyName.Contains("收检台"))
bool isdetail = furn.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).AsString().Contains("大样");
if (furn.Symbol.FamilyName.Contains("收检台") && !isdetail)
{
if (!furn.Symbol.FamilyName.Contains("大样"))
{
exit_gate_desk_num += 1;
exitGateDeskCount += 1;
}
else if (furn.Symbol.FamilyName.Contains("接待台") && !isdetail)
{
receptionDeskLength = furn.Symbol.GetParameters("台面长度").FirstOrDefault().AsDouble();
}
else if (furn.Symbol.FamilyName.Contains("接待台"))
else if (furn.Symbol.FamilyName.Contains("绿动箱") && !isdetail)
{
reception_desk_length = furn.Symbol.GetParameters("台面长度").FirstOrDefault().AsDouble();
}
else if (furn.Symbol.FamilyName.Contains("绿动箱"))
{
if (!furn.Symbol.FamilyName.Contains("大样"))
{
green_recycling_box_num += 1;
greenRecyclingBoxCount += 1;
if (furn.Symbol.Name.Contains("1500"))
{
Trash_can_num += 2;
trashCanCount += 1;
}
else
{
Trash_can_num += 1;
}
trashCanCount += 2;
}
}
else if (furn.Symbol.FamilyName.Contains("货架"))
{
shelf_num += 1;
shelfCount += 1;
}
else if (furn.Symbol.FamilyName.Contains("菜小鸟雕塑"))
{
cainiaoSculptureCount += 1;
}
}
var furnituressystem = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_FurnitureSystems).OfClass(typeof(FamilyInstance));
@@ -213,35 +262,47 @@ namespace RookieStation.Statistics
{
if (furnsys.Symbol.FamilyName.Contains("端牌"))
{
shelf_card_num += 1;
shelfCardCount += 1;
}
else if (furnsys.Symbol.FamilyName.Contains("使命"))
{
cainiao_duty_num += 1;
cainiaoDutyCount += 1;
}
else if (furnsys.Symbol.FamilyName.Contains("防撞条"))
{
containment_length += furnsys.get_Parameter(BuiltInParameter.FAMILY_LINE_LENGTH_PARAM).AsDouble();
containmentLength += furnsys.get_Parameter(BuiltInParameter.FAMILY_LINE_LENGTH_PARAM).AsDouble();
}
else if (furnsys.Symbol.FamilyName.Contains("标识"))
{
signage_num += 1;
signageCount += 1;
}
else if (furnsys.Symbol.FamilyName.Contains("亚克力"))
{
text_num += furnsys.GetParameters("文字").FirstOrDefault().AsString().Length;
textCount += furnsys.GetParameters("文字").FirstOrDefault().AsString().Length;
}
else if (furnsys.Symbol.FamilyName.Contains("地贴"))
{
ground_signage_num += 1;
groundSignageCount += 1;
}
else if (furnsys.Symbol.FamilyName.Contains("灯箱"))
{
light_box_num += 1;
lightBoxCount += 1;
}
else if (furnsys.Symbol.FamilyName.Contains("海报"))
{
poster_num += 1;
posterCount += 1;
}
else if (furnsys.Symbol.FamilyName.Contains("文化墙"))
{
var h = furnsys.GetParameters("高度").First().AsDouble();
var l = furnsys.GetParameters("长度").First().AsDouble();
cultureWallArea += h * l;
}
else if (furnsys.Symbol.FamilyName.Contains("半透"))
{
double h = furnsys.GetParameters("高度").First().AsDouble();
double w = furnsys.GetParameters("宽度").First().AsDouble();
halfGlassPasteArea += h * w;
}
}
var equipments = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_SpecialityEquipment).OfClass(typeof(FamilyInstance));
@@ -249,11 +310,11 @@ namespace RookieStation.Statistics
{
if (equip.Symbol.FamilyName.Contains("闸机"))
{
extrance_gate_num += 1;
extranceGateCount += 1;
}
else if (equip.Symbol.FamilyName.Contains("高拍仪"))
{
high_cam += 1;
highCameraCount += 1;
}
}
var doors = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors).OfClass(typeof(FamilyInstance));
@@ -261,62 +322,121 @@ namespace RookieStation.Statistics
{
if (door.Symbol.FamilyName.Contains("卷帘"))
{
var width = door.Symbol.GetParameters("宽度").FirstOrDefault().AsDouble();
var height = door.Symbol.GetParameters("高度").FirstOrDefault().AsDouble();
curtainedDoorArea += height * width;
}
else if (door.Symbol.FamilyName.Contains("卷帘"))
else if (door.Symbol.FamilyName.Contains("单扇"))
{
}
}
FileInfo fi = new FileInfo(destinationfilename);
var rails = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_StairsRailing).OfClass(typeof(Railing));
foreach (Railing rail in rails)
{
if (rail.Name.Contains("伸缩隔离栏"))
{
railIsolateCount += 1;
}
}
var sites = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Site).OfClass(typeof(FamilyInstance));
foreach (FamilyInstance site in sites)
{
if (site.Symbol.FamilyName.Contains("门头石"))
{
var length = site.Symbol.GetParameters("长度").FirstOrDefault().AsDouble();
var height = site.Symbol.GetParameters("高度").FirstOrDefault().AsDouble();
doorStoneArea += height * length;
}
else if (site.Symbol.FamilyName.Contains("台阶"))
{
var width = site.GetParameters("踏面宽度").FirstOrDefault().AsDouble();
var length = site.GetParameters("梯段宽度").FirstOrDefault().AsDouble();
int num = 0;
switch (site.Symbol.Name)
{
case "一阶":
num = 1;
break;
case "二阶":
num = 2;
break;
case "三阶":
num = 3;
break;
default:
break;
}
stairStoneArea += length * width * num;
}
}
FileInfo fi = new FileInfo(destinationFileName);
using (ExcelPackage package = new ExcelPackage(fi))
{
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
ExcelWorksheet sheet0 = package.Workbook.Worksheets["汇总表"];
ExcelWorksheet sheet1 = package.Workbook.Worksheets["基装"];
//消防管
sheet1.Cells[8, 7].Value = RsRevitUtils.FtConvertToM(pipe_length);
sheet1.Cells[8, 7].Value = RsRevitUtils.FtConvertToM(pipeLength);
//桥架
sheet1.Cells[9, 7].Value = RsRevitUtils.FtConvertToM(cabletray_length);
sheet1.Cells[9, 7].Value = RsRevitUtils.FtConvertToM(cableTrayLength);
//乳胶漆
sheet1.Cells[10, 7].Value = RsRevitUtils.SFConvertToSM(wall_blankemulsionpaint_area + wall_greyemulsionpaint_area);
sheet1.Cells[10, 7].Value = RsRevitUtils.SFConvertToSM(blankEmulsionPaintArea + greyEmulsionPaintArea);
//铝塑板
sheet1.Cells[11, 7].Value = RsRevitUtils.SFConvertToSM(wall_aluminum_plastic_panel_area);
sheet1.Cells[14, 7].Value = RsRevitUtils.SFConvertToSM(wall_steel_panel_area);
sheet1.Cells[11, 7].Value = RsRevitUtils.SFConvertToSM(aluminumPlasticPanelArea);
sheet1.Cells[12, 7].Value = RsRevitUtils.FtConvertToM(galvanizeFrame);
sheet1.Cells[13, 7].Value = RsRevitUtils.SFConvertToSM(cementMortarArea);
//轻钢龙骨
sheet1.Cells[14, 7].Value = RsRevitUtils.SFConvertToSM(steelWallArea);
sheet1.Cells[16, 7].Value = RsRevitUtils.SFConvertToSM(floorArea);
sheet1.Cells[17, 7].Value = RsRevitUtils.SFConvertToSM(floorArea);
sheet1.Cells[18, 7].Value = RsRevitUtils.SFConvertToSM(floorArea);
//踢脚线
sheet1.Cells[19, 7].Value = RsRevitUtils.FtConvertToM(wall_Skirting_length);
sheet1.Cells[24, 7].Value = RsRevitUtils.FtConvertToM(reception_desk_length);
sheet1.Cells[25, 7].Value = green_recycling_box_num;
sheet1.Cells[26, 7].Value = exit_gate_desk_num;
sheet1.Cells[32, 7].Value = switching_cabinet_num;
sheet1.Cells[19, 7].Value = RsRevitUtils.FtConvertToM(skirtingWallLength);
sheet1.Cells[21, 7].Value = RsRevitUtils.SFConvertToSM(stairStoneArea);
sheet1.Cells[22, 7].Value = RsRevitUtils.SFConvertToSM(doorStoneArea);
sheet1.Cells[24, 7].Value = RsRevitUtils.FtConvertToM(receptionDeskLength);
sheet1.Cells[25, 7].Value = greenRecyclingBoxCount;
sheet1.Cells[26, 7].Value = exitGateDeskCount;
sheet1.Cells[27, 7].Value = RsRevitUtils.SFConvertToSM(curtainedDoorArea);
sheet1.Cells[32, 7].Value = switchingCabinetCount;
//为什么和桥架乳胶漆长度不一样
sheet1.Cells[33, 7].Value = RsRevitUtils.FtConvertToM(cabletray_length);
sheet1.Cells[39, 7].Value = socket_num;
sheet1.Cells[40, 7].Value = switch_num;
sheet1.Cells[41, 7].Value = chandelier_num;
sheet1.Cells[42, 7].Value = spotlight_num;
sheet1.Cells[46, 7].Value = downlight_num;
sheet1.Cells[47, 7].Value = bracket_light_num;
sheet1.Cells[33, 7].Value = RsRevitUtils.FtConvertToM(cableTrayLength);
sheet1.Cells[39, 7].Value = socketCount;
sheet1.Cells[40, 7].Value = switchCount;
sheet1.Cells[41, 7].Value = chandelierCount;
sheet1.Cells[42, 7].Value = spotLightCount;
sheet1.Cells[46, 7].Value = downlightCount;
sheet1.Cells[47, 7].Value = bracketLightCount;
sheet1.Cells[48, 7].Value = downlightEmergencyModuleCount;
ExcelWorksheet sheet2 = package.Workbook.Worksheets["道具"];
//sheet2.Cells[8, 6].Value = UnitUtils.ConvertFromInternalUnits(pipe_length, DisplayUnitType.DUT_METERS);
sheet2.Cells[4, 7].Value = Trash_can_num;
sheet2.Cells[5, 7].Value = extrance_gate_num;
sheet2.Cells[4, 7].Value = trashCanCount;
sheet2.Cells[5, 7].Value = extranceGateCount;
sheet2.Cells[6, 7].Value = railIsolateCount;
sheet2.Cells[7, 7].Value = cainiaoSculptureCount;
ExcelWorksheet sheet3 = package.Workbook.Worksheets["品牌模块"];
//sheet3.Cells[8, 6].Value = UnitUtils.ConvertFromInternalUnits(pipe_length, DisplayUnitType.DUT_METERS);
sheet3.Cells[7, 6].Value = light_box_num;
sheet3.Cells[9, 6].Value = text_num;
sheet3.Cells[10, 6].Value = text_num;
sheet3.Cells[11, 6].Value = signage_num;
sheet3.Cells[14, 6].Value = cainiao_duty_num;
sheet3.Cells[16, 6].Value = RsRevitUtils.FtConvertToM(containment_length);
sheet3.Cells[17, 6].Value = ground_signage_num;
sheet3.Cells[18, 6].Value = shelf_card_num;
sheet3.Cells[19, 6].Value = shelf_num;
sheet3.Cells[7, 6].Value = lightBoxCount;
sheet3.Cells[9, 6].Value = textCount;
sheet3.Cells[10, 6].Value = textCount;
sheet3.Cells[11, 6].Value = signageCount;
sheet3.Cells[12, 6].Value = RsRevitUtils.SFConvertToSM(cultureWallArea);
sheet3.Cells[14, 6].Value = cainiaoDutyCount;
sheet3.Cells[15, 6].Value = RsRevitUtils.SFConvertToSM(halfGlassPasteArea);
sheet3.Cells[16, 6].Value = RsRevitUtils.FtConvertToM(containmentLength);
sheet3.Cells[17, 6].Value = groundSignageCount;
sheet3.Cells[18, 6].Value = shelfCardCount;
sheet3.Cells[19, 4].Value = shelfSize;
sheet3.Cells[19, 6].Value = shelfCount;
package.Save();
}
System.Diagnostics.Process.Start(destinationfilename);
System.Diagnostics.Process.Start(destinationFileName);
return Result.Succeeded;
}
}

File diff suppressed because it is too large Load Diff