更新铺贴,族库栏

This commit is contained in:
GG Z
2021-06-22 14:40:36 +08:00
parent 5e1bd8ca9a
commit 22d84126bc
44 changed files with 2459 additions and 1418 deletions

View File

@@ -36,7 +36,6 @@ namespace RookieStation.PackAreaModule
}
catch (Exception ex)
{
TaskDialog.Show("错误", ex.Message);
Log.WriteLog(ex.Message);
}
finally

View File

@@ -1,6 +1,7 @@
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using RookieStation.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -13,17 +14,29 @@ namespace RookieStation.CommonTools
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdBrowserFamily : IExternalCommand
{
private Guid guid = new Guid("{028001AD-0588-4A9C-AA03-D7E472D85050}");
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
//var dpid = new DockablePaneId(PaneIdentifiers.GetManagerPaneIdentifier());
try
{
var libraryDirectory = UserConstant.FamilyLibraryDirectory;
System.Diagnostics.Process.Start(libraryDirectory);
}
catch (Exception)
DockablePaneId id = new DockablePaneId(guid);
DockablePane pane = commandData.Application.GetDockablePane(id);
if (pane.IsShown())
{
TaskDialog.Show("温馨提示", "路径不存在,无法浏览文件");
pane.Hide();
}
else
{
pane.Show();
}
//var libraryDirectory = UserConstant.FamilyLibraryDirectory;
//System.Diagnostics.Process.Start(libraryDirectory);
}
catch (Exception ex)
{
Log.WriteLog(ex.Message);
//TaskDialog.Show("温馨提示", "路径不存在,无法浏览文件");
return Result.Failed;
}

View File

@@ -0,0 +1,540 @@
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using RookieStation.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
namespace RookieStation.Finishes
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
[Obsolete]
internal class CmdFloorFinishes : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Document doc = uidoc.Document;
Family family = null;
FamilySymbol symbol;
var rooms = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms);
if (rooms.Count() == 0)
{
TaskDialog.Show("温馨提示", "项目中当前没有房间");
return Result.Cancelled;
}
WpfFloorFinishes floorCovering = CommonUtils.GenerateWindow<WpfFloorFinishes>();
double length;
double width;
double gap;
if (floorCovering.DialogResult == true)
{
length = floorCovering.PavementLength / 304.8;
width = floorCovering.PavementWidth / 304.8;
gap = floorCovering.PavementGap / 304.8;
}
else
{
return Result.Cancelled;
}
return doc.InvokeGroup(tg =>
{
Level baseLevel = doc.ActiveView.GenLevel;
if (baseLevel == null)
{
return Result.Failed;
}
List<ElementId> modelCurveIds = new List<ElementId>();
try
{
//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);
//}
SelectFilter<Room> roomFilter = new SelectFilter<Room>();
Reference roomReference = uidoc.Selection.PickObject(ObjectType.Element, roomFilter, "请选择房间");
Room room = doc.GetElement(roomReference) as Room;
var roompoint = RsRevitUtils.GetLocationPointByElement(room);
var segments = room.GetBoundarySegments(new SpatialElementBoundaryOptions()).FirstOrDefault();
doc.Invoke(ts =>
{
foreach (var seg in segments)
{
Curve cur = seg.GetCurve();
Plane plane = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ());
var mc = doc.Create.NewModelCurve(cur, SketchPlane.Create(doc, plane));
modelCurveIds.Add(mc.Id);
}
}, "模型线创建");
//Reference edge = uidoc.Selection.PickObject(ObjectType.Edge, "请选择边界");
SelectFilter<ModelLine> mlFilter = new SelectFilter<ModelLine>();
Reference refline = uidoc.Selection.PickObject(ObjectType.Element, mlFilter, "请选择基准边线");
//模型线选取
var ml = doc.GetElement(refline) as ModelLine;
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;
}
//if (basepoint.IsAlmostEqualTo(ml.GeometryCurve.GetEndPoint(0)) || basepoint.IsAlmostEqualTo(ml.GeometryCurve.GetEndPoint(1)))
//{
//}
//基准线端点
var endpoint1 = referline.GetEndPoint(0);
var endpoint2 = referline.GetEndPoint(1);
//基准点向端点的向量
XYZ v1 = endpoint1 - basePoint;
XYZ v2 = endpoint2 - basePoint;
//用于确认布置方向
var v0 = roompoint - basePoint;
List<Curve> curves = new List<Curve>();
List<FamilyInstance> instances = new List<FamilyInstance>();
//Curve currefer = null;
//Curve currefer1 = null;
double interval = length + gap;
List<XYZ> pts = new List<XYZ>();
List<XYZ> lastpoints = new List<XYZ>();
XYZ zdir1 = null;
XYZ zdir2 = null;
XYZ offestVector = null;
double d1 = 0.0;
double d2 = 0.0;
//切分基准线后两侧向量不为0
if (!v1.IsAlmostEqualTo(XYZ.Zero))
{
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));
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;
d1 = lastp1.DistanceTo(endpoint1) - length / 2 - gap;
var lastfinalpoint = lastp1 + (l1.Direction * (d1 / 2 + length / 2 + gap)) + (offestVector * width / 2);
lastpoints.Add(lastfinalpoint);
break;
}
XYZ p = l1.Evaluate(parameter, false);
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);
}
pts.Add(finalPoint);
}
}
if (!v2.IsAlmostEqualTo(XYZ.Zero))
{
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));
for (int i = 0; i < 10000; i++)
{
var parameter = i * interval;
if (!l2.IsInside(parameter + interval - gap / 2))
{
//var lastdistance = pts.Last().DistanceTo(endp1) - interval / 2 - gap / 2;
var lastp2 = pts.Last() - offestVector * width / 2;
d2 = lastp2.DistanceTo(endpoint2) - length / 2 - gap;
var lastFinalPoint = lastp2 + (l2.Direction * (d2 / 2 + length / 2 + gap)) + (offestVector * width / 2);
lastpoints.Add(lastFinalPoint);
break;
}
XYZ p = l2.Evaluate(parameter, false);
//附加的基准线的水平垂直偏移距离
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);
}
pts.Add(finalpoint);
}
//var lastl2 = pts.Last().DistanceTo(endp2);
}
doc.Invoke(ts =>
{
//删除模型线
doc.Delete(modelCurveIds);
family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "FloorFinish\\地砖.rfa");
ElementId symbolId = family.GetFamilySymbolIds().FirstOrDefault();
symbol = doc.GetElement(symbolId) as FamilySymbol;
symbol.Activate();
foreach (var p in pts)
{
var fi = doc.Create
.NewFamilyInstance(p, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instances.Add(fi);
}
foreach (var p in lastpoints)
{
var fi = doc.Create
.NewFamilyInstance(p, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instances.Add(fi);
}
}, "地面铺装");
doc.Invoke(ts =>
{
XYZ veroffestdir = null;
if (zdir1 != null)
{
veroffestdir = zdir1.CrossProduct(referline.Direction).Normalize();
}
if (zdir2 != null)
{
veroffestdir = zdir2.CrossProduct(referline.Direction).Normalize();
}
//旋转角度
double angle = XYZ.BasisY.AngleTo(veroffestdir);
//判断相对于Y轴是正向角度逆时针还是逆向角度顺时针
var z = veroffestdir.CrossProduct(XYZ.BasisY).Normalize();
if (z.IsAlmostEqualTo(XYZ.BasisZ))
{
//逆向旋转,角度取负值
angle = -angle;
}
//单行调整地砖数量
int n = 0;
if (v2.IsAlmostEqualTo(XYZ.Zero) || v1.IsAlmostEqualTo(XYZ.Zero))
{
n = 1;
}
else
{
n = 2;
}
for (int i = 0; i < instances.Count; i++)
{
FamilyInstance fi = instances[i];
var filp = RsRevitUtils.GetLocationPointByElement(fi);
Line zaxis = Line.CreateUnbound(filp, XYZ.BasisZ);
//旋转,移动
ElementTransformUtils.RotateElement(doc, fi.Id, zaxis, angle);
fi.GetParameters("长").FirstOrDefault().Set(length);
fi.GetParameters("宽").FirstOrDefault().Set(width);
if (i >= instances.Count - n)
{
var loc = RsRevitUtils.GetLocationPointByElement(instances[i]);
var dis1 = loc.DistanceTo(endpoint1);
var dis2 = loc.DistanceTo(endpoint2);
if (dis1 < interval)
{
fi.GetParameters("长").FirstOrDefault().Set(d1);
}
else if (dis2 < interval)
{
fi.GetParameters("长").FirstOrDefault().Set(d2);
}
}
//ElementTransformUtils.CopyElement(doc, fi.Id, offestvector * (width + gap));
////垂直基准线平移
//ElementTransformUtils.MoveElement(doc, fi.Id, offestdir);
////平行基准线平移
//ElementTransformUtils.MoveElement(doc, fi.Id, line.Direction * w / 2);
//if (i >= 1)
//{
// XYZ additionaldir = zdir.CrossProduct(line.Direction).Normalize() * i * (passagewidth + l);
// ElementTransformUtils.MoveElement(doc, fi.Id, additionaldir);
//}
//位于直线右侧时,需要进行左右翻转
//if (OnLeft == false && fi.CanFlipHand)
//{
// fi.flipHand();
//}
}
}, "调整地砖");
doc.Invoke(ts =>
{
List<ElementId> idsCopied = new List<ElementId>();
for (int i = 0; i < instances.Count; i++)
{
FamilyInstance fi = instances[i];
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));
FamilyInstance copyinstance = doc.GetElement(eles.FirstOrDefault()) as FamilyInstance;
copyinstance.GetParameters("宽").FirstOrDefault().Set(rem);
idsCopied.AddRange(eles.ToList());
break;
}
eles = ElementTransformUtils.CopyElement(doc, fi.Id, offestVector * (width + gap) * j);
idsCopied.AddRange(eles.ToList());
}
}
foreach (var id in idsCopied)
{
FamilyInstance instanceCopied = doc.GetElement(id) as FamilyInstance;
if (instanceCopied.Room == null)
{
doc.Delete(id);
}
}
}, "复制地砖");
#region MyRegion
//foreach (var seg in segments)
//{
// Curve cur = seg.GetCurve();
// if (cur.GetEndPoint(0).IsAlmostEqualTo(startP) || cur.GetEndPoint(1).IsAlmostEqualTo(startP))
// {
// currefer = cur;
// }
// if (cur.GetEndPoint(1).IsAlmostEqualTo(startP))
// {
// currefer1 = cur;
// }
// //XYZ p1 = cur.Evaluate(100 / 304.8, false);
// //XYZ p2 = cur.Evaluate(200 / 304.8, false);
//}
//var n = Math.Floor(currefer1.Length / interval) + 1;
//var rem = currefer1.Length % interval / interval;
//var x = 0.5;
//if (rem < 0.334)
//{
// x = (1 + rem) / 4;
// for (int i = 0; i < n; i++)
// {
// Curve l = null;
// if (i == 0)
// {
// l = currefer.CreateOffset((i + x) * interval, -XYZ.BasisZ);
// }
// if (i >= 1)
// {
// l = currefer.CreateOffset((i - 0.5 + 2 * x) * interval, -XYZ.BasisZ);
// }
// if (i == n - 1)
// {
// l = currefer.CreateOffset((i - 1 + 3 * x) * interval, -XYZ.BasisZ);
// }
// curves.Add(l);
// }
//}
//else
//{
// for (int i = 0; i < n; i++)
// {
// //var v = cur.Direction.CrossProduct(XYZ.BasisZ);
// //createoffset的偏移方向由线方向 叉乘 自己给定的方向
// var l = currefer.CreateOffset((i + x) * interval, -XYZ.BasisZ);
// if (i == n - 1)
// {
// l = currefer.CreateOffset((i - 1 + x) * interval, -XYZ.BasisZ);
// }
// curves.Add(l);
// }
//}
//var m = Math.Floor(currefer.Length / interval) + 1;
//var rem1 = currefer.Length % interval / interval;
//x = 0.5;
//if (rem1 < 0.334)
//{
// x = (1 + rem1) / 4;
// for (int i = 0; i < m; i++)
// {
// Curve l = null;
// if (i == 0)
// {
// l = currefer1.CreateOffset((i + x) * interval, -XYZ.BasisZ);
// }
// if (i >= 1)
// {
// l = currefer1.CreateOffset((i - 0.5 + 2 * x) * interval, -XYZ.BasisZ);
// }
// if (i == m - 1)
// {
// l = currefer1.CreateOffset((i - 1 + 3 * x) * interval, -XYZ.BasisZ);
// }
// curves.Add(l);
// }
//}
//else
//{
// for (int i = 0; i < m; i++)
// {
// var l = currefer1.CreateOffset((i + x) * interval, -XYZ.BasisZ);
// if (i == m - 1)
// {
// l = currefer.CreateOffset((i - 1 + x) * interval, -XYZ.BasisZ);
// }
// curves.Add(l);
// }
//}
//var pts = GetIntersectPoints(curves);
//Plane pl = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ());
//foreach (var item in curves)
//{
// ModelCurve model = doc.Create.NewModelCurve(item, SketchPlane.Create(doc, pl));
//}
//foreach (var p in pts)
//{
// var fi = doc.Create
// .NewFamilyInstance(p, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
// instances.Add(fi);
//}
//foreach (var fi in instances)
//{
// var lp = fi.Location as LocationPoint;
// var p = lp.Point;
// foreach (var seg in segments)
// {
// var l = seg.GetCurve() as Line;
// if (l.Distance(p) - ((1 + rem) / 4 * interval) < 0.001)
// {
// if (l.Direction.X < 0.001)
// {
// fi.GetParameters("长度").FirstOrDefault().Set((1 + rem) / 2 * (interval - halfgap));
// }
// else if (l.Direction.Y < 0.001)
// {
// fi.GetParameters("宽度").FirstOrDefault().Set((1 + rem) / 2 * (interval - halfgap));
// }
// }
// else if (l.Distance(p) - ((1 + rem1) / 4 * interval) < 0.001)
// {
// if (l.Direction.X < 0.001)
// {
// fi.GetParameters("长度").FirstOrDefault().Set((1 + rem1) / 2 * (interval - halfgap));
// }
// else if (l.Direction.Y < 0.001)
// {
// fi.GetParameters("宽度").FirstOrDefault().Set((1 + rem1) / 2 * (interval - halfgap));
// }
// }
// if (true)
// {
// }
// }
//}
//Do Something.
#endregion MyRegion
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
if (tg.GetStatus() == TransactionStatus.Started)
{
tg.RollBack();
}
return Result.Succeeded;
}
return Result.Succeeded;
}, "地面铺装");
}
private List<XYZ> GetIntersectPoints(List<Curve> curves)
{
//获取轴网的所有交点
List<XYZ> Points = new List<XYZ>();
foreach (Curve curve in curves)
{
Curve currentCurve = curve;
foreach (Curve cur in curves)
{
IntersectionResultArray ira = null;
SetComparisonResult scr = currentCurve.Intersect(cur, out ira);
if (scr == SetComparisonResult.Overlap && ira.Size == 1)
{
XYZ tp = ira.get_Item(0).XYZPoint;
if (Points.Where(m => m.IsAlmostEqualTo(tp)).Count() == 0)
{
Points.Add(tp); //收集所有的交点
}
}
}
}
return Points;
}
//public class SelectionFilter : ISelectionFilter
//{
// public bool AllowElement(Element element)
// {
// if (element.Category.Id.IntegerValue == -2000160)
// {
// return true;
// }
// return false;
// }
// public bool AllowReference(Reference refer, XYZ point)
// {
// return false;
// }
//}
}
}

View File

@@ -1,6 +1,7 @@
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using RookieStation.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -96,7 +97,7 @@ namespace RookieStation
}
catch (Exception ex)
{
message = ex.Message;
Log.WriteLog(ex.Message);
if (trans.GetStatus() == TransactionStatus.Started)
{
trans.RollBack();

View File

@@ -60,6 +60,7 @@ namespace RookieStation
trans.Commit();
}
}
//var fas = RevitCommonUtils.GetFacesByFamilyInstance(instance, opt);
//var fas = RevitCommonUtils.GetFamilyInstanceFaces(instance, opt);
@@ -77,8 +78,6 @@ namespace RookieStation
//}
//refArry.Append(reffaces.First().Reference);
//refArry.Append(reffaces.Last().Reference);
}
return Result.Succeeded;
}
}

View File

@@ -85,7 +85,12 @@ namespace RookieStation.PackAreaModule
Document doc = uidoc.Document;
fis = new List<FamilyInstance>();
Level level = uidoc.ActiveView.GenLevel;
Level baseLevel = doc.ActiveView.GenLevel;
if (baseLevel == null)
{
offest = 0.0;
return;
}
Family gateFamily = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "Gate\\闸机.rfa");
ElementId symbolId = gateFamily.GetFamilySymbolIds().FirstOrDefault();
FamilySymbol gateSymbol = doc.GetElement(symbolId) as FamilySymbol;
@@ -93,7 +98,7 @@ namespace RookieStation.PackAreaModule
gateSymbol.Activate();
foreach (XYZ p in points)
{
var instance = doc.Create.NewFamilyInstance(p, gateSymbol, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
var instance = doc.Create.NewFamilyInstance(p, gateSymbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
fis.Add(instance);
}
}

View File

@@ -109,6 +109,10 @@ namespace RookieStation.PackAreaModule
//ElementId symbolId = family.GetFamilySymbolIds().FirstOrDefault();
FamilySymbol leftSymbol = doc.GetElement(leftSymbolId.FirstOrDefault()) as FamilySymbol;
Level level = uidoc.ActiveView.GenLevel;
if (level == null)
{
return;
}
if (isPassageStart)//起始是通道
{
for (int i = 0; i < n; i++)

View File

@@ -5,9 +5,10 @@ using Autodesk.Revit.UI.Selection;
using RookieStation.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
namespace RookieStation.Finishes
{
@@ -15,522 +16,235 @@ namespace RookieStation.Finishes
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdPlaceFloorFinishes : IExternalCommand
{
private static string AddinPath = typeof(CmdPlaceFloorFinishes).Assembly.Location;
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;
Family family = null;
FamilySymbol symbol;
WpfFloorFinishes floorCovering = CommonUtils.GenerateWindow<WpfFloorFinishes>();
var roomcounts = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).OfClass(typeof(Room)).GetElementCount();
if (roomcounts == 0)
var baselevel = doc.ActiveView.GenLevel;
if (baselevel == null)
{
TaskDialog.Show("温馨提示", "项目中当前没有房间");
return Result.Cancelled;
return Result.Failed;
}
double length;
double width;
double gap;
WpfFloorFinishes floorCovering = CommonUtils.GenerateWindow<WpfFloorFinishes>();
double length, width, gap, thickness;
if (floorCovering.DialogResult == true)
{
length = floorCovering.PavementLength / 304.8;
width = floorCovering.PavementWidth / 304.8;
gap = floorCovering.PavementGap / 304.8;
length = floorCovering.PavementLength;
width = floorCovering.PavementWidth;
gap = floorCovering.PavementGap;
thickness = floorCovering.PavementThickness;
}
else
{
return Result.Cancelled;
}
return doc.InvokeGroup(tg =>
CreateCurtainSystemByFace(uidoc, doc, length, width, gap, thickness);
//CreateCurtainSystemByRoom(uidoc, length, width, gap, thickness);
return Result.Succeeded;
//ModelCurveArray mca = new ModelCurveArray();
//var roofTypes = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Roofs).OfClass(typeof(RoofType)).ToElements();
//RoofType roofType = null;
//foreach (RoofType rooftype in roofTypes)
//{
// if (rooftype.Name == "常规 - 400mm")
// {
// roofType = rooftype;
// break;
// }
//}
//doc.Invoke(ts =>
//{
// doc.Create.NewFootPrintRoof(curveArray, baselevel, roofType, out mca);
//});
}
private static void CreateCurtainSystemByFace(UIDocument uidoc, Document doc, double length, double width, double gap, double thickness)
{
Reference faceReference = uidoc.Selection.PickObject(ObjectType.Face, "请选择铺贴面");
Element element = doc.GetElement(faceReference);
Face face = element.GetGeometryObjectFromReference(faceReference) as Face;
FaceArray faceArray = new FaceArray();
faceArray.Append(face);
doc.InvokeGroup(tg =>
{
var curtainSystemType = SetCurtainSystemType(doc, length, width, gap, thickness);
doc.Invoke(ts =>
{
var eleid = doc.Create.NewCurtainSystem(faceArray, curtainSystemType);
});
});
}
private static void CreateCurtainSystemByRoom(UIDocument uidoc, double length, double width, double gap, double thickness)
{
Document doc = uidoc.Document;
var rooms = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms);
if (rooms.Count() == 0)
{
TaskDialog.Show("温馨提示", "项目中当前没有房间");
//return Result.Cancelled;
}
Reference refer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter<Room>(), "请选择布置的房间");
Room room = doc.GetElement(refer) as Room;
List<CurveLoop> curveLoops = new List<CurveLoop>();
var opts = new SpatialElementBoundaryOptions();
var segementsList = room.GetBoundarySegments(opts);
if (segementsList != null)
{
foreach (var boundarySegments in segementsList)
{
CurveLoop curveLoop = new CurveLoop();
foreach (var boundarySegment in boundarySegments)
{
curveLoop.Append(boundarySegment.GetCurve());
}
curveLoops.Add(curveLoop);
}
}
doc.InvokeGroup(tg =>
{
//平面视图Z方向
//doc.ActiveView.ViewDirection;
FaceArray array = new FaceArray();
DirectShape ds = null;
doc.Invoke(ts =>
{
Solid solid = GeometryCreationUtilities.CreateExtrusionGeometry(curveLoops, -XYZ.BasisZ, 10.0);
ds = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_Mass));
if (ds != null)
{
ds.AppendShape(new List<GeometryObject>() { solid });
}
//doc.Create.NewFamilyInstance(,,,)
foreach (Face face in solid.Faces)
{
PlanarFace pf = face as PlanarFace;
if (pf.FaceNormal.IsAlmostEqualTo(XYZ.BasisZ))
{
array.Append(face);
break;
}
}
}, "创建体量,获取底面");
CurtainSystemType curtainSystemType = SetCurtainSystemType(doc, length, width, gap, thickness);
doc.Invoke(ts =>
{
doc.Create.NewCurtainSystem(array, curtainSystemType);
if (ds != null)
{
doc.Delete(ds.Id);
}
}, "创建幕墙系统");
});
}
private static CurtainSystemType SetCurtainSystemType(Document doc, double length, double width, double gap, double thickness)
{
var curtainSystemTypeCollector = new FilteredElementCollector(doc).OfClass(typeof(CurtainSystemType)).OfCategory(BuiltInCategory.OST_CurtaSystem);
var panelTypeCollector = new FilteredElementCollector(doc).OfClass(typeof(PanelType)).OfCategory(BuiltInCategory.OST_CurtainWallPanels);
var curtainWallMullionsTypeCollector = new FilteredElementCollector(doc).OfClass(typeof(MullionType)).OfCategory(BuiltInCategory.OST_CurtainWallMullions);
CurtainSystemType curtainSystemType = null;
PanelType panelType = null;
MullionType mullionType = null;
string cutainSystemTypeName = String.Format("{0}{1}{2}{3}", length, " x ", width, "mm");
string panelTypeName = "铺贴";
string mullionTypeName = String.Format("{0}{1}{2}{3}", gap, " x ", thickness, "mm");
doc.Invoke(ts =>
{
try
{
//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>();
SelectFilter<Room> roomFilter = new SelectFilter<Room>();
Reference roomReference = uidoc.Selection.PickObject(ObjectType.Element, roomFilter, "请选择房间");
Room room = doc.GetElement(roomReference) as Room;
var roompoint = RsRevitUtils.GetLocationPointByElement(room);
var segments = room.GetBoundarySegments(new SpatialElementBoundaryOptions()).FirstOrDefault();
doc.Invoke(ts =>
{
foreach (var seg in segments)
{
Curve cur = seg.GetCurve();
Plane plane = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ());
var mc = doc.Create.NewModelCurve(cur, SketchPlane.Create(doc, plane));
modelCurveIds.Add(mc.Id);
PanelType defaultPanelType = panelTypeCollector.FirstOrDefault(p => p.Name.Contains("实体") || p.Name.Contains("Solid")) as PanelType;
panelType = defaultPanelType.Duplicate(panelTypeName) as PanelType;
}
}, "模型线创建");
//Reference edge = uidoc.Selection.PickObject(ObjectType.Edge, "请选择边界");
SelectFilter<ModelLine> mlFilter = new SelectFilter<ModelLine>();
Reference refline = uidoc.Selection.PickObject(ObjectType.Element, mlFilter, "请选择基准边线");
//模型线选取
var ml = doc.GetElement(refline) as ModelLine;
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)
catch (Autodesk.Revit.Exceptions.ArgumentException)
{
MessageBox.Show("请选择基准线上的点", "温馨提示");
return Result.Cancelled;
}
//if (basepoint.IsAlmostEqualTo(ml.GeometryCurve.GetEndPoint(0)) || basepoint.IsAlmostEqualTo(ml.GeometryCurve.GetEndPoint(1)))
//{
//}
//基准线端点
var endpoint1 = referline.GetEndPoint(0);
var endpoint2 = referline.GetEndPoint(1);
//基准点向端点的向量
XYZ v1 = endpoint1 - basePoint;
XYZ v2 = endpoint2 - basePoint;
//用于确认布置方向
var v0 = roompoint - basePoint;
List<Curve> curves = new List<Curve>();
List<FamilyInstance> instances = new List<FamilyInstance>();
//Curve currefer = null;
//Curve currefer1 = null;
double interval = length + gap;
List<XYZ> pts = new List<XYZ>();
List<XYZ> lastpoints = new List<XYZ>();
XYZ zdir1 = null;
XYZ zdir2 = null;
XYZ offestVector = null;
double d1 = 0.0;
double d2 = 0.0;
//切分基准线后两侧向量不为0
if (!v1.IsAlmostEqualTo(XYZ.Zero))
foreach (PanelType t in panelTypeCollector)
{
if (endpoint1.DistanceTo(basePoint) < length)
if (t.Name == panelTypeName)
{
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));
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;
d1 = lastp1.DistanceTo(endpoint1) - length / 2 - gap;
var lastfinalpoint = lastp1 + (l1.Direction * (d1 / 2 + length / 2 + gap)) + (offestVector * width / 2);
lastpoints.Add(lastfinalpoint);
panelType = t;
break;
}
XYZ p = l1.Evaluate(parameter, false);
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);
}
pts.Add(finalPoint);
}
}
if (!v2.IsAlmostEqualTo(XYZ.Zero))
}, "创建嵌板类型");
doc.Invoke(ts =>
{
if (endpoint2.DistanceTo(basePoint) < length)
try
{
System.Windows.MessageBox.Show("基准点与基准线端点距离太近");
return Result.Cancelled;
MullionType defaultMullionType = curtainWallMullionsTypeCollector.FirstOrDefault(m => ((MullionType)m).FamilyName.Contains("矩形") || ((MullionType)m).FamilyName.Contains("Rectangular")) as MullionType;
mullionType = defaultMullionType.Duplicate(mullionTypeName) as MullionType;
}
zdir2 = v2.CrossProduct(v0).Normalize();
offestVector = zdir2.CrossProduct(v2).Normalize();
Line l2 = Line.CreateBound(basePoint, ml.GeometryCurve.GetEndPoint(1));
for (int i = 0; i < 10000; i++)
catch (Autodesk.Revit.Exceptions.ArgumentException)
{
var parameter = i * interval;
if (!l2.IsInside(parameter + interval - gap / 2))
foreach (MullionType t in curtainWallMullionsTypeCollector)
{
//var lastdistance = pts.Last().DistanceTo(endp1) - interval / 2 - gap / 2;
var lastp2 = pts.Last() - offestVector * width / 2;
d2 = lastp2.DistanceTo(endpoint2) - length / 2 - gap;
var lastFinalPoint = lastp2 + (l2.Direction * (d2 / 2 + length / 2 + gap)) + (offestVector * width / 2);
lastpoints.Add(lastFinalPoint);
if (t.Name == mullionTypeName)
{
mullionType = t;
break;
}
XYZ p = l2.Evaluate(parameter, false);
//附加的基准线的水平垂直偏移距离
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);
}
pts.Add(finalpoint);
}
//var lastl2 = pts.Last().DistanceTo(endp2);
}
}, "创建竖挺类型");
doc.Invoke(ts =>
{
//删除模型线
doc.Delete(modelCurveIds);
family = RsRevitUtils.GetLoadedFamily(doc, UserConstant.FamilyLibraryDirectory + "FloorFinish\\地砖.rfa");
ElementId symbolId = family.GetFamilySymbolIds().FirstOrDefault();
symbol = doc.GetElement(symbolId) as FamilySymbol;
symbol.Activate();
foreach (var p in pts)
try
{
var fi = doc.Create
.NewFamilyInstance(p, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instances.Add(fi);
CurtainSystemType defaultCurtainSystemType = curtainSystemTypeCollector.FirstOrDefault() as CurtainSystemType;
curtainSystemType = defaultCurtainSystemType.Duplicate(cutainSystemTypeName) as CurtainSystemType;
}
foreach (var p in lastpoints)
catch (Autodesk.Revit.Exceptions.ArgumentException)
{
var fi = doc.Create
.NewFamilyInstance(p, symbol, baseLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
instances.Add(fi);
}
}, "地面铺装");
doc.Invoke(ts =>
foreach (CurtainSystemType t in curtainSystemTypeCollector)
{
XYZ veroffestdir = null;
if (zdir1 != null)
if (t.Name == cutainSystemTypeName)
{
veroffestdir = zdir1.CrossProduct(referline.Direction).Normalize();
}
if (zdir2 != null)
{
veroffestdir = zdir2.CrossProduct(referline.Direction).Normalize();
}
//旋转角度
double angle = XYZ.BasisY.AngleTo(veroffestdir);
//判断相对于Y轴是正向角度逆时针还是逆向角度顺时针
var z = veroffestdir.CrossProduct(XYZ.BasisY).Normalize();
if (z.IsAlmostEqualTo(XYZ.BasisZ))
{
//逆向旋转,角度取负值
angle = -angle;
}
//单行调整地砖数量
int n = 0;
if (v2.IsAlmostEqualTo(XYZ.Zero) || v1.IsAlmostEqualTo(XYZ.Zero))
{
n = 1;
}
else
{
n = 2;
}
for (int i = 0; i < instances.Count; i++)
{
FamilyInstance fi = instances[i];
var filp = RsRevitUtils.GetLocationPointByElement(fi);
Line zaxis = Line.CreateUnbound(filp, XYZ.BasisZ);
//旋转,移动
ElementTransformUtils.RotateElement(doc, fi.Id, zaxis, angle);
fi.GetParameters("长").FirstOrDefault().Set(length);
fi.GetParameters("宽").FirstOrDefault().Set(width);
if (i >= instances.Count - n)
{
var loc = RsRevitUtils.GetLocationPointByElement(instances[i]);
var dis1 = loc.DistanceTo(endpoint1);
var dis2 = loc.DistanceTo(endpoint2);
if (dis1 < interval)
{
fi.GetParameters("长").FirstOrDefault().Set(d1);
}
else if (dis2 < interval)
{
fi.GetParameters("长").FirstOrDefault().Set(d2);
}
}
//ElementTransformUtils.CopyElement(doc, fi.Id, offestvector * (width + gap));
////垂直基准线平移
//ElementTransformUtils.MoveElement(doc, fi.Id, offestdir);
////平行基准线平移
//ElementTransformUtils.MoveElement(doc, fi.Id, line.Direction * w / 2);
//if (i >= 1)
//{
// XYZ additionaldir = zdir.CrossProduct(line.Direction).Normalize() * i * (passagewidth + l);
// ElementTransformUtils.MoveElement(doc, fi.Id, additionaldir);
//}
//位于直线右侧时,需要进行左右翻转
//if (OnLeft == false && fi.CanFlipHand)
//{
// fi.flipHand();
//}
}
}, "调整地砖");
doc.Invoke(ts =>
{
List<ElementId> idsCopied = new List<ElementId>();
for (int i = 0; i < instances.Count; i++)
{
FamilyInstance fi = instances[i];
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));
FamilyInstance copyinstance = doc.GetElement(eles.FirstOrDefault()) as FamilyInstance;
copyinstance.GetParameters("宽").FirstOrDefault().Set(rem);
idsCopied.AddRange(eles.ToList());
curtainSystemType = t;
break;
}
eles = ElementTransformUtils.CopyElement(doc, fi.Id, offestVector * (width + gap) * j);
idsCopied.AddRange(eles.ToList());
}
}
foreach (var id in idsCopied)
}, "创建幕墙系统类型");
doc.Invoke(ts =>
{
FamilyInstance instanceCopied = doc.GetElement(id) as FamilyInstance;
if (instanceCopied.Room == null)
mullionType.get_Parameter(BuiltInParameter.RECT_MULLION_WIDTH1).Set(gap / 304.8 / 2);
mullionType.get_Parameter(BuiltInParameter.RECT_MULLION_WIDTH2).Set(gap / 304.8 / 2);
mullionType.get_Parameter(BuiltInParameter.RECT_MULLION_THICK).Set(thickness / 304.8 * 2);
//mullionType.get_Parameter(BuiltInParameter.MULLION_OFFSET).Set(0);
//mullionType.get_Parameter(BuiltInParameter.MULLION_OFFSET).Set(thickness / 304.8 * 0.75 / 2);
panelType.get_Parameter(BuiltInParameter.CURTAIN_WALL_SYSPANEL_THICKNESS).Set(thickness / 304.8 * 2);
//panelType.get_Parameter(BuiltInParameter.CURTAIN_WALL_SYSPANEL_OFFSET).Set(0);
//panelType.get_Parameter(BuiltInParameter.CURTAIN_WALL_SYSPANEL_OFFSET).Set(-thickness / 304.8 / 2);
curtainSystemType.get_Parameter(BuiltInParameter.SPACING_LENGTH_1).Set((length + gap) / 304.8);
curtainSystemType.get_Parameter(BuiltInParameter.SPACING_LENGTH_2).Set((width + gap) / 304.8);
try
{
doc.Delete(id);
curtainSystemType.get_Parameter(BuiltInParameter.AUTO_PANEL).Set(panelType.Id);
curtainSystemType.get_Parameter(BuiltInParameter.AUTO_MULLION_INTERIOR_GRID1).Set(mullionType.Id);
curtainSystemType.get_Parameter(BuiltInParameter.AUTO_MULLION_INTERIOR_GRID2).Set(mullionType.Id);
}
}
}, "复制地砖");
#region MyRegion
//foreach (var seg in segments)
//{
// Curve cur = seg.GetCurve();
// if (cur.GetEndPoint(0).IsAlmostEqualTo(startP) || cur.GetEndPoint(1).IsAlmostEqualTo(startP))
// {
// currefer = cur;
// }
// if (cur.GetEndPoint(1).IsAlmostEqualTo(startP))
// {
// currefer1 = cur;
// }
// //XYZ p1 = cur.Evaluate(100 / 304.8, false);
// //XYZ p2 = cur.Evaluate(200 / 304.8, false);
//}
//var n = Math.Floor(currefer1.Length / interval) + 1;
//var rem = currefer1.Length % interval / interval;
//var x = 0.5;
//if (rem < 0.334)
//{
// x = (1 + rem) / 4;
// for (int i = 0; i < n; i++)
// {
// Curve l = null;
// if (i == 0)
// {
// l = currefer.CreateOffset((i + x) * interval, -XYZ.BasisZ);
// }
// if (i >= 1)
// {
// l = currefer.CreateOffset((i - 0.5 + 2 * x) * interval, -XYZ.BasisZ);
// }
// if (i == n - 1)
// {
// l = currefer.CreateOffset((i - 1 + 3 * x) * interval, -XYZ.BasisZ);
// }
// curves.Add(l);
// }
//}
//else
//{
// for (int i = 0; i < n; i++)
// {
// //var v = cur.Direction.CrossProduct(XYZ.BasisZ);
// //createoffset的偏移方向由线方向 叉乘 自己给定的方向
// var l = currefer.CreateOffset((i + x) * interval, -XYZ.BasisZ);
// if (i == n - 1)
// {
// l = currefer.CreateOffset((i - 1 + x) * interval, -XYZ.BasisZ);
// }
// curves.Add(l);
// }
//}
//var m = Math.Floor(currefer.Length / interval) + 1;
//var rem1 = currefer.Length % interval / interval;
//x = 0.5;
//if (rem1 < 0.334)
//{
// x = (1 + rem1) / 4;
// for (int i = 0; i < m; i++)
// {
// Curve l = null;
// if (i == 0)
// {
// l = currefer1.CreateOffset((i + x) * interval, -XYZ.BasisZ);
// }
// if (i >= 1)
// {
// l = currefer1.CreateOffset((i - 0.5 + 2 * x) * interval, -XYZ.BasisZ);
// }
// if (i == m - 1)
// {
// l = currefer1.CreateOffset((i - 1 + 3 * x) * interval, -XYZ.BasisZ);
// }
// curves.Add(l);
// }
//}
//else
//{
// for (int i = 0; i < m; i++)
// {
// var l = currefer1.CreateOffset((i + x) * interval, -XYZ.BasisZ);
// if (i == m - 1)
// {
// l = currefer.CreateOffset((i - 1 + x) * interval, -XYZ.BasisZ);
// }
// curves.Add(l);
// }
//}
//var pts = GetIntersectPoints(curves);
//Plane pl = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ());
//foreach (var item in curves)
//{
// ModelCurve model = doc.Create.NewModelCurve(item, SketchPlane.Create(doc, pl));
//}
//foreach (var p in pts)
//{
// var fi = doc.Create
// .NewFamilyInstance(p, symbol, baselevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
// instances.Add(fi);
//}
//foreach (var fi in instances)
//{
// var lp = fi.Location as LocationPoint;
// var p = lp.Point;
// foreach (var seg in segments)
// {
// var l = seg.GetCurve() as Line;
// if (l.Distance(p) - ((1 + rem) / 4 * interval) < 0.001)
// {
// if (l.Direction.X < 0.001)
// {
// fi.GetParameters("长度").FirstOrDefault().Set((1 + rem) / 2 * (interval - halfgap));
// }
// else if (l.Direction.Y < 0.001)
// {
// fi.GetParameters("宽度").FirstOrDefault().Set((1 + rem) / 2 * (interval - halfgap));
// }
// }
// else if (l.Distance(p) - ((1 + rem1) / 4 * interval) < 0.001)
// {
// if (l.Direction.X < 0.001)
// {
// fi.GetParameters("长度").FirstOrDefault().Set((1 + rem1) / 2 * (interval - halfgap));
// }
// else if (l.Direction.Y < 0.001)
// {
// fi.GetParameters("宽度").FirstOrDefault().Set((1 + rem1) / 2 * (interval - halfgap));
// }
// }
// if (true)
// {
// }
// }
//}
//Do Something.
#endregion MyRegion
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
catch (Exception)
{
if (tg.GetStatus() == TransactionStatus.Started)
{
tg.RollBack();
throw;
}
return Result.Succeeded;
}, "设置参数");
return curtainSystemType;
}
return Result.Succeeded;
}, "地面铺装");
}
private List<XYZ> GetIntersectPoints(List<Curve> curves)
{
//获取轴网的所有交点
List<XYZ> Points = new List<XYZ>();
foreach (Curve curve in curves)
{
Curve currentCurve = curve;
foreach (Curve cur in curves)
{
IntersectionResultArray ira = null;
SetComparisonResult scr = currentCurve.Intersect(cur, out ira);
if (scr == SetComparisonResult.Overlap && ira.Size == 1)
{
XYZ tp = ira.get_Item(0).XYZPoint;
if (Points.Where(m => m.IsAlmostEqualTo(tp)).Count() == 0)
{
Points.Add(tp); //收集所有的交点
}
}
}
}
return Points;
}
//public class SelectionFilter : ISelectionFilter
//{
// public bool AllowElement(Element element)
// {
// if (element.Category.Id.IntegerValue == -2000160)
// {
// return true;
// }
// return false;
// }
// public bool AllowReference(Reference refer, XYZ point)
// {
// return false;
// }
//}
}
}

View File

@@ -30,8 +30,8 @@ namespace RookieStation.PackAreaModule
double leftRightDistance = 0.0;
double frontDistance = 0.0;
var roomCount = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).GetElementCount();
if (roomCount == 0)
var rooms = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms);
if (rooms.Count() == 0)
{
TaskDialog.Show("温馨提示", "项目中当前没有房间");
return Result.Cancelled;
@@ -53,21 +53,26 @@ namespace RookieStation.PackAreaModule
{
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);
List<ElementId> modelCurveIds = new List<ElementId>();
if (uidoc.ActiveView.ViewType != ViewType.FloorPlan)
{
uidoc.RequestViewChange(v);
}
//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);
//if (uidoc.ActiveView.ViewType != ViewType.FloorPlan)
//{
// uidoc.RequestViewChange(v);
//}
Level baseLevel = doc.ActiveView.GenLevel;
if (baseLevel == null)
{
return Result.Failed;
}
SelectFilter<Room> roomFilter = new SelectFilter<Room>();
Reference roomReference = uidoc.Selection.PickObject(ObjectType.Element, roomFilter, "请选择房间");
Room room = doc.GetElement(roomReference) as Room;

View File

@@ -93,6 +93,10 @@ namespace RookieStation.ShippingAreaModule
return Result.Cancelled;
}
Level baseLevel = uidoc.ActiveView.GenLevel;
if (baseLevel == null)
{
return Result.Failed;
}
Family family = null;
FamilySymbol symbol;
return doc.InvokeGroup<Result>(tg =>
@@ -149,7 +153,7 @@ namespace RookieStation.ShippingAreaModule
if (n == 0)
{
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);
var wall = Wall.Create(doc, offestline, aluminumPlasticPanelType.Id, baseLevel.Id, aluminumPlasticPanelHeight, skirtingLineHeight, false, false);
wallIds.Add(wall.Id);
}
else
@@ -165,7 +169,7 @@ namespace RookieStation.ShippingAreaModule
}
Line line = Line.CreateBound(startpoint, endpoint);
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);
var wall = Wall.Create(doc, offestline, aluminumPlasticPanelType.Id, baseLevel.Id, aluminumPlasticPanelHeight, skirtingLineHeight, false, false);
//不允许连接
WallUtils.DisallowWallJoinAtEnd(wall, 0);
//curves.Add()
@@ -174,18 +178,18 @@ namespace RookieStation.ShippingAreaModule
}
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);
var skirtingwall = Wall.Create(doc, skirtingOffestLine, skirtingLineType.Id, baseLevel.Id, skirtingLineHeight, 0, false, false);
wallIds.Add(skirtingwall.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);
var baseLayerWall = Wall.Create(doc, baseLayerOffestLine, baseLayerType.Id, baseLevel.Id, UserConstant.Height / 304.8, 0, false, false);
wallIds.Add(baseLayerWall.Id);
//高度大于3000才有灰色乳胶漆
if (UserConstant.Height > 3000)
{
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);
Wall greyPaintWall = Wall.Create(doc, greyEmulsionPaintOffestLine, greyEmulsionPaintType.Id, baseLevel.Id, UserConstant.Height / 304.8 - baseHeight, baseHeight, false, false);
wallIds.Add(greyPaintWall.Id);
}

View File

@@ -54,7 +54,10 @@ namespace RookieStation.PackAreaModule
ObservableCollection<Shelf> shelves = vm.Data;
Level level = uidoc.ActiveView.GenLevel;
if (level == null)
{
return Result.Failed;
}
return doc.InvokeGroup<Result>(tg =>
{
try

View File

@@ -46,7 +46,6 @@ namespace RookieStation.Finishes
}
catch (Exception ex)
{
TaskDialog.Show("错误", ex.Message);
Log.WriteLog(ex.Message);
}
finally
@@ -68,13 +67,15 @@ namespace RookieStation.Finishes
{
while (isContinue)
{
var baselevel = doc.ActiveView.GenLevel;
if (placeType == "房间")
{
var roomCount = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).GetElementCount();
if (roomCount == 0)
var rooms = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms);
if (rooms.Count() == 0)
{
TaskDialog.Show("温馨提示", "项目中当前没有房间");
return Result.Failed;
return Result.Cancelled;
}
Reference refer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter<Room>(), "请选择布置的房间");
Room room = uidoc.Document.GetElement(refer) as Room;
@@ -134,7 +135,7 @@ namespace RookieStation.Finishes
//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 wallCreated = Wall.Create(doc, curve, wallType.Id, doc.ActiveView.GenLevel.Id, wallHeight / 304.8, wallBaseOffest / 304.8, false, false);
var wallCreated = Wall.Create(doc, curve, wallType.Id, baselevel.Id, wallHeight / 304.8, wallBaseOffest / 304.8, false, false);
wallCreated.get_Parameter(BuiltInParameter.WALL_ATTR_ROOM_BOUNDING).Set(0);
doc.Regenerate();
//连接墙体让门窗可以剪切出来
@@ -142,9 +143,20 @@ namespace RookieStation.Finishes
{
Element elemToJoin = doc.GetElement(wallToJoinList[i][j]);
try
{
if (wallCreated.WallType.Kind == WallKind.Stacked)
{
foreach (var wallid in wallCreated.GetStackedWallMemberIds())
{
Wall stackedwall = doc.GetElement(wallid) as Wall;
JoinGeometryUtils.JoinGeometry(doc, elemToJoin, stackedwall);
}
}
else
{
JoinGeometryUtils.JoinGeometry(doc, elemToJoin, wallCreated);
}
}
catch (Exception ex)
{
Log.WriteLog(ex.Message);
@@ -168,14 +180,26 @@ namespace RookieStation.Finishes
face.Intersect(bottomFace, out instersectCurve);
doc.Invoke(ts =>
{
Curve curve = instersectCurve.CreateOffset(wallWidth / 2, XYZ.BasisZ);
Curve curve = instersectCurve.CreateOffset(wallWidth / 2, XYZ.BasisZ).CreateReversed();
var wallCreated = Wall.Create(doc, curve, wallType.Id, doc.ActiveView.GenLevel.Id, wallHeight / 304.8, wallBaseOffest / 304.8, false, false);
var wallCreated = Wall.Create(doc, curve, wallType.Id, baselevel.Id, wallHeight / 304.8, wallBaseOffest / 304.8, false, false);
doc.Regenerate();
try
{
if (wallCreated.WallType.Kind == WallKind.Stacked)
{
foreach (var wallid in wallCreated.GetStackedWallMemberIds())
{
Wall stackedwall = doc.GetElement(wallid) as Wall;
JoinGeometryUtils.JoinGeometry(doc, wall, stackedwall);
}
}
else
{
JoinGeometryUtils.JoinGeometry(doc, wall, wallCreated);
}
//JoinGeometryUtils.JoinGeometry(doc, wall, wallCreated);
}
catch (Exception ex)
{
Log.WriteLog(ex.Message);
@@ -216,13 +240,25 @@ namespace RookieStation.Finishes
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);
var wallCreated = Wall.Create(doc, curve, wallType.Id, baselevel.Id, wallHeight / 304.8, wallBaseOffest / 304.8, false, false);
doc.Regenerate();
try
{
if (wallCreated.WallType.Kind == WallKind.Stacked)
{
foreach (var wallid in wallCreated.GetStackedWallMemberIds())
{
Wall stackedwall = doc.GetElement(wallid) as Wall;
JoinGeometryUtils.JoinGeometry(doc, wall, stackedwall);
}
}
else
{
JoinGeometryUtils.JoinGeometry(doc, wall, wallCreated);
}
//JoinGeometryUtils.JoinGeometry(doc, wall, wallCreated);
}
catch (Exception ex)
{
Log.WriteLog(ex.Message);

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Interop;
using System.Windows.Media.Imaging;
using System.Windows;
using RookieStation.Utils;
namespace RookieStation
{
internal class FamilyInfo
{
public FamilyInfo(string fullFileName)
{
FullFileName = fullFileName;
}
public string FullFileName { get; internal set; }
public BitmapSource ImageData => LoadImage(FullFileName, 128, 128);
public string Title => Path.GetFileNameWithoutExtension(FullFileName);
public string ToolTip { get; set; }
public FileInfo FileInfo { get; set; }
private BitmapSource LoadImage(string filename, int width, int height)
{
Bitmap bm = WindowsThumbnailProvider.GetThumbnail(filename, width, height, ThumbnailOptions.None);
return Imaging.CreateBitmapSourceFromHBitmap(bm.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
}
}
}

View File

@@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RookieStation
namespace RookieStation.PackAreaModule
{
public class Shelf
{

View File

@@ -14,7 +14,17 @@ namespace RookieStation
public static string AddinDirectory => System.IO.Path.GetDirectoryName(AddinPath);
internal static string FamilyLibraryDirectory => AddinDirectory + "RsLibrary\\FamilyLibrary\\";
//打包路径
//internal static string FamilyLibraryDirectory => AddinDirectory + "\\FamilyLibrary\\";
//调试路径
internal static string FamilyLibraryDirectory => AddinDirectory + "\\RsLibrary\\FamilyLibrary\\";
//打包路径
//internal static string DocumentDirectory => AddinDirectory + "\\Document\\";
//调试路径
internal static string DocumentDirectory => AddinDirectory + "\\RsLibrary\\Document\\";
internal static ObjectSnapTypes SnapAll =>
ObjectSnapTypes.Intersections

View File

@@ -0,0 +1,59 @@
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using RookieStation.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RookieStation.CommonTools
{
internal class LoadFamilyHandler : IExternalEventHandler
{
public FamilyInfo FamilyInfo { get; set; }
public void Execute(UIApplication app)
{
try
{
Document doc = app.ActiveUIDocument.Document;
RsFamilyLoadOption familyLoadOption = new RsFamilyLoadOption();
Family family = null;
FamilySymbol fs = null;
doc.Invoke(ts =>
{
var canloaded = doc.LoadFamily(FamilyInfo.FullFileName, familyLoadOption, out family);
if (canloaded)
{
fs = doc.GetElement(family.GetFamilySymbolIds().FirstOrDefault()) as FamilySymbol;
if (!fs.IsActive)
{
fs.Activate();
}
}
else
{
TaskDialog.Show("温馨提示", "族已载入或载入失败。");
}
}, "载入-" + FamilyInfo.Title);
if (fs != null)
{
app.ActiveUIDocument.PromptForFamilyInstancePlacement(fs);
//app.ActiveUIDocument.PromptToPlaceElementTypeOnLegendView(fs);
}
}
catch (Exception e)
{
Log.WriteLog(e.Message);
}
}
public string GetName()
{
return "加载族";
}
}
}

View File

@@ -72,5 +72,17 @@ namespace RookieStation.Properties {
this["Shelves"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("C:\\ProgramData\\Autodesk\\Revit\\Addins\\2020\\RsLibrary\\FamilyLibrary")]
public string FamilyFolder {
get {
return ((string)(this["FamilyFolder"]));
}
set {
this["FamilyFolder"] = value;
}
}
}
}

View File

@@ -17,5 +17,8 @@
&lt;string&gt;单个,1500,400&lt;/string&gt;
&lt;/ArrayOfString&gt;</Value>
</Setting>
<Setting Name="FamilyFolder" Type="System.String" Scope="User">
<Value Profile="(Default)">C:\ProgramData\Autodesk\Revit\Addins\2020\RsLibrary\FamilyLibrary</Value>
</Setting>
</Settings>
</SettingsFile>

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 638 B

View File

@@ -2,7 +2,7 @@
<RevitAddIns>
<AddIn Type="Application">
<Name>菜鸟驿站插件</Name>
<Assembly>\RsLibrary\RookieStation.dll</Assembly>
<Assembly>RsLibrary\RookieStation.dll</Assembly>
<ClientId>1aac8233-690c-4dd6-89c0-78221dd65497</ClientId>
<FullClassName>RookieStation.RsApp</FullClassName>
<VendorId>ADSK</VendorId>

View File

@@ -90,8 +90,11 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CmdExportWorkSchedule.cs" />
<Compile Include="CmdPlaceFloorFinishes.cs" />
<Compile Include="CmdLogoExtrusion.cs" />
<Compile Include="CmdPlaceWallFinishes.cs" />
<Compile Include="FamilyDockablePaneHandler.cs" />
<Compile Include="Common\FamilyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
@@ -107,13 +110,13 @@
<Compile Include="CmdPlaceShelves.cs" />
<Compile Include="Utils\CommonUtils.cs" />
<Compile Include="Utils\Log.cs" />
<Compile Include="Utils\ViewPlanCmdEnabled.cs" />
<Compile Include="Utils\EnableCmdInViewPlan.cs" />
<Compile Include="CmdPlaceEntranceGate.cs" />
<Compile Include="CmdPlaceExitGate.cs" />
<Compile Include="Utils\RsRevitUtils.cs" />
<Compile Include="CmdPlaceFloorFinishes.cs" />
<Compile Include="CmdFloorFinishes.cs" />
<Compile Include="CmdPlaceLamps.cs" />
<Compile Include="Custom\Enum.cs" />
<Compile Include="Common\Enum.cs" />
<Compile Include="Utils\ProjectConfigUtil.cs" />
<Compile Include="CmdProjectSettings.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -127,8 +130,9 @@
<Compile Include="ShelvesPlacementViewModel.cs" />
<Compile Include="Utils\SelectFilter.cs" />
<Compile Include="CmdPlaceReceptionArea.cs" />
<Compile Include="Custom\Shelf.cs" />
<Compile Include="Custom\UserConstant.cs" />
<Compile Include="Common\Shelf.cs" />
<Compile Include="Common\UserConstant.cs" />
<Compile Include="Utils\WindowsThumbnailProvider.cs" />
<Compile Include="Utils\WinIntPtr.cs" />
<Compile Include="WpfEntranceGate.xaml.cs">
<DependentUpon>WpfEntranceGate.xaml</DependentUpon>
@@ -136,6 +140,9 @@
<Compile Include="WpfExitGate.xaml.cs">
<DependentUpon>WpfExitGate.xaml</DependentUpon>
</Compile>
<Compile Include="WpfFamilyDockablePane.xaml.cs">
<DependentUpon>WpfFamilyDockablePane.xaml</DependentUpon>
</Compile>
<Compile Include="WpfFloorFinishes.xaml.cs">
<DependentUpon>WpfFloorFinishes.xaml</DependentUpon>
</Compile>
@@ -164,6 +171,7 @@
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Resource Include="Resources\Fonts\iconfont.ttf" />
<None Include="RsLibrary\Document\样板工程量清单.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
@@ -185,6 +193,9 @@
<None Include="RsLibrary\FamilyLibrary\Gate\L型收检台.rfa">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="RsLibrary\FamilyLibrary\Gate\直线形收检台.rfa">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="RsLibrary\FamilyLibrary\Gate\简易收检台.rfa">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
@@ -278,6 +289,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="WpfFamilyDockablePane.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="WpfFloorFinishes.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@@ -1,4 +1,10 @@
using Autodesk.Revit.UI;
using RookieStation.CommonTools;
using RookieStation.Finishes;
using RookieStation.PackAreaModule;
using RookieStation.ShippingAreaModule;
using RookieStation.Statistics;
using RookieStation.Utils;
using System;
using System.Collections.Generic;
using System.IO;
@@ -27,6 +33,8 @@ namespace RookieStation
//获取AddInPath的目录
private static string DirRequestAssembly = Path.GetDirectoryName(AddInPath);
private static string ViewPlanCmdEnabled = typeof(EnableCmdInViewPlan).ToString();
private BitmapSource ConvertFromBitmap(System.Drawing.Bitmap bitmap)
{
return Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
@@ -50,7 +58,7 @@ namespace RookieStation
//项目设置
RibbonPanel projectPanel = application.CreateRibbonPanel(TabName, ProjectSettingsPanelName);
PushButtonData projectPBD = new PushButtonData("项目设置", "项目设置", AddInPath, "RookieStation.CmdProjectSettings")
PushButtonData projectPBD = new PushButtonData("项目设置", "项目设置", AddInPath, typeof(CmdProjectSettings).FullName)
{
LargeImage = ConvertFromBitmap(Properties.Resources.cainiao),
Image = ConvertFromBitmap(Properties.Resources.cainiao)
@@ -58,21 +66,21 @@ namespace RookieStation
var projectBtn = (PushButton)projectPanel.AddItem(projectPBD);
//前台布置
RibbonPanel receptionAreaPanel = application.CreateRibbonPanel(TabName, ReceptionPanelName);
PushButtonData receptionLayoutPBD = new PushButtonData("寄件区布置", "前台布置", AddInPath, "RookieStation.ShippingAreaModule.CmdPlaceReceptionArea")
PushButtonData receptionLayoutPBD = new PushButtonData("寄件区布置", "前台布置", AddInPath, typeof(CmdPlaceReceptionArea).FullName)
{
LargeImage = ConvertFromBitmap(Properties.Resources.Reception),
Image = ConvertFromBitmap(Properties.Resources.Reception)
};
var receptionBtn = (PushButton)receptionAreaPanel.AddItem(receptionLayoutPBD);
receptionBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
receptionBtn.AvailabilityClassName = ViewPlanCmdEnabled;
//出入口布置
RibbonPanel packAreaPanel = application.CreateRibbonPanel(TabName, EntranceAndExitGatePanelName);
PushButtonData entrancegateLayoutPBD = new PushButtonData("入口布置", "入口闸机", AddInPath, "RookieStation.PackAreaModule.CmdPlaceEntranceGate")
PushButtonData entrancegateLayoutPBD = new PushButtonData("入口布置", "入口闸机", AddInPath, typeof(CmdPlaceEntranceGate).FullName)
{
LargeImage = ConvertFromBitmap(Properties.Resources.EntranceGate),
Image = ConvertFromBitmap(Properties.Resources.EntranceGate)
};
PushButtonData exitGateLayoutPBD = new PushButtonData("出口布置", "出口收检台", AddInPath, "RookieStation.PackAreaModule.CmdPlaceExitGate")
PushButtonData exitGateLayoutPBD = new PushButtonData("出口布置", "出口收检台", AddInPath, typeof(CmdPlaceExitGate).FullName)
{
LargeImage = ConvertFromBitmap(Properties.Resources.ExitGate),
Image = ConvertFromBitmap(Properties.Resources.ExitGate)
@@ -84,54 +92,54 @@ namespace RookieStation
//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";
entranceBtn.AvailabilityClassName = ViewPlanCmdEnabled;
exitBtn.AvailabilityClassName = ViewPlanCmdEnabled;
PushButtonData placeShelvesPBD = new PushButtonData("货架布置", "货架布置", AddInPath, "RookieStation.PackAreaModule.CmdPlaceShelves")
PushButtonData placeShelvesPBD = new PushButtonData("货架布置", "货架布置", AddInPath, typeof(CmdPlaceShelves).FullName)
{
LargeImage = ConvertFromBitmap(Properties.Resources.Shelf),
Image = ConvertFromBitmap(Properties.Resources.Shelf)
};
var placeShelvesBtn = (PushButton)packAreaPanel.AddItem(placeShelvesPBD);
placeShelvesBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
placeShelvesBtn.AvailabilityClassName = ViewPlanCmdEnabled;
PushButtonData placeShelveCardsPBD = new PushButtonData("货架端牌", "货架端牌", AddInPath, "RookieStation.PackAreaModule.CmdArrangeShelfCards")
PushButtonData placeShelveCardsPBD = new PushButtonData("货架端牌", "货架端牌", AddInPath, typeof(CmdArrangeShelfCards).FullName)
{
LargeImage = ConvertFromBitmap(Properties.Resources.ShelfCard),
Image = ConvertFromBitmap(Properties.Resources.ShelfCard)
};
var placeShelveCardsBtn = (PushButton)packAreaPanel.AddItem(placeShelveCardsPBD);
PushButtonData placeLampsPBD = new PushButtonData("灯具布置", "灯具布置", AddInPath, "RookieStation.PackAreaModule.CmdPlaceLamps")
PushButtonData placeLampsPBD = new PushButtonData("灯具布置", "灯具布置", AddInPath, typeof(CmdPlaceLamps).FullName)
{
LargeImage = ConvertFromBitmap(Properties.Resources.Lamp),
Image = ConvertFromBitmap(Properties.Resources.Lamp)
};
var placeLampsBtn = (PushButton)packAreaPanel.AddItem(placeLampsPBD);
placeLampsBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
placeLampsBtn.AvailabilityClassName = ViewPlanCmdEnabled;
//饰面,完成面
RibbonPanel finishesPanel = application.CreateRibbonPanel(TabName, FinishesPanelName);
PushButtonData floorfinishesPBD = new PushButtonData("地面铺装", "地面铺装", AddInPath, "RookieStation.Finishes.CmdPlaceFloorFinishes")
PushButtonData floorfinishesPBD = new PushButtonData("地面铺装", "地面铺装", AddInPath, typeof(CmdPlaceFloorFinishes).FullName)
{
LargeImage = ConvertFromBitmap(Properties.Resources.FloorFinishes),
Image = ConvertFromBitmap(Properties.Resources.FloorFinishes)
};
var floorcoveringBtn = (PushButton)finishesPanel.AddItem(floorfinishesPBD);
floorcoveringBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
floorcoveringBtn.AvailabilityClassName = ViewPlanCmdEnabled;
PushButtonData wallcoveringPBD = new PushButtonData("墙饰面", "墙饰面", AddInPath, "RookieStation.Finishes.CmdPlaceWallFinishes")
PushButtonData wallcoveringPBD = new PushButtonData("墙饰面", "墙饰面", AddInPath, typeof(CmdPlaceWallFinishes).FullName)
{
LargeImage = ConvertFromBitmap(Properties.Resources.WallFinishes),
Image = ConvertFromBitmap(Properties.Resources.WallFinishes)
};
var wallcoveringBtn = (PushButton)finishesPanel.AddItem(wallcoveringPBD);
wallcoveringBtn.AvailabilityClassName = "RookieStation.ViewPlanCmdEnabled";
wallcoveringBtn.AvailabilityClassName = ViewPlanCmdEnabled;
//统计面板
RibbonPanel statisticsPanel = application.CreateRibbonPanel(TabName, StatisticsPanelName);
PushButtonData statisticsfamilyPBD = new PushButtonData("输出统计表", "工程量统计", AddInPath, "RookieStation.Statistics.CmdExportWorkSchedule")
PushButtonData statisticsfamilyPBD = new PushButtonData("输出统计表", "工程量统计", AddInPath, typeof(CmdExportWorkSchedule).FullName)
{
LargeImage = ConvertFromBitmap(Properties.Resources.WorkSchedule),
Image = ConvertFromBitmap(Properties.Resources.WorkSchedule)
@@ -140,13 +148,14 @@ namespace RookieStation
//通用面板
RibbonPanel commonToolsPanel = application.CreateRibbonPanel(TabName, CommonTools);
PushButtonData browserfamilyPBD = new PushButtonData("浏览族", "浏览族文件", AddInPath, "RookieStation.CommonTools.CmdBrowserFamily")
PushButtonData browserfamilyPBD = new PushButtonData("浏览族", "浏览族文件", AddInPath, typeof(CmdBrowserFamily).FullName)
{
LargeImage = ConvertFromBitmap(Properties.Resources.FamilyLib),
Image = ConvertFromBitmap(Properties.Resources.FamilyLib)
};
commonToolsPanel.AddItem(browserfamilyPBD);
RegisterDockPane(application);
return Result.Succeeded;
#region MyRegion
@@ -205,9 +214,17 @@ namespace RookieStation
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
Log.WriteLog(ex.Message);
return Result.Cancelled;
}
}
private void RegisterDockPane(UIControlledApplication application)
{
Guid guid = new Guid("{028001AD-0588-4A9C-AA03-D7E472D85050}");
DockablePaneId id = new DockablePaneId(guid);
WpfFamilyDockablePane pane = new WpfFamilyDockablePane();
application.RegisterDockablePane(id, "族库", pane as IDockablePaneProvider);
}
}
}

View File

@@ -6,7 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RookieStation
namespace RookieStation.PackAreaModule
{
public class ShelvesPlacementViewModel
{

View File

@@ -72,7 +72,6 @@ namespace RookieStation.Utils
}
catch (Exception ex)
{
TaskDialog.Show("错误", ex.Message);
Log.WriteLog(ex.Message);
}
finally

View File

@@ -11,7 +11,7 @@ namespace RookieStation
/// <summary>
/// 平面视图命令才可用
/// </summary>
internal class ViewPlanCmdEnabled : IExternalCommandAvailability
internal class EnableCmdInViewPlan : IExternalCommandAvailability
{
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{

View File

@@ -140,8 +140,9 @@ namespace RookieStation.Utils
ExcelWorksheet workSheet = package.Workbook.Worksheets.Add(dt.TableName);
workSheet.Cells["A1"].LoadFromDataTable(dt, true);
}
catch (Exception)
catch (Exception ex)
{
Log.WriteLog(ex.Message);
}
finally
{

View File

@@ -13,7 +13,7 @@ namespace RookieStation.Utils
{
try
{
string logFolder = UserConstant.FamilyLibraryDirectory + "\\Log";
string logFolder = UserConstant.FamilyLibraryDirectory + "Log\\";
string logFile = Path.Combine(logFolder, DateTime.Now.ToString("yyyyMMdd") + ".log");
if (!Directory.Exists(logFolder))
Directory.CreateDirectory(logFolder);

View File

@@ -0,0 +1,210 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace RookieStation.Utils
{
public enum ThumbnailOptions
{
None = 0x00,
BiggerSizeOk = 0x01,
InMemoryOnly = 0x02,
IconOnly = 0x04,
ThumbnailOnly = 0x08,
InCacheOnly = 0x10,
}
public class WindowsThumbnailProvider
{
private const string IShellItem2Guid = "7E9FB0D3-919F-4307-AB2E-9B1860310C93";
[DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int SHCreateItemFromParsingName(
[MarshalAs(UnmanagedType.LPWStr)] string path,
// The following parameter is not used - binding context.
IntPtr pbc,
ref Guid riid,
[MarshalAs(UnmanagedType.Interface)] out IShellItem shellItem);
[DllImport("gdi32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool DeleteObject(IntPtr hObject);
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")]
internal interface IShellItem
{
void BindToHandler(IntPtr pbc,
[MarshalAs(UnmanagedType.LPStruct)] Guid bhid,
[MarshalAs(UnmanagedType.LPStruct)] Guid riid,
out IntPtr ppv);
void GetParent(out IShellItem ppsi);
void GetDisplayName(SIGDN sigdnName, out IntPtr ppszName);
void GetAttributes(uint sfgaoMask, out uint psfgaoAttribs);
void Compare(IShellItem psi, uint hint, out int piOrder);
};
internal enum SIGDN : uint
{
NORMALDISPLAY = 0,
PARENTRELATIVEPARSING = 0x80018001,
PARENTRELATIVEFORADDRESSBAR = 0x8001c001,
DESKTOPABSOLUTEPARSING = 0x80028000,
PARENTRELATIVEEDITING = 0x80031001,
DESKTOPABSOLUTEEDITING = 0x8004c000,
FILESYSPATH = 0x80058000,
URL = 0x80068000
}
internal enum HResult
{
Ok = 0x0000,
False = 0x0001,
InvalidArguments = unchecked((int)0x80070057),
OutOfMemory = unchecked((int)0x8007000E),
NoInterface = unchecked((int)0x80004002),
Fail = unchecked((int)0x80004005),
ElementNotFound = unchecked((int)0x80070490),
TypeElementNotFound = unchecked((int)0x8002802B),
NoObject = unchecked((int)0x800401E5),
Win32ErrorCanceled = 1223,
Canceled = unchecked((int)0x800704C7),
ResourceInUse = unchecked((int)0x800700AA),
AccessDenied = unchecked((int)0x80030005)
}
[ComImportAttribute()]
[GuidAttribute("bcc18b79-ba16-442f-80c4-8a59c30c463b")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IShellItemImageFactory
{
[PreserveSig]
HResult GetImage(
[In, MarshalAs(UnmanagedType.Struct)] NativeSize size,
[In] ThumbnailOptions flags,
[Out] out IntPtr phbm);
}
[StructLayout(LayoutKind.Sequential)]
internal struct NativeSize
{
private int width;
private int height;
public int Width { set { width = value; } }
public int Height { set { height = value; } }
};
[StructLayout(LayoutKind.Sequential)]
public struct RGBQUAD
{
public byte rgbBlue;
public byte rgbGreen;
public byte rgbRed;
public byte rgbReserved;
}
public static Bitmap GetThumbnail(string fileName, int width, int height, ThumbnailOptions options)
{
IntPtr hBitmap = GetHBitmap(Path.GetFullPath(fileName), width, height, options);
try
{
// return a System.Drawing.Bitmap from the hBitmap
return GetBitmapFromHBitmap(hBitmap);
}
finally
{
// delete HBitmap to avoid memory leaks
DeleteObject(hBitmap);
}
}
public static Bitmap GetBitmapFromHBitmap(IntPtr nativeHBitmap)
{
Bitmap bmp = Bitmap.FromHbitmap(nativeHBitmap);
if (Bitmap.GetPixelFormatSize(bmp.PixelFormat) < 32)
return bmp;
return CreateAlphaBitmap(bmp, PixelFormat.Format32bppArgb);
}
public static Bitmap CreateAlphaBitmap(Bitmap srcBitmap, PixelFormat targetPixelFormat)
{
Bitmap result = new Bitmap(srcBitmap.Width, srcBitmap.Height, targetPixelFormat);
Rectangle bmpBounds = new Rectangle(0, 0, srcBitmap.Width, srcBitmap.Height);
BitmapData srcData = srcBitmap.LockBits(bmpBounds, ImageLockMode.ReadOnly, srcBitmap.PixelFormat);
bool isAlplaBitmap = false;
try
{
for (int y = 0; y <= srcData.Height - 1; y++)
{
for (int x = 0; x <= srcData.Width - 1; x++)
{
Color pixelColor = Color.FromArgb(
Marshal.ReadInt32(srcData.Scan0, (srcData.Stride * y) + (4 * x)));
if (pixelColor.A > 0 & pixelColor.A < 255)
{
isAlplaBitmap = true;
}
result.SetPixel(x, y, pixelColor);
}
}
}
finally
{
srcBitmap.UnlockBits(srcData);
}
if (isAlplaBitmap)
{
return result;
}
else
{
return srcBitmap;
}
}
private static IntPtr GetHBitmap(string fileName, int width, int height, ThumbnailOptions options)
{
IShellItem nativeShellItem;
Guid shellItem2Guid = new Guid(IShellItem2Guid);
int retCode = SHCreateItemFromParsingName(fileName, IntPtr.Zero, ref shellItem2Guid, out nativeShellItem);
if (retCode != 0)
throw Marshal.GetExceptionForHR(retCode);
NativeSize nativeSize = new NativeSize();
nativeSize.Width = width;
nativeSize.Height = height;
IntPtr hBitmap;
HResult hr = ((IShellItemImageFactory)nativeShellItem).GetImage(nativeSize, options, out hBitmap);
Marshal.ReleaseComObject(nativeShellItem);
if (hr == HResult.Ok) return hBitmap;
throw Marshal.GetExceptionForHR((int)hr);
}
}
}

View File

@@ -0,0 +1,12 @@
<UserControl x:Class="RookieStation.WpfFamilyDockPane"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:RookieStation"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</UserControl>

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace RookieStation
{
/// <summary>
/// WpfFamilyDockPane.xaml 的交互逻辑
/// </summary>
public partial class WpfFamilyDockPane : UserControl
{
public WpfFamilyDockPane()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,122 @@
<Page
x:Class="RookieStation.CommonTools.WpfFamilyDockablePane"
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="216"
Height="540"
MinWidth="200"
Background="LightGray"
mc:Ignorable="d">
<Page.Resources>
<ResourceDictionary>
<FontFamily x:Key="IconFont">pack://application:,,,/RookieStation;component/Resources/Fonts/#iconfont</FontFamily>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml" />
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Page.Resources>
<Grid Margin="2">
<Grid.RowDefinitions>
<RowDefinition Height="35" />
<RowDefinition Height="35" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="0.5*" />
</Grid.ColumnDefinitions>
<hc:ComboBox
x:Name="cbbLibrary"
HorizontalAlignment="Center"
VerticalAlignment="Center"
hc:InfoElement.Placeholder="请选择库"
DisplayMemberPath="Key"
SelectedValuePath="Value"
SelectionChanged="cbbLibrary_SelectionChanged" />
<Button
x:Name="btnSelectPath"
Grid.Row="0"
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Click="btnSelectPath_Click"
Content="&#xe973;"
FontFamily="{StaticResource IconFont}"
ToolTip="选择族库路径" />
<hc:TextBox
x:Name="tbSearch"
Grid.Row="1"
Grid.Column="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
hc:InfoElement.Placeholder="请输入搜索的族文件名"
FontFamily="{StaticResource IconFont}"
TextChanged="tbSearch_TextChanged" />
<Button
x:Name="btnSearch"
Grid.Row="1"
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Click="btnSearch_Click"
Content="&#xe9b2;"
FontFamily="{StaticResource IconFont}"
IsDefault="True" />
<ListBox x:Name="lbFamilyLib" Grid.Row="2" Grid.ColumnSpan="3" Style="{DynamicResource WrapPanelHorizontalListBox}">
<ListBox.ItemTemplate>
<DataTemplate>
<Border Margin="10" BorderBrush="Black" BorderThickness="2" CornerRadius="5">
<Grid Width="128">
<Grid.RowDefinitions>
<RowDefinition Height="128" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Image
Grid.Row="0"
Width="128"
Height="128"
Source="{Binding ImageData}"
Stretch="Uniform"
ToolTip="{Binding ToolTip}" />
<hc:RunningBlock Grid.Row="1" Runaway="False">
<TextBlock Text="{Binding Title}" TextAlignment="Center" />
</hc:RunningBlock>
<StackPanel Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel.Style>
<Style TargetType="{x:Type StackPanel}">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsMouseOver}" Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
<Button
Width="64"
Margin="2"
Click="BtnLoadFamily_Click"
Content="&#xe7e3;载入"
FontFamily="{StaticResource IconFont}"
ToolTip="载入项目" />
<Button
Width="64"
Margin="2"
Click="BtnOpenFile_Click"
Content="&#xe7e2;定位"
FontFamily="{StaticResource IconFont}"
ToolTip="定位文件" />
</StackPanel>
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Page>

View File

@@ -0,0 +1,171 @@
using Autodesk.Revit.UI;
using RookieStation.Properties;
using RookieStation.Utils;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace RookieStation.CommonTools
{
/// <summary>
/// WpfFamilyDockablePane.xaml 的交互逻辑
/// </summary>
public partial class WpfFamilyDockablePane : Page, IDockablePaneProvider
{
internal LoadFamilyHandler LoadHandler = new LoadFamilyHandler();
public ExternalEvent LoadFamilyExEvent { get; set; }
public string FamilyFolder;
private ObservableCollection<FamilyInfo> FamilyInfos = null;
public WpfFamilyDockablePane()
{
FamilyFolder = Settings.Default.FamilyFolder;
LoadFamilyExEvent = ExternalEvent.Create(LoadHandler);
//if (IsContain)
//{
// FamilyInfos = GetFamilyFiles(FamilyFolder, SearchOption.AllDirectories);
//}
//else
//{
// FamilyInfos = GetFamilyFiles(FamilyFolder, SearchOption.TopDirectoryOnly);
//}
//cbbLibrary.DataContext
InitializeComponent();
btnSelectPath.ToolTip = FamilyFolder;
cbbLibrary.ItemsSource = GetTopDirectoryFolder(FamilyFolder);
}
public void SetupDockablePane(DockablePaneProviderData data)
{
data.FrameworkElement = this as FrameworkElement;
data.InitialState = new DockablePaneState();
data.InitialState.DockPosition = DockPosition.Left;
}
private Dictionary<string, string> GetTopDirectoryFolder(string folder)
{
DirectoryInfo directory = new DirectoryInfo(folder);
var dirs = directory.GetDirectories("*", SearchOption.TopDirectoryOnly);
//ComboBox Key显示Value路径下的文件夹路径
Dictionary<string, string> dictFolderInfo = new Dictionary<string, string>();
for (int i = 0; i < dirs.Count(); i++)
{
dictFolderInfo.Add(dirs[i].Name, dirs[i].FullName);
}
return dictFolderInfo;
}
private ObservableCollection<FamilyInfo> GetFamilyInfos(string folder)
{
var fileinfos = new ObservableCollection<FamilyInfo>();
DirectoryInfo directory = new DirectoryInfo(folder);
var files = directory.GetFiles("*.rfa");
for (int i = 0; i < files.Count(); i++)
{
FamilyInfo fi = new FamilyInfo(files[i].FullName);
fileinfos.Add(fi);
}
return fileinfos;
}
private void cbbLibrary_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var selected = cbbLibrary.SelectedValue;
FamilyInfos = GetFamilyInfos(selected.ToString());
lbFamilyLib.ItemsSource = FamilyInfos;
//lbFamilyLib.DataContext =;
}
private void BtnLoadFamily_Click(object sender, RoutedEventArgs e)
{
try
{
System.Windows.Controls.Button btn = sender as System.Windows.Controls.Button;
LoadHandler.FamilyInfo = btn.DataContext as FamilyInfo;
LoadFamilyExEvent.Raise();
}
catch (Exception ex)
{
Log.WriteLog(ex.Message);
}
}
private void BtnOpenFile_Click(object sender, RoutedEventArgs e)
{
System.Windows.Controls.Button btn = sender as System.Windows.Controls.Button;
FamilyInfo file = btn.DataContext as FamilyInfo;
ExploreFile(file.FullFileName);
}
/// <summary>
/// 定位文件
/// </summary>
/// <param name="filePath"></param>
public static void ExploreFile(string filePath)
{
Process proc = new Process();
proc.StartInfo.FileName = "explorer";
//打开资源管理器
proc.StartInfo.Arguments = @"/select," + filePath;
proc.Start();
}
private void btnSelectPath_Click(object sender, RoutedEventArgs e)
{
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
FamilyFolder = folderBrowserDialog.SelectedPath;
btnSelectPath.ToolTip = FamilyFolder;
cbbLibrary.DataContext = GetTopDirectoryFolder(FamilyFolder);
Settings.Default.FamilyFolder = FamilyFolder;
Settings.Default.Save();
}
}
private void btnSearch_Click(object sender, RoutedEventArgs e)
{
if (tbSearch.Text == "")
{
return;
}
ObservableCollection<FamilyInfo> searchfamily = new ObservableCollection<FamilyInfo>();
foreach (FamilyInfo item in FamilyInfos)
{
if (item.Title.Contains(tbSearch.Text.Trim()))
{
searchfamily.Add(item);
}
}
lbFamilyLib.ItemsSource = searchfamily;
}
private void tbSearch_TextChanged(object sender, TextChangedEventArgs e)
{
if (tbSearch.Text == "")
{
lbFamilyLib.ItemsSource = FamilyInfos;
}
}
}
}

View File

@@ -7,8 +7,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Width="81"
Height="59"
MinWidth="260"
MinHeight="240"
MinWidth="280"
MinHeight="300"
ShowInTaskbar="False"
mc:Ignorable="d">
<Window.Resources>
@@ -23,6 +23,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="0.5*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
@@ -65,10 +66,23 @@
Text="2"
TextAlignment="Center" />
</GroupBox>
<Button
x:Name="btnConfirm"
<GroupBox
Grid.Row="1"
Grid.Column="1"
Margin="2"
Header="厚度mm">
<TextBox
x:Name="tbPavementThickness"
InputMethod.IsInputMethodEnabled="False"
PreviewTextInput="tb_PreviewTextInput"
Text="2"
TextAlignment="Center" />
</GroupBox>
<Button
x:Name="btnConfirm"
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2"
Click="btnConfirm_Click"
Content="铺设" />
</Grid>

View File

@@ -26,6 +26,8 @@ namespace RookieStation
public double PavementGap { get; set; }
public double PavementThickness { get; set; }
public WpfFloorFinishes()
{
@@ -34,15 +36,17 @@ namespace RookieStation
private void btnConfirm_Click(object sender, RoutedEventArgs e)
{
double length, width, gap;
double length, width, gap, thickness;
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)
var d = double.TryParse(tbPavementGap.Text, out thickness);
if (a && b && c && d)
{
PavementLength = length;
PavementWidth = width;
PavementGap = gap;
PavementThickness = thickness;
DialogResult = true;
}
else

View File

@@ -1,21 +1,9 @@
using Autodesk.Revit.UI;
using RookieStation.PackAreaModule;
using RookieStation.Utils;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace RookieStation
{

View File

@@ -35,19 +35,24 @@
x:Name="cbbWallTypes"
Grid.Row="0"
Grid.Column="1"
Width="200"
Width="250"
HorizontalAlignment="Center"
VerticalAlignment="Center"
hc:InfoElement.Title="饰面层类型:"
hc:InfoElement.TitlePlacement="Left"
hc:IsEditable="True"
hc:IsTextSearchEnabled="True"
AutoComplete="True"
DisplayMemberPath="Name"
IsTextSearchCaseSensitive="False"
SelectedIndex="0"
SelectedValuePath="Name" />
SelectedValuePath="Name"
Style="{StaticResource ComboBoxExtend}" />
<hc:TextBox
x:Name="tbWallHeight"
Grid.Row="1"
Grid.Column="1"
Width="200"
Width="250"
HorizontalAlignment="Center"
VerticalAlignment="Center"
hc:InfoElement.Title="饰面层高度:"
@@ -60,7 +65,7 @@
x:Name="tbWallBase"
Grid.Row="2"
Grid.Column="1"
Width="200"
Width="250"
HorizontalAlignment="Center"
VerticalAlignment="Center"
hc:InfoElement.Title="饰面层底部偏移:"
@@ -73,7 +78,7 @@
x:Name="cbbPlaceType"
Grid.Row="3"
Grid.Column="1"
Width="200"
Width="250"
HorizontalAlignment="Center"
VerticalAlignment="Center"
hc:InfoElement.Title="布置方式:"
@@ -81,8 +86,8 @@
PreviewTextInput="tb_PreviewTextInput"
Text="0"
ToolTip="饰面底部离地高度">
<ComboBoxItem Content="房间" IsSelected="True" />
<ComboBoxItem Content="墙面" />
<ComboBoxItem Content="房间" />
<ComboBoxItem Content="墙面" IsSelected="True" />
<ComboBoxItem Content="整墙" />
</hc:ComboBox>
<Button

View File

@@ -18,11 +18,15 @@
</setting>
<setting name="Shelves" serializeAs="Xml">
<value>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<string>单个,1500,400</string>
</ArrayOfString>
</value>
</setting>
<setting name="FamilyFolder" serializeAs="String">
<value>C:\ProgramData\Autodesk\Revit\Addins\2020\RsLibrary\FamilyLibrary</value>
</setting>
</RookieStation.Properties.Settings>
</userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/></startup></configuration>

View File

@@ -26,8 +26,9 @@ namespace RookieStation.Statistics
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Document doc = uidoc.Document;
string fileName = UserConstant.AddinDirectory + "\\RsLibrary\\Document\\样板工程量清单.xlsx";
//调试路径
//string fileName = UserConstant.AddinDirectory + "\\RsLibrary\\Document\\样板工程量清单.xlsx";
string fileName = UserConstant.DocumentDirectory + "样板工程量清单.xlsx";
SaveFileDialog sfd = new SaveFileDialog()
{
Filter = "Excel文件|*.xlsx"
@@ -227,7 +228,14 @@ namespace RookieStation.Statistics
var furnitures = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Furniture).OfClass(typeof(FamilyInstance));
foreach (FamilyInstance furn in furnitures)
{
bool isdetail = furn.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).AsString().Contains("大样");
var param = furn.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS);
string dayang = param.AsValueString();
bool isdetail = false;
if (dayang != null)
{
isdetail = dayang.Contains("大样");
}
if (furn.Symbol.FamilyName.Contains("收检台") && !isdetail)
{
exitGateDeskCount += 1;

File diff suppressed because it is too large Load Diff