forked from tazuddinleton/revit-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFloorPlans.cs
73 lines (63 loc) · 2.42 KB
/
FloorPlans.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
65
66
67
68
69
70
71
72
73
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.Windows.Media.Imaging;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI;
namespace BIMAsistant
{
class FloorPlans
{
private Autodesk.Revit.DB.Document m_rvtDoc;
public ViewPlan selectedFloorPlan = null;
public List<ViewPlan> floorPlans;
public List<string> housingNum = null;
public FloorPlans(Autodesk.Revit.DB.Document m_rvtDoc)
{
this.m_rvtDoc = m_rvtDoc;
this.floorPlans = new List<ViewPlan>(new FilteredElementCollector(m_rvtDoc).OfClass(typeof(ViewPlan)).Cast<ViewPlan>().Where<ViewPlan>(v => !v.IsTemplate && ViewType.FloorPlan == v.ViewType));
}
public bool CreateDependents()
{
ElementId levelID = this.selectedFloorPlan.get_Parameter(BuiltInParameter.PLAN_VIEW_LEVEL).Id;
if(this.selectedFloorPlan != null && this.housingNum != null)
{
using (Transaction t = new Transaction(m_rvtDoc, "Create dependent views"))
{
t.Start();
try
{
for (int i = 0; i < housingNum.Count(); i++ )
{
ElementId viewID = this.selectedFloorPlan.Duplicate(ViewDuplicateOption.AsDependent);
ViewPlan plan = m_rvtDoc.GetElement(viewID) as ViewPlan;
if(plan == null)
{
throw new Exception("Can't create dependent views");
}
plan.Name = housingNum[i];
// var shape = plan.GetCropRegionShapeManager();
}
t.Commit();
return true;
}
catch
{
t.RollBack();
}
}
}
else
{
TaskDialog.Show("Revit", housingNum.ToString() + selectedFloorPlan.ToString());
}
return false;
}
}
}