Message 1 of 3
My first basic script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,I have a probably simple problem.I want select many elements and add to paramaeter "Comments" value "Something".I dont know where the problem is ;/.
using System;
using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Autodesk.Revit.ApplicationServices; using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Selection; namespace Lab1PlaceGroup { [Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)] public class Class1 : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uiapp.ActiveUIDocument.Document; IList<Reference> pickedobj = uidoc.Selection.PickObjects(ObjectType.Element, "SELECT").ToList(); IList<Parameter> param = new List<Parameter>(); for (int i = 0; i < pickedobj.Count; i++) { Element elemm = uidoc.Document.GetElement(pickedobj.ElementAt(i)); Parameter par = elemm.LookupParameter("Comments"); param.Append(par); } using (Transaction t = new Transaction(doc, "ASD")) { t.Start("TRANS"); try { int a = 0; foreach (Parameter x in param) { param.ElementAt(a).Set("Something"); a++; } } catch { } t.Commit(); } return Result.Succeeded; } } }