162 lines
4.6 KiB
C#
162 lines
4.6 KiB
C#
|
|
using Autodesk.Revit.DB;
|
|||
|
|
using Autodesk.Revit.UI;
|
|||
|
|
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Runtime.CompilerServices;
|
|||
|
|
using System.Threading;
|
|||
|
|
|
|||
|
|
using Color = System.Drawing.Color;
|
|||
|
|
|
|||
|
|
namespace HYJig
|
|||
|
|
{
|
|||
|
|
public class XCurvesFlicker : XUiJigBase
|
|||
|
|
{
|
|||
|
|
public XCurvesFlicker(UIDocument uiDoc)
|
|||
|
|
: base(uiDoc)
|
|||
|
|
{
|
|||
|
|
this.list_0 = new List<Curve>();
|
|||
|
|
this.thread_0 = new Thread(new ParameterizedThreadStart(XCurvesFlicker.smethod_0));
|
|||
|
|
this.IsThreadComplete = false;
|
|||
|
|
this.FlickerTime = 500;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void method_13()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
this.thread_0.Start(this);
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void method_14()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
this.thread_0.Join(1000);
|
|||
|
|
this.thread_0.Abort();
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private static void smethod_0(object object_0)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
XCurvesFlicker xcurvesFlicker = object_0 as XCurvesFlicker;
|
|||
|
|
while (!xcurvesFlicker.IsThreadComplete)
|
|||
|
|
{
|
|||
|
|
xcurvesFlicker.method_15();
|
|||
|
|
Thread.Sleep(xcurvesFlicker.FlickerTime);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void method_15()
|
|||
|
|
{
|
|||
|
|
if (this.thread_0.IsAlive)
|
|||
|
|
{
|
|||
|
|
List<XDrawable2D> list = new List<XDrawable2D>();
|
|||
|
|
foreach (Curve curve in this.Curves)
|
|||
|
|
{
|
|||
|
|
Line line = curve as Line;
|
|||
|
|
if (line != null)
|
|||
|
|
{
|
|||
|
|
XYZ endPoint = line.GetEndPoint(0);
|
|||
|
|
XYZ endPoint2 = line.GetEndPoint(1);
|
|||
|
|
Point point = base.Revit2Client(endPoint);
|
|||
|
|
Point point2 = base.Revit2Client(endPoint2);
|
|||
|
|
XLine2D xline2D = new XLine2D(point, point2);
|
|||
|
|
list.Add(xline2D);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Arc arc = curve as Arc;
|
|||
|
|
if (arc != null && arc.IsBound)
|
|||
|
|
{
|
|||
|
|
XYZ endPoint3 = arc.GetEndPoint(0);
|
|||
|
|
XYZ endPoint4 = arc.GetEndPoint(1);
|
|||
|
|
XYZ xyz = arc.Evaluate(0.5, true);
|
|||
|
|
Point point3 = base.Revit2Client(endPoint3);
|
|||
|
|
Point point4 = base.Revit2Client(endPoint4);
|
|||
|
|
Point point5 = base.Revit2Client(xyz);
|
|||
|
|
XArc2D xarc2D = new XArc2D(point3, point4, point5);
|
|||
|
|
list.Add(xarc2D);
|
|||
|
|
}
|
|||
|
|
else if (arc != null && !arc.IsBound)
|
|||
|
|
{
|
|||
|
|
XYZ center = arc.Center;
|
|||
|
|
XYZ xyz2 = center + base.UiDoc.ActiveView.RightDirection * arc.Radius;
|
|||
|
|
Point point6 = base.Revit2Client(center);
|
|||
|
|
Point point7 = base.Revit2Client(xyz2);
|
|||
|
|
int distance = XDrawable2D.GetDistance(point7, point6);
|
|||
|
|
XCircle2D xcircle2D = new XCircle2D(point6, distance);
|
|||
|
|
list.Add(xcircle2D);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public XUiJigBase.EJigResult DoJig()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
this.method_13();
|
|||
|
|
base.UiDoc.Selection.PickPoint("按任意键退出:");
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
return XUiJigBase.EJigResult.eRtCancel;
|
|||
|
|
}
|
|||
|
|
finally
|
|||
|
|
{
|
|||
|
|
this.IsThreadComplete = true;
|
|||
|
|
}
|
|||
|
|
return XUiJigBase.EJigResult.eRtOk;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public Color PenColor
|
|||
|
|
{
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
this.color_0 = value;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public int PenWidth
|
|||
|
|
{
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
this.PenWidth = value;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public int FlickerTime { get; set; }
|
|||
|
|
|
|||
|
|
public List<Curve> Curves
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
return this.list_0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool IsThreadComplete { get; set; }
|
|||
|
|
|
|||
|
|
private List<Curve> list_0 = null;
|
|||
|
|
|
|||
|
|
private Thread thread_0 = null;
|
|||
|
|
|
|||
|
|
private Color color_0 = Color.Red;
|
|||
|
|
}
|
|||
|
|
}
|