-
Notifications
You must be signed in to change notification settings - Fork 0
/
SampleParameters_Type.cs
41 lines (38 loc) · 1.16 KB
/
SampleParameters_Type.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace TestWorks
{
class SampleParameters_Type
{
public void SetTypeParameter(Document doc)
{
Element e = FindElementByName(doc, typeof(WallType), "ApollosWall200");
WallType wallType = doc.GetElement(e.Id) as WallType;
try
{
using(Transaction t = new Transaction(doc, "Set Type"))
{
t.Start();
Parameter p = wallType.get_Parameter(BuiltInParameter.ALL_MODEL_COST);
p.Set(500);
t.Commit();
}
}
catch(Exception ex)
{
TaskDialog.Show("error", ex.Message);
}
}
public Element FindElementByName(Document doc, Type targetType, string targetName)
{
return new FilteredElementCollector(doc)
.OfClass(targetType)
.FirstOrDefault<Element>(e => e.Name.Equals(targetName));
}
}
}