Message 1 of 4

Not applicable
02-09-2018
12:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
These codes are from a book about Revit API(compiled by Autodesk), but VS says that 'Selection' does not contain a definition for 'Elements' and no extension method 'Elements' accepting a first argument of type 'Selection' could be found (are you missing a using directive or an assembly reference?). So what is the problem? Please help me~
using System; using Autodesk.Revit.DB; using Autodesk.Revit.UI.Selection; using Autodesk.Revit.UI; namespace select { [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)] public class Class1:IExternalCommand { public Autodesk.Revit.UI.Result Execute(ExternalCommandData revit,ref string message,ElementSet elements) { try { UIDocument uIDocument = revit.Application.ActiveUIDocument; Selection selection = uIDocument.Selection; ElementSet collection = selection.Elements; if (collection.Size == 0) TaskDialog.Show("Revit", "No elements selected"); else { string info = "information:"; foreach (ElementId elem in collection) info += "\n\t" + elem.GetType().ToString(); TaskDialog.Show("Revit", info); } } catch(Exception e) { message = e.Message; return Autodesk.Revit.UI.Result.Failed; } return Autodesk.Revit.UI.Result.Succeeded; } } }
Solved! Go to Solution.