优化更新
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using Autodesk.Revit.Attributes;
|
||||
using Autodesk.Revit.Attributes;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Electrical;
|
||||
using Autodesk.Revit.DB.Mechanical;
|
||||
using Autodesk.Revit.DB.Plumbing;
|
||||
|
||||
using Nice3point.Revit.Toolkit.External;
|
||||
using Nice3point.Revit.Toolkit.Utils;
|
||||
|
||||
|
||||
namespace Sai.RvKits.RvMEP;
|
||||
@@ -77,6 +76,42 @@ public class CorrectMEPCurveSlopeCmd : ExternalCommand
|
||||
}
|
||||
}, "修正坡度");
|
||||
}
|
||||
private void CorrectSlope()
|
||||
{
|
||||
var ids = UiDocument.Selection.GetElementIds();
|
||||
Document.Modify(
|
||||
set => set.Transaction).Commit((doc, t) =>
|
||||
{
|
||||
foreach (var id in ids)
|
||||
{
|
||||
var elem = Document.GetElement(id);
|
||||
if (elem is MEPCurve mep)
|
||||
{
|
||||
var loc = mep.GetCurve() as Line;
|
||||
var x = Math.Round(loc.Direction.X);
|
||||
var y = Math.Round(loc.Direction.Y);
|
||||
var z = Math.Round(loc.Direction.Z);
|
||||
//if (Math.Abs(x) < 10E-5)
|
||||
//{
|
||||
// x = 0;
|
||||
//}
|
||||
//if (Math.Abs(y) < 10E-5)
|
||||
//{
|
||||
// y = 0;
|
||||
//}
|
||||
//if (Math.Abs(z) < 10E-5)
|
||||
//{
|
||||
// z = 0;
|
||||
//}
|
||||
var dir = new XYZ(x, y, z);
|
||||
var endPoint = loc.Origin + dir * loc.Length;
|
||||
var li = Line.CreateBound(loc.Origin, endPoint);
|
||||
var locx = mep.GetLocationCurve();
|
||||
locx.Curve = li;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
private void ModifyMEPCurve(MEPCurve mepCurve)
|
||||
{
|
||||
var loc = mepCurve.Location as LocationCurve;
|
||||
|
||||
Reference in New Issue
Block a user