添加项目文件。
This commit is contained in:
106
HYDragCurveJigPro/JigEdgeInfo.cs
Normal file
106
HYDragCurveJigPro/JigEdgeInfo.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using Autodesk.Revit.ApplicationServices;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using System;
|
||||
|
||||
namespace HYDragCurveJig
|
||||
{
|
||||
public class JigEdgeInfo
|
||||
{
|
||||
public XYZ StartPoint { get; set; }
|
||||
|
||||
public XYZ EndPoint { get; set; }
|
||||
|
||||
public double Bulge { get; set; }
|
||||
|
||||
public bool IsArc => !JigGeometry.IsEqual(this.Bulge, 0.0);
|
||||
|
||||
public bool IsNull()
|
||||
{
|
||||
return this.StartPoint == null || this.EndPoint == null;
|
||||
}
|
||||
|
||||
public JigEdgeInfo(JigEdgeInfo rhs)
|
||||
{
|
||||
this.StartPoint = rhs.StartPoint;
|
||||
this.EndPoint = rhs.EndPoint;
|
||||
this.Bulge = rhs.Bulge;
|
||||
}
|
||||
|
||||
public JigEdgeInfo(XYZ startPoint, XYZ endPoint, double bulge)
|
||||
{
|
||||
this.StartPoint = startPoint;
|
||||
this.EndPoint = endPoint;
|
||||
this.Bulge = bulge;
|
||||
}
|
||||
|
||||
public JigEdgeInfo(Curve curve)
|
||||
{
|
||||
if (curve.GetType() == typeof(Line))
|
||||
{
|
||||
this.StartPoint = curve.GetEndPoint(0);
|
||||
this.EndPoint = curve.GetEndPoint(1);
|
||||
this.Bulge = 0.0;
|
||||
return;
|
||||
}
|
||||
if (curve.GetType() == typeof(Arc))
|
||||
{
|
||||
Arc arc = curve as Arc;
|
||||
this.StartPoint = curve.GetEndPoint(0);
|
||||
this.EndPoint = curve.GetEndPoint(1);
|
||||
if (!arc.Normal.IsAlmostEqualTo(XYZ.BasisZ))
|
||||
{
|
||||
this.StartPoint = curve.GetEndPoint(1);
|
||||
this.EndPoint = curve.GetEndPoint(0);
|
||||
}
|
||||
this.Bulge = JigGeometry.GetBulge(this.StartPoint, this.EndPoint, arc.Center, true);
|
||||
}
|
||||
}
|
||||
|
||||
public JigEdgeInfo TransformTo(Transform matrix)
|
||||
{
|
||||
XYZ xyz = JigGeometry.TransformPoint(this.StartPoint, matrix);
|
||||
XYZ xyz2 = JigGeometry.TransformPoint(this.EndPoint, matrix);
|
||||
return new JigEdgeInfo(xyz, xyz2, this.Bulge);
|
||||
}
|
||||
|
||||
public void TransformSelf(Transform matrix)
|
||||
{
|
||||
this.StartPoint = JigGeometry.TransformPoint(this.StartPoint, matrix);
|
||||
this.EndPoint = JigGeometry.TransformPoint(this.EndPoint, matrix);
|
||||
}
|
||||
|
||||
public Curve ConvertTo(Application app)
|
||||
{
|
||||
Curve curve = null;
|
||||
if (this.IsNull())
|
||||
{
|
||||
return curve;
|
||||
}
|
||||
XYZ xyz = this.ProjectX0Y(this.StartPoint);
|
||||
XYZ xyz2 = this.ProjectX0Y(this.EndPoint);
|
||||
if (xyz.IsAlmostEqualTo(xyz2))
|
||||
{
|
||||
return curve;
|
||||
}
|
||||
if (this.IsArc)
|
||||
{
|
||||
XYZ xyz3 = null;
|
||||
double num = 0.0;
|
||||
double num2 = 0.0;
|
||||
double num3 = 0.0;
|
||||
JigGeometry.GetArcInfoWithBulge(xyz, xyz2, this.Bulge, ref xyz3, ref num, ref num2, ref num3);
|
||||
double num4 = JigGeometry.BetweenTheAngles(num2, num3, true) / 2.0;
|
||||
XYZ xyz4 = xyz - xyz3;
|
||||
XYZ xyz5 = xyz3 + JigGeometry.RotateTo(xyz4, num4, XYZ.BasisZ);
|
||||
return Arc.Create(xyz, xyz2, xyz5);
|
||||
}
|
||||
return Line.CreateBound(xyz, xyz2);
|
||||
}
|
||||
|
||||
private XYZ ProjectX0Y(XYZ xyz_2)
|
||||
{
|
||||
return new XYZ(xyz_2.X, xyz_2.Y, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user