-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommandSetLCAParameterValue2.cs
64 lines (59 loc) · 2.12 KB
/
CommandSetLCAParameterValue2.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI.Selection;
using System.Data.SQLite;
using System.Data.SqlClient;
namespace TestWorks
{
//This is the Transaction mode set to Manual
[Transaction(TransactionMode.Manual)]
//This is the Setting LCA Parameter value public class IExternalCommand
public class CommandSetLCAParameterValue2 : 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 = uidoc.Document;
SampleCollector sc = new SampleCollector();
List<Wall> ListWalls_Class = sc.GetWalls_Class(doc);
foreach (Wall wall in ListWalls_Class)
{
using (Transaction t = new Transaction(doc, "setting LCA Value"))
{
t.Start();
try
{
var lcaParameter = wall.GetParameters("ClimateChangePerUnit");
if (lcaParameter != null)
{
foreach (Parameter parameter in lcaParameter)
{
parameter.Set(0.0099);
}
}
else
{
string message2 = string.Format("NULL");
TaskDialog.Show("There is no value", message2);
}
}
catch (Exception ex)
{
TaskDialog.Show(message, ex.Message);
}
t.Commit();
}
}
return Result.Succeeded;
}
}
}