增加保温层和整理管线的功能,修复自动保存功能等修复多个bug
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Security.Cryptography;
|
||||
using System.Windows;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
@@ -55,13 +56,35 @@ namespace Sai.RvKits.RvView
|
||||
{
|
||||
var uidoc = uiapp.ActiveUIDocument;
|
||||
var element = uidoc.SelectObject(new FuncFilter(elem => elem.GetLocCurve() is Line));
|
||||
#region 选择方向
|
||||
//var firstTip = "请选择第一个点以确定正交剖面的定位点";
|
||||
//var lastTip = "请选择第二个点以确定拉抻的深度";
|
||||
//if (IsParallel)
|
||||
//{
|
||||
// firstTip = "请选择第一个剖面范围水平的边界点";
|
||||
// lastTip = "请选择第二个剖面范围水平的边界点";
|
||||
//}
|
||||
//var firstrefer = uidoc.Selection
|
||||
// .PickObject(Autodesk.Revit.UI.Selection.ObjectType.PointOnElement, firstTip);
|
||||
//var lastrefer = uidoc.Selection
|
||||
// .PickObject(Autodesk.Revit.UI.Selection.ObjectType.PointOnElement, lastTip);
|
||||
//var first = firstrefer.GlobalPoint;
|
||||
//var last = firstrefer.GlobalPoint;
|
||||
//var elementByCurve = uidoc.Document.GetElement(firstrefer);
|
||||
|
||||
//var firstPoint = elementByCurve.GetLocCurve().Project(first).XYZPoint;
|
||||
//var lastPoint = elementByCurve.GetLocCurve().Project(last).XYZPoint;
|
||||
#endregion
|
||||
|
||||
var lc = element.Location as LocationCurve;
|
||||
var line = lc.Curve as Line;
|
||||
var doc = uidoc.Document;
|
||||
//获取剖面图类型
|
||||
var viewfamilyType = doc.OfClass<ViewFamilyType>()
|
||||
.Cast<ViewFamilyType>()
|
||||
.Where(t => t.ViewFamily == ViewFamily.Section)
|
||||
.FirstOrDefault();
|
||||
|
||||
var bb = element.get_BoundingBox(null);
|
||||
var minZ = bb.Min.Z;
|
||||
var maxZ = bb.Max.Z;
|
||||
@@ -70,30 +93,33 @@ namespace Sai.RvKits.RvView
|
||||
|
||||
ViewSection viewSection = null;
|
||||
BoundingBoxXYZ sectionBox;
|
||||
var offset = 0.2 * baseLength;
|
||||
//transform.x:RightDirection,transform.y:UpDirection=Z轴,transform.z:ViewDirection (r x u=v)
|
||||
var t = Transform.Identity;
|
||||
Debug.WriteLine($"Length:{baseLength}");
|
||||
Debug.WriteLine($"Offset:{offset}");
|
||||
Debug.WriteLine("拾取对象:");
|
||||
|
||||
Debug.WriteLine($"Min:{bb.Min}");
|
||||
Debug.WriteLine($"Max:{bb.Max}");
|
||||
|
||||
//获得定位点
|
||||
t.Origin = line.Evaluate(0.5, true).Flatten();
|
||||
//t.Origin = line.GetEndPoint(0).Flatten();
|
||||
Debug.WriteLine("定义剖面:");
|
||||
Debug.WriteLine($"Transform.Origin:{t.Origin}");
|
||||
t.BasisY = XYZ.BasisZ;//UpDirection
|
||||
t.BasisY = XYZ.BasisZ;//固定朝上UpDirection
|
||||
var viewName = $"{element.Category.Name}({element.Id})";
|
||||
if (IsParallel)
|
||||
{
|
||||
var min = new XYZ(-baseLength / 2, minZ - offset, -offset);
|
||||
var max = new XYZ(baseLength / 2, maxZ + offset, offset);
|
||||
//剖面视图中,裁剪框左下角的点
|
||||
var min = new XYZ(-(baseLength + 1) / 2, minZ - 10, -2);
|
||||
//剖面视图中,裁剪框右上角的点
|
||||
var max = new XYZ((baseLength + 1) / 2, maxZ + 10, 2);
|
||||
Debug.WriteLine($"Min:{min}");
|
||||
Debug.WriteLine($"Max:{max}");
|
||||
|
||||
viewName = $"平行剖面-{viewName}";
|
||||
t.BasisX = line.Direction;//与生成的最终剖面视图的RightDirection反向(定义Transform)
|
||||
t.BasisZ = line.Direction.CrossProduct(XYZ.BasisZ);//与生成的最终剖面视图的ViewDirection反向(定义Transform)
|
||||
|
||||
Debug.WriteLine($"Transform.BasisX:{t.BasisX}");
|
||||
Debug.WriteLine($"Transform.BasisZ:{t.BasisZ}");
|
||||
|
||||
@@ -110,22 +136,33 @@ namespace Sai.RvKits.RvView
|
||||
viewName = $"正交剖面-{viewName}";
|
||||
t.BasisX = XYZ.BasisZ.CrossProduct(line.Direction);
|
||||
t.BasisZ = line.Direction;
|
||||
var min = new XYZ(-3000 / 304.8 / 2, minZ - offset, -offset);
|
||||
var max = new XYZ(3000 / 304.8 / 2, maxZ + offset, offset);
|
||||
var min = new XYZ(-5, minZ - 5, -2);
|
||||
var max = new XYZ(5, maxZ + 5, 2);
|
||||
|
||||
Debug.WriteLine($"Transform.BasisX:{t.BasisX}");
|
||||
Debug.WriteLine($"Transform.BasisZ:{t.BasisZ}");
|
||||
|
||||
sectionBox = new BoundingBoxXYZ
|
||||
try
|
||||
{
|
||||
Transform = t,
|
||||
Min = min,
|
||||
Max = max
|
||||
};
|
||||
sectionBox = new BoundingBoxXYZ
|
||||
{
|
||||
Transform = t,
|
||||
Min = min,
|
||||
Max = max
|
||||
};
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
doc.Invoke(
|
||||
ts =>
|
||||
{
|
||||
if (sectionBox == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
viewSection = ViewSection.CreateSection(uidoc.Document, viewfamilyType.Id, sectionBox);
|
||||
viewSection.DisplayStyle = DisplayStyle.ShadingWithEdges;
|
||||
viewSection.DetailLevel = ViewDetailLevel.Fine;
|
||||
|
||||
Reference in New Issue
Block a user