-
Notifications
You must be signed in to change notification settings - Fork 0
/
annot.cs
86 lines (73 loc) · 2.79 KB
/
annot.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
74
75
76
77
78
79
80
81
82
83
84
85
86
using Autodesk.Revit.ApplicationServices;
//using Autodesk.Revit.Creation;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace WorkApp
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
class annot : IExternalCommand
{
Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
/*-
var sel = uidoc.Selection.GetElementIds().First();
var selel =doc.GetElement( sel) as Wall;
var box = selel.get_BoundingBox(doc.ActiveView);
*/
var allAnnot = new FilteredElementCollector(doc)
.OfCategory(BuiltInCategory.OST_GenericAnnotation)
.WhereElementIsNotElementType()
.Cast<FamilyInstance>();
var allUzl = new FilteredElementCollector(doc)
.OfCategory(BuiltInCategory.OST_DetailComponents)
.OfClass(typeof(FamilyInstance))
.WhereElementIsNotElementType()
.ToElements();
var allSpec = new FilteredElementCollector(doc)
.OfCategory(BuiltInCategory.OST_Views)
.ToElements();
using (Transaction tr=new Transaction(doc,"annot"))
{
tr.Start();
foreach (var i in allSpec)
{
try
{
i.LookupParameter("СП_Лист").Set(doc.GetElement(i.OwnerViewId).Name);
}
catch (Exception) { }
}
foreach (FamilyInstance i in allAnnot)
{
try
{
i.LookupParameter("СП_Лист").Set(doc.GetElement(i.OwnerViewId).Name);
}
catch (Exception) { }
}
foreach (FamilyInstance i in allUzl)
{
try
{
i.LookupParameter("СП_Лист").Set(doc.GetElement(i.OwnerViewId).Name);
}
catch (Exception) { }
}
tr.Commit();
}
return Result.Succeeded;
}
}
}