public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elems) { Result result; using (var transaction = new Transaction(cmdData.Application.ActiveUIDocument.Document, this.GetType().Name)) { transaction.Start(); // necessary to snoop Document.PlanTopologies try { Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application; Snoop.CollectorExts.CollectorExt.m_activeDoc = cmdData.Application.ActiveUIDocument.Document; // TBD: see note in CollectorExt.cs Snoop.Forms.Objects form = new Snoop.Forms.Objects(cmdData.Application.Application); form.ShowDialog(); ActiveDoc.UIApp = cmdData.Application; result = Result.Succeeded; } catch (System.Exception e) { msg = e.Message; result = Result.Failed; } transaction.RollBack(); } return(result); }
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elems) { Result result; try { Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application; // TBD: see note in CollectorExt.cs Snoop.CollectorExts.CollectorExt.m_activeDoc = cmdData.Application.ActiveUIDocument.Document; // iterate over the collection and put them in an ArrayList so we can pass on // to our Form Autodesk.Revit.DB.Document doc = cmdData.Application.ActiveUIDocument.Document; if (doc.ActiveView == null) { TaskDialog.Show("RevitLookup", "The document must have an active view!"); return(Result.Cancelled); } Snoop.Forms.Objects form = new Snoop.Forms.Objects(doc.ActiveView); form.ShowDialog(); result = Result.Succeeded; } catch (System.Exception e) { msg = e.Message; result = Result.Failed; } return(result); }
public Result Execute( ExternalCommandData cmdData, ref string msg, ElementSet elems) { Result result = Result.Failed; try { Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application; UIDocument uidoc = cmdData.Application.ActiveUIDocument; ICollection <ElementId> idPickfirst = uidoc.Selection.GetElementIds(); Document doc = uidoc.Document; ICollection <Element> elemSet = new List <Element>( idPickfirst.Select <ElementId, Element>( id => doc.GetElement(id))); ICollection <ElementId> ids = elemSet.SelectMany( t => t.GetDependentElements(null)).ToList(); Snoop.Forms.Objects form = new Snoop.Forms.Objects(doc, ids); ActiveDoc.UIApp = cmdData.Application; form.ShowDialog(); result = Result.Succeeded; } catch (System.Exception e) { msg = e.Message; } return(result); }
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elems) { Result result; using (var transaction = new Transaction(cmdData.Application.ActiveUIDocument.Document, this.GetType().Name)) { transaction.Start(); // necessary to snoop Document.PlanTopologies try { Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application; UIDocument revitDoc = cmdData.Application.ActiveUIDocument; Document dbdoc = revitDoc.Document; Snoop.CollectorExts.CollectorExt.m_activeDoc = dbdoc; // TBD: see note in CollectorExt.cs Autodesk.Revit.DB.View view = dbdoc.ActiveView; //ElementSet ss = cmdData.Application.ActiveUIDocument.Selection.Elements; // 2015, jeremy: 'Selection.Selection.Elements' is obsolete: 'This property is deprecated in Revit 2015. Use GetElementIds() and SetElementIds instead.' //if (ss.Size == 0) //{ // FilteredElementCollector collector = new FilteredElementCollector( revitDoc.Document, view.Id ); // collector.WhereElementIsNotElementType(); // FilteredElementIterator i = collector.GetElementIterator(); // i.Reset(); // ElementSet ss1 = cmdData.Application.Application.Create.NewElementSet(); // while( i.MoveNext() ) // { // Element e = i.Current as Element; // ss1.Insert( e ); // } // ss = ss1; //} ICollection <ElementId> ids = cmdData.Application.ActiveUIDocument.Selection.GetElementIds(); // 2016, jeremy if (0 == ids.Count) { FilteredElementCollector collector = new FilteredElementCollector(revitDoc.Document, view.Id) .WhereElementIsNotElementType(); ids = collector.ToElementIds(); } //ICollection<Element> elements // = new List<Element>( ids.Select<ElementId,Element>( // id => dbdoc.GetElement( id ) ) ); Snoop.Forms.Objects form = new Snoop.Forms.Objects(dbdoc, ids); ActiveDoc.UIApp = cmdData.Application; form.ShowDialog(); result = Result.Succeeded; } catch (System.Exception e) { msg = e.Message; result = Result.Failed; } transaction.RollBack(); } return(result); }
public Result Execute( ExternalCommandData cmdData, ref string msg, ElementSet elems) { Result result; using (var transaction = new Transaction(cmdData.Application.ActiveUIDocument.Document, this.GetType().Name)) { transaction.Start(); // necessary to snoop Document.PlanTopologies try { Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application; // TBD: see note in CollectorExt.cs Snoop.CollectorExts.CollectorExt.m_activeDoc = cmdData.Application.ActiveUIDocument.Document; // iterate over the collection and put them in an ArrayList so we can pass on // to our Form Autodesk.Revit.DB.Document doc = cmdData.Application.ActiveUIDocument.Document; FilteredElementCollector elemTypeCtor = (new FilteredElementCollector(doc)).WhereElementIsElementType(); FilteredElementCollector notElemTypeCtor = (new FilteredElementCollector(doc)).WhereElementIsNotElementType(); FilteredElementCollector allElementCtor = elemTypeCtor.UnionWith(notElemTypeCtor); ICollection <Element> founds = allElementCtor.ToElements(); ArrayList objs = new ArrayList(); foreach (Element element in founds) { objs.Add(element); } System.Diagnostics.Trace.WriteLine(founds.Count.ToString()); Snoop.Forms.Objects form = new Snoop.Forms.Objects(objs); ActiveDoc.UIApp = cmdData.Application; form.ShowDialog(); result = Result.Succeeded; } catch (System.Exception e) { msg = e.Message; result = Result.Failed; } transaction.RollBack(); } return(result); }
public Result Execute( ExternalCommandData cmdData, ref string msg, ElementSet elems) { Result result; try { Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application; Snoop.CollectorExts.CollectorExt.m_activeDoc = cmdData.Application.ActiveUIDocument.Document; Reference refElem = null; try { refElem = cmdData.Application.ActiveUIDocument .Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Face); } catch { return(Result.Succeeded); } //GeometryObject geoObject = cmdData.Application.ActiveUIDocument.Document.GetElement(refElem) // .GetGeometryObjectFromReference(refElem); Snoop.Forms.Objects form = new Snoop.Forms.Objects(refElem); ActiveDoc.UIApp = cmdData.Application; form.ShowDialog(); result = Result.Succeeded; } catch (System.Exception e) { msg = e.Message; result = Result.Failed; } return(result); }
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elems) { Result result; try { Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application; Document doc = cmdData.Application.ActiveUIDocument.Document; Reference refElem = null; try { refElem = cmdData.Application.ActiveUIDocument .Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.LinkedElement); } catch { return(Result.Succeeded); } string stableReflink = refElem.ConvertToStableRepresentation(doc).Split(':')[0]; Reference refLink = Reference.ParseFromStableRepresentation(doc, stableReflink); RevitLinkInstance rli_return = doc.GetElement(refLink) as RevitLinkInstance; Snoop.CollectorExts.CollectorExt.m_activeDoc = rli_return.GetLinkDocument(); Element e = Snoop.CollectorExts.CollectorExt.m_activeDoc.GetElement(refElem.LinkedElementId); Snoop.Forms.Objects form = new Snoop.Forms.Objects(e); ActiveDoc.UIApp = cmdData.Application; form.ShowDialog(); result = Result.Succeeded; } catch (System.Exception e) { msg = e.Message; result = Result.Failed; } return(result); }
public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData cmdData, ref string msg, ElementSet elems) { Autodesk.Revit.UI.Result result; try { Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application; Snoop.CollectorExts.CollectorExt.m_activeDoc = cmdData.Application.ActiveUIDocument.Document; // TBD: see note in CollectorExt.cs UIDocument revitDoc = cmdData.Application.ActiveUIDocument; Autodesk.Revit.DB.View view = revitDoc.Document.ActiveView; ElementSet ss = cmdData.Application.ActiveUIDocument.Selection.Elements; if (ss.Size == 0) { FilteredElementCollector collector = new FilteredElementCollector(revitDoc.Document, view.Id); collector.WhereElementIsNotElementType(); FilteredElementIterator i = collector.GetElementIterator(); i.Reset(); ElementSet ss1 = cmdData.Application.Application.Create.NewElementSet(); while (i.MoveNext()) { Element e = i.Current as Element; ss1.Insert(e); } ss = ss1; } Snoop.Forms.Objects form = new Snoop.Forms.Objects(ss); ActiveDoc.UIApp = cmdData.Application; form.ShowDialog(); result = Autodesk.Revit.UI.Result.Succeeded; } catch (System.Exception e) { msg = e.Message; result = Autodesk.Revit.UI.Result.Failed; } return(result); }
public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData cmdData, ref string msg, ElementSet elems) { Autodesk.Revit.UI.Result result; try { Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application; // TBD: see note in CollectorExt.cs Snoop.Forms.Objects form = new Snoop.Forms.Objects(cmdData.Application.Application); form.ShowDialog(); result = Autodesk.Revit.UI.Result.Succeeded; } catch (System.Exception e) { msg = e.Message; result = Autodesk.Revit.UI.Result.Failed; } return(result); }
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elems) { Result result; try { Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application; Snoop.CollectorExts.CollectorExt.m_activeDoc = cmdData.Application.ActiveUIDocument.Document; // TBD: see note in CollectorExt.cs Snoop.Forms.Objects form = new Snoop.Forms.Objects(cmdData.Application.Application); form.ShowDialog(); ActiveDoc.UIApp = cmdData.Application; result = Result.Succeeded; } catch (System.Exception e) { msg = e.Message; result = Result.Failed; } return(result); }
public Result Execute( ExternalCommandData cmdData, ref string msg, ElementSet elems ) { Result result; try { Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application; UIDocument revitDoc = cmdData.Application.ActiveUIDocument; Document dbdoc = revitDoc.Document; Snoop.CollectorExts.CollectorExt.m_activeDoc = dbdoc; // TBD: see note in CollectorExt.cs Autodesk.Revit.DB.View view = dbdoc.ActiveView; //ElementSet ss = cmdData.Application.ActiveUIDocument.Selection.Elements; // 2015, jeremy: 'Selection.Selection.Elements' is obsolete: 'This property is deprecated in Revit 2015. Use GetElementIds() and SetElementIds instead.' //if (ss.Size == 0) //{ // FilteredElementCollector collector = new FilteredElementCollector( revitDoc.Document, view.Id ); // collector.WhereElementIsNotElementType(); // FilteredElementIterator i = collector.GetElementIterator(); // i.Reset(); // ElementSet ss1 = cmdData.Application.Application.Create.NewElementSet(); // while( i.MoveNext() ) // { // Element e = i.Current as Element; // ss1.Insert( e ); // } // ss = ss1; //} ICollection<ElementId> ids = cmdData.Application.ActiveUIDocument.Selection.GetElementIds(); // 2016, jeremy if( 0 == ids.Count ) { FilteredElementCollector collector = new FilteredElementCollector( revitDoc.Document, view.Id ) .WhereElementIsNotElementType(); ids = collector.ToElementIds(); } //ICollection<Element> elements // = new List<Element>( ids.Select<ElementId,Element>( // id => dbdoc.GetElement( id ) ) ); Snoop.Forms.Objects form = new Snoop.Forms.Objects( dbdoc, ids ); ActiveDoc.UIApp = cmdData.Application; form.ShowDialog(); result = Result.Succeeded; } catch( System.Exception e ) { msg = e.Message; result = Result.Failed; } return result; }
public Result Execute( ExternalCommandData cmdData, ref string msg, ElementSet elems ) { Result result; try { Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application; // TBD: see note in CollectorExt.cs Snoop.CollectorExts.CollectorExt.m_activeDoc = cmdData.Application.ActiveUIDocument.Document; // iterate over the collection and put them in an ArrayList so we can pass on // to our Form Autodesk.Revit.DB.Document doc = cmdData.Application.ActiveUIDocument.Document; FilteredElementCollector elemTypeCtor = ( new FilteredElementCollector( doc ) ).WhereElementIsElementType(); FilteredElementCollector notElemTypeCtor = ( new FilteredElementCollector( doc ) ).WhereElementIsNotElementType(); FilteredElementCollector allElementCtor = elemTypeCtor.UnionWith( notElemTypeCtor ); ICollection<Element> founds = allElementCtor.ToElements(); ArrayList objs = new ArrayList(); foreach( Element element in founds ) { objs.Add( element ); } System.Diagnostics.Trace.WriteLine( founds.Count.ToString() ); Snoop.Forms.Objects form = new Snoop.Forms.Objects( objs ); ActiveDoc.UIApp = cmdData.Application; form.ShowDialog(); result = Result.Succeeded; } catch( System.Exception e ) { msg = e.Message; result = Result.Failed; } return result; }
public Result Execute( ExternalCommandData cmdData, ref string msg, ElementSet elems ) { Result result; try { Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application; Snoop.CollectorExts.CollectorExt.m_activeDoc = cmdData.Application.ActiveUIDocument.Document; // TBD: see note in CollectorExt.cs Snoop.Forms.Objects form = new Snoop.Forms.Objects( cmdData.Application.Application ); form.ShowDialog(); ActiveDoc.UIApp = cmdData.Application; result = Result.Succeeded; } catch( System.Exception e ) { msg = e.Message; result = Result.Failed; } return result; }
public Result Execute( ExternalCommandData cmdData, ref string msg, ElementSet elems ) { Result result; try { Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application; // TBD: see note in CollectorExt.cs Snoop.CollectorExts.CollectorExt.m_activeDoc = cmdData.Application.ActiveUIDocument.Document; // iterate over the collection and put them in an ArrayList so we can pass on // to our Form Autodesk.Revit.DB.Document doc = cmdData.Application.ActiveUIDocument.Document; if( doc.ActiveView == null ) { TaskDialog.Show( "RevitLookup", "The document must have an active view!" ); return Result.Cancelled; } Snoop.Forms.Objects form = new Snoop.Forms.Objects( doc.ActiveView ); form.ShowDialog(); result = Result.Succeeded; } catch( System.Exception e ) { msg = e.Message; result = Result.Failed; } return result; }
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elems) { Result result; try { Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application; UIDocument revitDoc = cmdData.Application.ActiveUIDocument; Document dbdoc = revitDoc.Document; Snoop.CollectorExts.CollectorExt.m_activeDoc = dbdoc; // TBD: see note in CollectorExt.cs Autodesk.Revit.DB.View view = dbdoc.ActiveView; //ElementSet ss = cmdData.Application.ActiveUIDocument.Selection.Elements; // 2015, jeremy: 'Selection.Selection.Elements' is obsolete: 'This property is deprecated in Revit 2015. Use GetElementIds() and SetElementIds instead.' //if (ss.Size == 0) //{ // FilteredElementCollector collector = new FilteredElementCollector( revitDoc.Document, view.Id ); // collector.WhereElementIsNotElementType(); // FilteredElementIterator i = collector.GetElementIterator(); // i.Reset(); // ElementSet ss1 = cmdData.Application.Application.Create.NewElementSet(); // while( i.MoveNext() ) // { // Element e = i.Current as Element; // ss1.Insert( e ); // } // ss = ss1; //} var input = Microsoft.VisualBasic.Interaction.InputBox("Enter element id:"); if (string.IsNullOrEmpty(input)) { return(Result.Cancelled); } int elementIdInt; if (!int.TryParse(input, out elementIdInt)) { msg = "Element id must be an integer"; return(Result.Failed); } var elementId = new ElementId(elementIdInt); var element = revitDoc.Document.GetElement(elementId); if (element == null) { msg = $"Element with id = {elementIdInt} not found"; return(Result.Failed); } ICollection <ElementId> ids = new List <ElementId> { elementId }; Snoop.Forms.Objects form = new Snoop.Forms.Objects(dbdoc, ids); ActiveDoc.UIApp = cmdData.Application; form.ShowDialog(); result = Result.Succeeded; } catch (System.Exception e) { msg = e.Message; result = Result.Failed; } return(result); }
public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData cmdData, ref string msg, ElementSet elems) { Autodesk.Revit.UI.Result result; try { Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application; Snoop.CollectorExts.CollectorExt.m_activeDoc = cmdData.Application.ActiveUIDocument.Document; // TBD: see note in CollectorExt.cs UIDocument revitDoc = cmdData.Application.ActiveUIDocument; Autodesk.Revit.DB.View view = revitDoc.Document.ActiveView; ElementSet ss = cmdData.Application.ActiveUIDocument.Selection.Elements; if (ss.Size == 0) { FilteredElementCollector collector = new FilteredElementCollector(revitDoc.Document, view.Id); collector.WhereElementIsNotElementType(); FilteredElementIterator i = collector.GetElementIterator(); i.Reset(); ElementSet ss1 = cmdData.Application.Application.Create.NewElementSet(); while (i.MoveNext()) { Element e = i.Current as Element; ss1.Insert(e); } ss = ss1; } Snoop.Forms.Objects form = new Snoop.Forms.Objects(ss); ActiveDoc.UIApp = cmdData.Application; form.ShowDialog(); result = Autodesk.Revit.UI.Result.Succeeded; } catch (System.Exception e) { msg = e.Message; result = Autodesk.Revit.UI.Result.Failed; } return result; }