-
Notifications
You must be signed in to change notification settings - Fork 0
/
MD1.cs
366 lines (249 loc) · 8.81 KB
/
MD1.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
/*
* Created by SharpDevelop.
* User: SMK
* Date: 01/06/2020
* Time: 07:55 p. m.
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.DB.Architecture;
namespace GeoAutoDim
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.DB.Macros.AddInId("38113AA1-C819-45D5-9FD7-2DBEFE62715F")]
public partial class ThisApplication
{
private void Module_Startup(object sender, EventArgs e)
{
}
private void Module_Shutdown(object sender, EventArgs e)
{
}
#region Revit Macros generated code
private void InternalStartup()
{
this.Startup += new System.EventHandler(Module_Startup);
this.Shutdown += new System.EventHandler(Module_Shutdown);
}
#endregion
public void LocationDim()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
Element ele = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element));
Location loc = ele.Location;
if(loc is LocationCurve)
{
LocationCurve lc = loc as LocationCurve;
Curve c = lc.Curve;
double length = UnitUtils.ConvertFromInternalUnits(c.ApproximateLength,DisplayUnitType.DUT_METERS);
TaskDialog.Show("Springall + mk","longitud de elemento en (m)" + " : " + length.ToString() + " m");
if(c is Line)
{
Line line = c as Line;
TaskDialog.Show("Springall + mk","LA LONGITUD RECTA EN (m) : " + UnitUtils.ConvertFromInternalUnits(line.ApproximateLength,DisplayUnitType.DUT_METERS).ToString());
}
}
}
public void EdgeDim()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
Reference myref = uidoc.Selection.PickObject(ObjectType.Edge);
Element el = doc.GetElement(myref);
GeometryObject geomObj = el.GetGeometryObjectFromReference(myref);
Edge edge = geomObj as Edge;
double length = UnitUtils.ConvertFromInternalUnits(edge.ApproximateLength,DisplayUnitType.DUT_METERS);
TaskDialog.Show("Springall + mk","longitud de elemento en (m)" + " : " + length.ToString() + " m");
}
public void SetParameter()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
string nombres = "";
string valores= "";
foreach(Element el in new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Furniture).WhereElementIsElementType())
{
string tnames = el.Name;
Parameter par = el.get_Parameter(BuiltInParameter.ALL_MODEL_TYPE_MARK);
valores += par.AsString() + Environment.NewLine;
nombres += tnames + Environment.NewLine;
}
TaskDialog.Show("INFO","TIPOS DE FAMILIA SON : " + nombres + Environment.NewLine + valores);
}
public void TopoTOExistingFloor()
{
Document doc = this.ActiveUIDocument.Document;
UIDocument uidoc = this.ActiveUIDocument;
TopographySurface ts = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element,"seleccionar subregion")) as TopographySurface;
Floor piso = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element,"seleccione piso o losa")) as Floor;
using (Transaction trans = new Transaction(doc,"TOPO TO FLOOR"))
{
trans.Start();
SlabShapeEditor ed = piso.SlabShapeEditor;
foreach(XYZ pt in ts.GetPoints())
{
ed.DrawPoint(pt);
}
trans.Commit();
}
}
public void GetKeynoteTable()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
FilteredElementCollector collector = new FilteredElementCollector(doc);
collector.OfClass(typeof(KeynoteTable));
string test = "";
foreach(KeynoteTable kt in collector)
{
KeyBasedTreeEntries kbe = kt.GetKeyBasedTreeEntries();
string ho = "";
foreach(KeyBasedTreeEntry k in kbe)
{
KeynoteEntry KE = k as KeynoteEntry;
string key = k.Key.ToString();
string keyvalue = k.ParentKey.ToString();
string keytext = KE.KeynoteText.ToString();
ho += key + " : " + keyvalue + " : " + keytext + Environment.NewLine;
}
test = ho;
}
TaskDialog.Show("INFO","CAMARA REY : " + test);
}
public void DeleteCADS()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
FilteredElementCollector collector = new FilteredElementCollector(doc).OfClass(typeof(ImportInstance));
string info = "";
IList<ElementId> elists = new List<ElementId>();
foreach(ImportInstance cad in collector)
{
ElementId cadids = cad.Id;
elists.Add(cadids);
info += cad.Id + Environment.NewLine;
}
using(Transaction trans = new Transaction(doc,"DELETING"))
{
trans.Start();
doc.Delete(elists);
trans.Commit();
}
TaskDialog.Show("indo","LA INFO PAPS :" + Environment.NewLine + info);
}
public void DeleteElement()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
Reference refe = uidoc.Selection.PickObject(ObjectType.Element,"SELECCIONE UN ELEMENTO A BORRAR");
using (Transaction trans = new Transaction(doc,"borrando"))
{
trans.Start();
doc.Delete(refe.ElementId);
trans.Commit();
}
}
public void SeleccionporCategoria()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
ICollection<ElementId> elements = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).ToElementIds();
uidoc.Selection.SetElementIds(elements);
}
public void InformacionSeleccionada()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
ICollection<ElementId> selectedIDS = uidoc.Selection.GetElementIds();
string s = "";
foreach(ElementId eleid in selectedIDS)
{
Element e = doc.GetElement(eleid);
s += e.Name + Environment.NewLine;
}
TaskDialog.Show("ELEMENTOS" , selectedIDS.Count + Environment.NewLine + s);
}
public void SeleccionFiltrada()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
Reference refWall = uidoc.Selection.PickObject(ObjectType.Element , new GenericSelectionFilter("Floors"),"SELECCIONE ALGO");
}
public class GenericSelectionFilter : ISelectionFilter
{
static string categoryName = "";
public GenericSelectionFilter(string name)
{
categoryName = name;
}
public bool AllowElement(Element el)
{
if(el.Category.Name == categoryName)
{
return true;
}
return false;
}
public bool AllowReference(Reference r , XYZ point)
{
return true;
}
}
public class WallSelectionFilter : ISelectionFilter
{
public bool AllowElement(Element e)
{
if(e.Category.Name == "Walls")
return true;
return false;
}
public bool AllowReference(Reference r, XYZ point)
{
return true;
}
}
public void GetRebarTypeName()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
FilteredElementCollector collector = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rebar).WhereElementIsElementType();
string info = "";
foreach(var bar in collector)
{
info += bar.Name + Environment.NewLine;
}
TaskDialog.Show("INFO","REBAR BAR TYPE : " + info);
}
public void GetSetParameters()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
IList<BuiltInCategory> catList = new List<BuiltInCategory>();
FilteredElementCollector collector = new FilteredElementCollector(doc);
collector.OfCategory(BuiltInCategory.OST_Floors).WhereElementIsElementType();
string typeNames = "";
foreach(FloorType muro in collector)
{
string keyvalue = "";
Parameter keynote = muro.get_Parameter(BuiltInParameter.KEYNOTE_PARAM);
if(keynote.HasValue)
{
keyvalue += keynote.AsString() + Environment.NewLine;
}
else
{
keyvalue += "NO KEYNOTE ASSIGNED" + Environment.NewLine;
}
typeNames += muro.Name.ToString() + Environment.NewLine + "KEYNOTE VALUE : " + keyvalue + Environment.NewLine;
}
TaskDialog.Show("bnt","LA INFO ES : " + typeNames);
}
}
}