添加项目文件。
This commit is contained in:
62
HYJigPro/JigCurves.cs
Normal file
62
HYJigPro/JigCurves.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using Autodesk.Revit.Attributes;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HYJig
|
||||
{
|
||||
[Transaction(TransactionMode.Manual)]
|
||||
[Regeneration(0)]
|
||||
public class JigCurves : IExternalCommand
|
||||
{
|
||||
public Result Execute(ExternalCommandData cmdData, ref string message, ElementSet elements)
|
||||
{
|
||||
UIDocument activeUIDocument = cmdData.Application.ActiveUIDocument;
|
||||
ViewAssist.ViewValidating(activeUIDocument.Document, activeUIDocument.ActiveView);
|
||||
XYZ xyz = null;
|
||||
List<Curve> list = new List<Curve>();
|
||||
try
|
||||
{
|
||||
IList<Reference> list2 = activeUIDocument.Selection.PickObjects(Autodesk.Revit.UI.Selection.ObjectType.Element);
|
||||
foreach (Reference reference in list2)
|
||||
{
|
||||
DetailCurve detailCurve = activeUIDocument.Document.GetElement(reference) as DetailCurve;
|
||||
if (detailCurve != null)
|
||||
{
|
||||
list.Add(detailCurve.GeometryCurve);
|
||||
}
|
||||
}
|
||||
xyz = activeUIDocument.Selection.PickPoint("请选择基点<退出>:");
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
XCurvesJig xcurvesJig = new XCurvesJig(activeUIDocument, false);
|
||||
XYZ xyz2 = xcurvesJig.DragCurves(list, xyz, "请确定插入点:");
|
||||
Result result;
|
||||
if (xyz2 == null)
|
||||
{
|
||||
xcurvesJig.Dispose();
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Transform transform = Transform.CreateTranslation(xyz2 - xyz);
|
||||
Transaction transaction = new Transaction(activeUIDocument.Document);
|
||||
transaction.Start("CreateCurve");
|
||||
foreach (Curve curve in list)
|
||||
{
|
||||
Curve curve2 = curve.CreateTransformed(transform);
|
||||
activeUIDocument.Document.Create.NewDetailCurve(activeUIDocument.ActiveView, curve2);
|
||||
}
|
||||
transaction.Commit();
|
||||
xcurvesJig.Dispose();
|
||||
result = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user