71 lines
2.7 KiB
C#
71 lines
2.7 KiB
C#
|
|
using Autodesk.Revit.DB;
|
|
using Autodesk.Revit.UI;
|
|
using Autodesk.Revit.UI.Events;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace HYDragCurveJig
|
|
{
|
|
public class DragCurveJigInterface
|
|
{
|
|
public static bool GetInsertPosition(ExternalCommandData commandData, List<JigEdgeInfo> curveInfos, bool moveCurveInfos, XYZ ptBase, ref XYZ ptPosition)
|
|
{
|
|
List<JigTextInfo> list = new List<JigTextInfo>();
|
|
return DragCurveJigInterface.GetInsertPosition(commandData, curveInfos, moveCurveInfos, list, moveCurveInfos, ptBase, ref ptPosition);
|
|
}
|
|
|
|
public static bool GetInsertPosition(ExternalCommandData commandData, List<JigTextInfo> textInfos, bool moveTextInfos, XYZ ptBase, ref XYZ ptPosition)
|
|
{
|
|
List<JigEdgeInfo> list = new List<JigEdgeInfo>();
|
|
return DragCurveJigInterface.GetInsertPosition(commandData, list, moveTextInfos, textInfos, moveTextInfos, ptBase, ref ptPosition);
|
|
}
|
|
|
|
public static bool GetInsertPosition(ExternalCommandData commandData, List<JigEdgeInfo> curveInfos, bool moveCurveInfos, List<JigTextInfo> textInfos, bool moveTextInfos, XYZ ptBase, ref XYZ ptPosition)
|
|
{
|
|
commandData.Application.ApplicationClosing += DragCurveJigInterface.smethod_0;
|
|
JigCreator jigCreator = new JigCreator(commandData);
|
|
string text = string.Empty;
|
|
jigCreator.Initialize(curveInfos, textInfos, ptBase, ref text);
|
|
if (!jigCreator.Do(ref ptPosition))
|
|
{
|
|
commandData.Application.ApplicationClosing -= DragCurveJigInterface.smethod_0;
|
|
return false;
|
|
}
|
|
Transform transform = Transform.CreateTranslation(ptPosition - ptBase);
|
|
if (moveCurveInfos)
|
|
{
|
|
for (int i = 0; i < curveInfos.Count; i++)
|
|
{
|
|
curveInfos[i].TransformSelf(transform);
|
|
}
|
|
}
|
|
if (moveTextInfos)
|
|
{
|
|
for (int j = 0; j < textInfos.Count; j++)
|
|
{
|
|
textInfos[j].TransformSelf(transform, false);
|
|
}
|
|
}
|
|
commandData.Application.ApplicationClosing -= DragCurveJigInterface.smethod_0;
|
|
return true;
|
|
}
|
|
|
|
private static void smethod_0(object sender, ApplicationClosingEventArgs e)
|
|
{
|
|
}
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
|
|
|
|
private static void smethod_1()
|
|
{
|
|
byte b = 27;
|
|
DragCurveJigInterface.keybd_event(27, 0, 0, 0);
|
|
DragCurveJigInterface.keybd_event(b, 0, 2, 0);
|
|
}
|
|
}
|
|
}
|