using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Selection; using System; using System.Collections.Generic; using System.Linq; namespace HYDragCurveJig { public class TestJigControler { public TestJigControler(ExternalCommandData commandData) { this.externalCommandData_0 = commandData; this.options_0 = this.externalCommandData_0.Application.Application.Create.NewGeometryOptions(); this.options_0.View = this.externalCommandData_0.Application.ActiveUIDocument.Document.ActiveView; } public bool Test(ref string message) { List list = new List(); if (!this.method_0(ref list)) { return false; } XYZ xyz = null; if (!this.method_5(ref xyz)) { return false; } XYZ xyz2 = null; List list2 = new List(); if (!DragCurveJigInterface.GetInsertPosition(this.externalCommandData_0, list, false, list2, false, xyz, ref xyz2)) { return false; } this.method_6(xyz2); return true; } private bool method_0(ref List list_0) { Document document = this.externalCommandData_0.Application.ActiveUIDocument.Document; IList list = null; Selection selection = this.externalCommandData_0.Application.ActiveUIDocument.Selection; bool flag; try { list = selection.PickObjects(ObjectType.Element, "select elements"); goto IL_0045; } catch (Exception) { flag = false; } return flag; IL_0045: foreach (Reference reference in list) { Element element = document.GetElement(reference); if (element.GetType() == typeof(FamilyInstance)) { this.method_1(element as FamilyInstance, ref list_0); } else { this.method_2(element, ref list_0); } } return true; } private void method_1(FamilyInstance familyInstance_0, ref List list_0) { GeometryElement geometryElement = familyInstance_0.GetOriginalGeometry(this.options_0); geometryElement = geometryElement.GetTransformed(familyInstance_0.GetTransform()); if (null == geometryElement) { return; } IEnumerator enumerator = geometryElement.GetEnumerator(); List geometryObjectArray = geometryElement.OfType().ToList(); while (enumerator.MoveNext()) { GeometryObject geometryObject = enumerator.Current; geometryObjectArray.Add(geometryObject); } new List(); foreach (GeometryObject geometryObject2 in geometryObjectArray) { this.method_3(geometryObject2, ref list_0); } } private void method_2(Element element_0, ref List list_0) { GeometryElement geometryElement = element_0.get_Geometry(this.options_0); if (null == geometryElement) { return; } IEnumerator enumerator = geometryElement.GetEnumerator(); List geometryObjectArray = geometryElement.OfType().ToList(); while (enumerator.MoveNext()) { GeometryObject geometryObject = enumerator.Current; geometryObjectArray.Add(geometryObject); } new List(); foreach (GeometryObject geometryObject2 in geometryObjectArray) { this.method_3(geometryObject2, ref list_0); } } private void method_3(GeometryObject geometryObject_0, ref List list_0) { if (geometryObject_0.GetType() == typeof(Solid)) { var enumerator = (geometryObject_0 as Solid).Edges.GetEnumerator(); { while (enumerator.MoveNext()) { object obj = enumerator.Current; JigEdgeInfo jigEdgeInfo = new JigEdgeInfo(((Edge)obj).AsCurve()); if (!jigEdgeInfo.IsNull()) { list_0.Add(jigEdgeInfo); } } return; } } if (geometryObject_0.GetType() == typeof(Arc)) { JigEdgeInfo jigEdgeInfo2 = new JigEdgeInfo(geometryObject_0 as Arc); if (jigEdgeInfo2.IsNull()) { return; } list_0.Add(jigEdgeInfo2); return; } else if (geometryObject_0.GetType() == typeof(Line)) { JigEdgeInfo jigEdgeInfo3 = new JigEdgeInfo(geometryObject_0 as Line); if (jigEdgeInfo3.IsNull()) { return; } list_0.Add(jigEdgeInfo3); } } private bool method_4(ref List list_0) { Document document = this.externalCommandData_0.Application.ActiveUIDocument.Document; IList list = null; Selection selection = this.externalCommandData_0.Application.ActiveUIDocument.Selection; bool flag; try { list = selection.PickObjects(ObjectType.Element, new CurveFilter(), "select curves"); goto IL_004A; } catch (Exception) { flag = false; } return flag; IL_004A: foreach (Reference reference in list) { Element element = document.GetElement(reference); if (element.GetType() == typeof(ModelLine)) { JigEdgeInfo jigEdgeInfo = new JigEdgeInfo((element as ModelLine).GeometryCurve as Line); list_0.Add(jigEdgeInfo); } else if (element.GetType() == typeof(ModelArc)) { JigEdgeInfo jigEdgeInfo2 = new JigEdgeInfo((element as ModelArc).GeometryCurve as Arc); list_0.Add(jigEdgeInfo2); } else if (element.GetType() == typeof(DetailLine)) { JigEdgeInfo jigEdgeInfo3 = new JigEdgeInfo((element as DetailLine).GeometryCurve as Line); list_0.Add(jigEdgeInfo3); } else if (element.GetType() == typeof(DetailArc)) { JigEdgeInfo jigEdgeInfo4 = new JigEdgeInfo((element as DetailArc).GeometryCurve as Arc); list_0.Add(jigEdgeInfo4); } } return true; } private bool method_5(ref XYZ xyz_0) { XYZ xyz = null; bool flag; try { xyz = this.externalCommandData_0.Application.ActiveUIDocument.Selection.PickPoint("please pick point on column"); goto IL_002C; } catch (Exception) { flag = false; } return flag; IL_002C: xyz_0 = new XYZ(xyz.X, xyz.Y, 0.0); return true; } private void method_6(XYZ xyz_0) { Document document = this.externalCommandData_0.Application.ActiveUIDocument.Document; Transaction transaction = new Transaction(document); transaction.Start("create mark"); CurveArray curveArray = new CurveArray(); double num = 3.0; XYZ xyz = new XYZ(xyz_0.X - num, xyz_0.Y + num, 0.0); XYZ xyz2 = new XYZ(xyz_0.X + num, xyz_0.Y - num, 0.0); Line line = Line.CreateBound(xyz, xyz2); curveArray.Append(line); XYZ xyz3 = new XYZ(xyz_0.X - num, xyz_0.Y - num, 0.0); xyz2 = new XYZ(xyz_0.X + num, xyz_0.Y + num, 0.0); Line line2 = Line.CreateBound(xyz3, xyz2); curveArray.Append(line2); XYZ xyz4 = new XYZ(0.0, 0.0, 0.0); Plane plane = Plane.CreateByNormalAndOrigin(new XYZ(0.0, 0.0, 1.0), xyz4); SketchPlane sketchPlane = SketchPlane.Create(document, plane); document.Create.NewModelCurveArray(curveArray, sketchPlane); transaction.Commit(); } private ExternalCommandData externalCommandData_0; private Options options_0; } }