Files
RevitArchive/HYJigPro/DrawJigCurve.cs

280 lines
8.9 KiB
C#
Raw Permalink Normal View History

2026-02-23 14:58:05 +08:00
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System;
using System.Collections.Generic;
namespace HYJig
{
public class DrawJigCurve
{
public DrawJigCurve(ExternalCommandData cmdData)
{
this.uidocument_0 = cmdData.Application.ActiveUIDocument;
}
public DrawJigCurve(UIDocument uiDoc)
{
this.uidocument_0 = uiDoc;
}
public Result DrawJigCurveLine(ref List<Curve> lstCurves, ref XYZ ptLast, string strPromptStart, string strPromptEnd)
{
XLineJig xlineJig = new XLineJig(this.uidocument_0);
XYZ xyz;
if (ptLast != null)
{
xyz = ptLast;
xlineJig.StartPoint = xyz;
}
else
{
xyz = xlineJig.PickStartPoint(strPromptStart);
if (xyz == null)
{
xlineJig.Dispose();
return Result.Cancelled;
}
}
XYZ xyz2 = xlineJig.PickEndPoint(xyz, strPromptEnd);
Result result;
if (xyz2 == null)
{
xlineJig.Dispose();
result = Result.Cancelled;
}
else
{
lstCurves = xlineJig.CreateCurves();
ptLast = xyz2;
xlineJig.Dispose();
result = 0;
}
return result;
}
public Result DrawJigCurveLine(ref Line line, ref XYZ ptLast, string strPromptStart, string strPromptEnd)
{
List<Curve> list = new List<Curve>();
Result result = this.DrawJigCurveLine(ref list, ref ptLast, strPromptStart, strPromptEnd);
if (list.Count > 0)
{
line = list[0] as Line;
}
return result;
}
public Result DrawJigCurveLineXDirection(ref Line line, ref XYZ ptLast, string strPromptStart, string strPromptEnd)
{
XLineJig xlineJig = new XLineJig(this.uidocument_0);
XYZ xyz;
if (ptLast != null)
{
xyz = ptLast;
xlineJig.StartPoint = xyz;
}
else
{
xyz = xlineJig.PickStartPoint(strPromptStart);
if (xyz == null)
{
xlineJig.Dispose();
return Result.Cancelled;
}
}
xlineJig.ResetPoint = XUiJigBase.EResetPoint.eByAngle;
xlineJig.LineAngle = 0.0;
XYZ xyz2 = xlineJig.PickEndPoint(xyz, strPromptEnd);
Result result;
if (xyz2 == null)
{
xlineJig.Dispose();
result = Result.Cancelled;
}
else
{
List<Curve> list = new List<Curve>();
list = xlineJig.CreateCurves();
ptLast = xyz2;
if (list.Count > 0)
{
line = list[0] as Line;
}
xlineJig.Dispose();
result = 0;
}
return result;
}
public Result DrawJigCurveLineYDirection(ref Line line, ref XYZ ptLast, string strPromptStart, string strPromptEnd)
{
XLineJig xlineJig = new XLineJig(this.uidocument_0);
XYZ xyz;
if (ptLast != null)
{
xyz = ptLast;
xlineJig.StartPoint = xyz;
}
else
{
xyz = xlineJig.PickStartPoint(strPromptStart);
if (xyz == null)
{
xlineJig.Dispose();
return Result.Cancelled;
}
}
xlineJig.ResetPoint = XUiJigBase.EResetPoint.eByAngle;
xlineJig.LineAngle = 1.5707963267948966;
XYZ xyz2 = xlineJig.PickEndPoint(xyz, strPromptEnd);
Result result;
if (xyz2 == null)
{
xlineJig.Dispose();
result = Result.Cancelled;
}
else
{
List<Curve> list = new List<Curve>();
list = xlineJig.CreateCurves();
ptLast = xyz2;
if (list.Count > 0)
{
line = list[0] as Line;
}
xlineJig.Dispose();
result = 0;
}
return result;
}
public Result DrawJigCurveRect(ref List<Curve> lstCurves, string strPromptStart, string strPromptEnd)
{
XRectJig xrectJig = new XRectJig(this.uidocument_0);
try
{
XYZ xyz = xrectJig.PickStartPoint(strPromptStart);
if (xyz == null)
{
xrectJig.Dispose();
return Result.Cancelled;
}
XYZ xyz2 = xrectJig.PickEndPoint(xyz, this.uidocument_0.ActiveView.RightDirection, strPromptEnd);
if (xyz2 == null)
{
xrectJig.Dispose();
return Result.Cancelled;
}
lstCurves = xrectJig.CreateCurves();
xrectJig.Dispose();
}
catch (Exception)
{
xrectJig.Dispose();
return Result.Failed;
}
return 0;
}
public Result method_0(ref List<Curve> lstCurves, ref XYZ ptLast, string strPromptStart, string strPromptEnd, string strPromptMid)
{
XArc3PtJig xarc3PtJig = new XArc3PtJig(this.uidocument_0);
try
{
XYZ xyz;
if (ptLast != null)
{
xyz = ptLast;
xarc3PtJig.StartPoint = xyz;
}
else
{
xyz = xarc3PtJig.PickStartPoint(strPromptStart);
if (xyz == null)
{
xarc3PtJig.Dispose();
return Result.Cancelled;
}
}
XYZ xyz2 = xarc3PtJig.PickEndPoint(xyz, strPromptEnd);
if (xyz2 == null)
{
xarc3PtJig.Dispose();
return Result.Cancelled;
}
XYZ xyz3 = xarc3PtJig.PickOnCurvePoint(xyz, xyz2, strPromptMid);
if (xyz3 == null)
{
xarc3PtJig.Dispose();
return Result.Cancelled;
}
lstCurves = xarc3PtJig.CreateCurves();
ptLast = xyz2;
xarc3PtJig.Dispose();
}
catch (Exception)
{
xarc3PtJig.Dispose();
}
return 0;
}
public Result method_1(ref Arc arc, ref XYZ ptLast, string strPromptStart, string strPromptEnd, string strPromptMid)
{
List<Curve> list = new List<Curve>();
Result result = this.method_0(ref list, ref ptLast, strPromptStart, strPromptEnd, strPromptMid);
if (list.Count > 0)
{
arc = list[0] as Arc;
}
return result;
}
public Result DrawJigCurveArcCenter2Pt(ref List<Curve> lstCurves, string strPromptCenter, string strPromptStart, string strPromptEnd)
{
XArcJig xarcJig = new XArcJig(this.uidocument_0);
try
{
XYZ xyz = xarcJig.PickCenterPoint(strPromptCenter);
if (xyz == null)
{
xarcJig.Dispose();
return Result.Cancelled;
}
XYZ xyz2 = xarcJig.PickStartPoint(xyz, strPromptStart);
if (xyz2 == null)
{
xarcJig.Dispose();
return Result.Cancelled;
}
XYZ xyz3 = xarcJig.PickEndPoint(xyz, xyz2, strPromptEnd);
if (xyz3 == null)
{
xarcJig.Dispose();
return Result.Cancelled;
}
lstCurves = xarcJig.CreateCurves();
xarcJig.Dispose();
}
catch (Exception)
{
xarcJig.Dispose();
}
return 0;
}
public Result DrawJigCurveArcCenter2Pt(ref Arc arc, string strPromptCenter, string strPromptStart, string strPromptEnd)
{
List<Curve> list = new List<Curve>();
Result result = this.DrawJigCurveArcCenter2Pt(ref list, strPromptCenter, strPromptStart, strPromptEnd);
if (list.Count > 0)
{
arc = list[0] as Arc;
}
return result;
}
private UIDocument uidocument_0;
}
}