-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShapeCreator.cs
613 lines (536 loc) · 26 KB
/
ShapeCreator.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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
using Autodesk.Revit.DB;
using ricaun.Revit.DB.Shape.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
namespace ricaun.Revit.DB.Shape
{
/// <summary>
/// Provides static methods for creating various shapes.
/// </summary>
public static class ShapeCreator
{
/// <summary>
/// Default Sides for Prisms and Pyramids.
/// </summary>
internal const int Sides = 3;
#region Lines
/// <summary>
/// Creates an array of <see cref="Line"/> objects from a collection of <see cref="Autodesk.Revit.DB.XYZ"/> points.
/// </summary>
/// <param name="points">A collection of <see cref="Autodesk.Revit.DB.XYZ"/> points to create lines from.</param>
/// <param name="closed">
/// A boolean value indicating whether the lines should form a closed loop.
/// If true, an additional line will be created from the last point back to the first point.
/// </param>
/// <returns>
/// An array of <see cref="Line"/> objects representing the lines created from the specified points.
/// </returns>
public static Line[] CreateLines(IEnumerable<XYZ> points, bool closed)
{
return CreateLines(points, null, closed);
}
/// <summary>
/// Creates an array of <see cref="Line"/> objects from a collection of <see cref="Autodesk.Revit.DB.XYZ"/> points.
/// </summary>
/// <param name="points">A collection of <see cref="Autodesk.Revit.DB.XYZ"/> points to create lines from.</param>
/// <param name="graphicsStyleId">
/// An optional <see cref="Autodesk.Revit.DB.ElementId"/> representing the graphics style to apply to the lines.
/// If null, the default graphics style will be used.
/// </param>
/// <param name="closed">
/// A boolean value indicating whether the lines should form a closed loop.
/// If true, an additional line will be created from the last point back to the first point.
/// </param>
/// <returns>
/// An array of <see cref="Line"/> objects representing the lines created from the specified points.
/// </returns>
public static Line[] CreateLines(IEnumerable<XYZ> points, ElementId graphicsStyleId = null, bool closed = false)
{
var lines = new List<Line>();
var pointsArray = points.ToArray();
for (int i = 0; i < pointsArray.Length - 1; i++)
{
var line = CreateBound(pointsArray[i], pointsArray[i + 1], graphicsStyleId);
if (line is not null)
lines.Add(line);
}
if (closed)
{
var line = CreateBound(pointsArray[0], pointsArray[pointsArray.Length - 1], graphicsStyleId);
if (line is not null)
lines.Add(line);
}
return lines.ToArray();
}
/// <summary>
/// Creates an array of lines representing the edges of a 3D box with the specified minimum and maximum points.
/// </summary>
/// <param name="center">The center point of the box.</param>
/// <param name="scaleRadius">The scale size of the box.</param>
/// <param name="graphicsStyleId">The ID of the graphics style to use for the lines. If not specified, the lines will use the default graphics style.</param>
/// <returns>An array of lines representing the edges of the 3D box.</returns>
public static Line[] CreateBoxLines(XYZ center, double scaleRadius, ElementId graphicsStyleId = null)
{
var scaleXYZ = new XYZ(scaleRadius, scaleRadius, scaleRadius);
return CreateBoxLines(center - scaleXYZ, center + scaleXYZ, graphicsStyleId);
}
/// <summary>
/// Creates an array of lines representing the edges of a 3D box with the specified minimum and maximum points.
/// </summary>
/// <param name="min">The minimum point of the box. This point defines the lower corner of the box.</param>
/// <param name="max">The maximum point of the box. This point defines the upper corner of the box.</param>
/// <param name="graphicsStyleId">The ID of the graphics style to use for the lines. If not specified, the lines will use the default graphics style.</param>
/// <returns>An array of lines representing the edges of the 3D box.</returns>
/// <remarks>Ignore Lines with distance too short.</remarks>
public static Line[] CreateBoxLines(XYZ min, XYZ max, ElementId graphicsStyleId = null)
{
// Create an array to store the lines
Line[] lines = new Line[12];
// Calculate the vertices of the cube
XYZ[] vertices = {
new XYZ(min.X, min.Y, min.Z),
new XYZ(max.X, min.Y, min.Z),
new XYZ(max.X, max.Y, min.Z),
new XYZ(min.X, max.Y, min.Z),
new XYZ(min.X, min.Y, max.Z),
new XYZ(max.X, min.Y, max.Z),
new XYZ(max.X, max.Y, max.Z),
new XYZ(min.X, max.Y, max.Z)
};
// Create the lines for each edge of the cube using a for loop
for (int i = 0; i < 4; i++)
{
lines[i] = CreateBound(vertices[i], vertices[(i + 1) % 4], graphicsStyleId);
lines[i + 4] = CreateBound(vertices[i], vertices[i + 4], graphicsStyleId);
lines[i + 8] = CreateBound(vertices[i + 4], vertices[(i + 1) % 4 + 4], graphicsStyleId);
}
return lines.OfType<Line>().ToArray();
}
internal static Line CreateBound(XYZ point1, XYZ point2, ElementId graphicsStyleId = null)
{
try
{
var line = Line.CreateBound(point1, point2);
if (graphicsStyleId is not null)
line.SetGraphicsStyleId(graphicsStyleId);
return line;
}
catch { }
return null;
}
#endregion
#region Box
/// <summary>
/// Creates a 3D box with the specified center and size.
/// </summary>
/// <param name="center">The center point of the box.</param>
/// <param name="scaleRadius">The scale size of the box.</param>
/// <param name="materialId">The ID of the material to use for the box. If not specified, the box will use the default material.</param>
/// <param name="graphicsStyleId">The ID of the graphics style to use for the box. If not specified, the box will use the default graphics style.</param>
/// <returns>A solid representing the 3D box.</returns>
public static Solid CreateBox(XYZ center, double scaleRadius,
ElementId materialId = null,
ElementId graphicsStyleId = null)
{
var scaleXYZ = new XYZ(scaleRadius, scaleRadius, scaleRadius);
return CreateBox(center - scaleXYZ, center + scaleXYZ, materialId, graphicsStyleId);
}
/// <summary>
/// Creates a 3D box with the specified minimum and maximum points.
/// </summary>
/// <param name="min">The minimum point of the box. This point defines the lower corner of the box.</param>
/// <param name="max">The maximum point of the box. This point defines the upper corner of the box.</param>
/// <param name="materialId">The ID of the material to use for the box. If not specified, the box will use the default material.</param>
/// <param name="graphicsStyleId">The ID of the graphics style to use for the box. If not specified, the box will use the default graphics style.</param>
/// <returns>A solid representing the 3D box.</returns>
public static Solid CreateBox(XYZ min, XYZ max,
ElementId materialId = null,
ElementId graphicsStyleId = null)
{
// Create a list of CurveLoop objects to represent the profile of the box
var profileLoops = new List<CurveLoop>();
// Create the four lines connecting the minimum and maximum coordinates
Line line1 = Line.CreateBound(min, new XYZ(max.X, min.Y, min.Z));
Line line2 = Line.CreateBound(new XYZ(max.X, min.Y, min.Z), new XYZ(max.X, max.Y, min.Z));
Line line3 = Line.CreateBound(new XYZ(max.X, max.Y, min.Z), new XYZ(min.X, max.Y, min.Z));
Line line4 = Line.CreateBound(new XYZ(min.X, max.Y, min.Z), min);
// Add the lines to a CurveLoop object
CurveLoop curveLoop = new CurveLoop();
curveLoop.Append(line1);
curveLoop.Append(line2);
curveLoop.Append(line3);
curveLoop.Append(line4);
// Add the CurveLoop object to the list of profile loops
profileLoops.Add(curveLoop);
// Set the extrusion direction and distance
XYZ extrusionDir = XYZ.BasisZ;
double extrusionDist = max.Z - min.Z;
// Set material and graphicsStyle
SolidOptions solidOptions = CreateSolidOptions(materialId, graphicsStyleId);
// Create the solid box
Solid solid = GeometryCreationUtilities.CreateExtrusionGeometry(profileLoops, extrusionDir, extrusionDist, solidOptions);
return solid;
}
#endregion
#region Sphere
/// <summary>
/// Creates a 3D sphere with the specified center and radius.
/// </summary>
/// <param name="center">The center point of the sphere.</param>
/// <param name="radius">The radius of the sphere.</param>
/// <param name="materialId">The ID of the material to use for the sphere. If not specified, the sphere will use the default material.</param>
/// <param name="graphicsStyleId">The ID of the graphics style to use for sphere box. If not specified, the sphere will use the default graphics style.</param>
/// <returns>A solid representing the 3D sphere.</returns>
public static Solid CreateSphere(XYZ center, double radius,
ElementId materialId = null,
ElementId graphicsStyleId = null)
{
var profile = new List<Curve>();
XYZ profilePlus = center + new XYZ(0, radius, 0);
XYZ profileMinus = center - new XYZ(0, radius, 0);
profile.Add(Line.CreateBound(profilePlus, profileMinus));
profile.Add(Arc.Create(profileMinus, profilePlus, center + new XYZ(radius, 0, 0)));
CurveLoop curveLoop = CurveLoop.Create(profile);
SolidOptions solidOptions = CreateSolidOptions(materialId, graphicsStyleId);
Frame frame = new Frame(center, XYZ.BasisX, -XYZ.BasisZ, XYZ.BasisY);
Solid sphere = GeometryCreationUtilities.CreateRevolvedGeometry(frame, new CurveLoop[] { curveLoop }, 0, 2 * Math.PI, solidOptions);
return sphere;
}
#endregion
#region Cone / Cylinder
/// <summary>
/// CreateCone
/// </summary>
/// <param name="center"></param>
/// <param name="radius"></param>
/// <param name="height"></param>
/// <param name="materialId"></param>
/// <param name="graphicsStyleId"></param>
/// <returns></returns>
public static Solid CreateCone(XYZ center, double radius, double height = 0,
ElementId materialId = null,
ElementId graphicsStyleId = null)
{
var profile = new List<Curve>();
if (height <= 0) height = radius * 2;
center -= new XYZ(0, 0, height / 2.0);
XYZ profileCenter = center;
XYZ profileHeight = center + new XYZ(0, 0, height);
XYZ profileRadius = center + new XYZ(radius, 0, 0);
profile.Add(Line.CreateBound(profileCenter, profileHeight));
profile.Add(Line.CreateBound(profileHeight, profileRadius));
profile.Add(Line.CreateBound(profileRadius, profileCenter));
CurveLoop curveLoop = CurveLoop.Create(profile);
SolidOptions solidOptions = CreateSolidOptions(materialId, graphicsStyleId);
Frame frame = new Frame(center, XYZ.BasisX, XYZ.BasisY, XYZ.BasisZ);
Solid solid = GeometryCreationUtilities.CreateRevolvedGeometry(frame, new CurveLoop[] { curveLoop }, 0, 2 * Math.PI, solidOptions);
return solid;
}
/// <summary>
/// CreateCylinder
/// </summary>
/// <param name="center"></param>
/// <param name="radius"></param>
/// <param name="height"></param>
/// <param name="materialId"></param>
/// <param name="graphicsStyleId"></param>
/// <returns></returns>
public static Solid CreateCylinder(XYZ center, double radius, double height = 0,
ElementId materialId = null,
ElementId graphicsStyleId = null)
{
var profile = new List<Curve>();
if (height <= 0) height = radius * 2;
center -= new XYZ(0, 0, height / 2.0);
XYZ profileCenter = center;
XYZ profileHeight = center + new XYZ(0, 0, height);
XYZ profileRadius = center + new XYZ(radius, 0, 0);
XYZ profileRadiusHeight = center + new XYZ(radius, 0, height);
profile.Add(Line.CreateBound(profileCenter, profileHeight));
profile.Add(Line.CreateBound(profileHeight, profileRadiusHeight));
profile.Add(Line.CreateBound(profileRadiusHeight, profileRadius));
profile.Add(Line.CreateBound(profileRadius, profileCenter));
CurveLoop curveLoop = CurveLoop.Create(profile);
SolidOptions solidOptions = CreateSolidOptions(materialId, graphicsStyleId);
Frame frame = new Frame(center, XYZ.BasisX, XYZ.BasisY, XYZ.BasisZ);
Solid solid = GeometryCreationUtilities.CreateRevolvedGeometry(frame, new CurveLoop[] { curveLoop }, 0, 2 * Math.PI, solidOptions);
return solid;
}
#endregion
#region Prism / Pyramid
/// <summary>
/// CreatePrism
/// </summary>
/// <param name="center"></param>
/// <param name="radius"></param>
/// <param name="height"></param>
/// <param name="materialId"></param>
/// <param name="graphicsStyleId"></param>
/// <returns></returns>
public static Solid CreatePrism(XYZ center, double radius, double height = 0,
ElementId materialId = null,
ElementId graphicsStyleId = null)
{
return CreatePrism(Sides, center, radius, height, materialId, graphicsStyleId);
}
/// <summary>
/// CreatePrism
/// </summary>
/// <param name="sides"></param>
/// <param name="center"></param>
/// <param name="radius"></param>
/// <param name="height"></param>
/// <param name="materialId"></param>
/// <param name="graphicsStyleId"></param>
/// <returns></returns>
public static Solid CreatePrism(int sides, XYZ center, double radius, double height = 0,
ElementId materialId = null,
ElementId graphicsStyleId = null)
{
if (sides < 3) sides = 3;
if (height <= 0) height = radius * 2;
var heightHalfZ = height * XYZ.BasisZ / 2.0;
center -= heightHalfZ;
var profileLoops = new List<CurveLoop>();
var curveLoop = new CurveLoop();
var points = XYZUtils.CreateCircleLoopVertices(center, radius, sides);
for (int i = 0; i < points.Length; i++)
{
var p1 = points[(i + 0) % points.Length];
var p2 = points[(i + 1) % points.Length];
curveLoop.Append(Line.CreateBound(p1, p2));
}
profileLoops.Add(curveLoop);
XYZ extrusionDir = XYZ.BasisZ;
double extrusionDist = height;
SolidOptions solidOptions = CreateSolidOptions(materialId, graphicsStyleId);
Solid solid = GeometryCreationUtilities.CreateExtrusionGeometry(profileLoops, extrusionDir, extrusionDist, solidOptions);
return solid;
}
/// <summary>
/// CreatePyramid
/// </summary>
/// <param name="center"></param>
/// <param name="radius"></param>
/// <param name="height"></param>
/// <param name="materialId"></param>
/// <param name="graphicsStyleId"></param>
/// <returns></returns>
/// <remarks>This method uses <see cref="TessellatedShapeCreator"/> and return null if fails.</remarks>
public static Solid CreatePyramid(XYZ center, double radius, double height = 0,
ElementId materialId = null,
ElementId graphicsStyleId = null)
{
return CreatePyramid(Sides, center, radius, height, materialId, graphicsStyleId);
}
/// <summary>
/// CreatePyramid
/// </summary>
/// <param name="sides"></param>
/// <param name="center"></param>
/// <param name="radius"></param>
/// <param name="height"></param>
/// <param name="materialId"></param>
/// <param name="graphicsStyleId"></param>
/// <returns></returns>
/// <remarks>This method uses <see cref="TessellatedShapeCreator"/> and return null if fails.</remarks>
public static Solid CreatePyramid(int sides, XYZ center, double radius, double height = 0,
ElementId materialId = null,
ElementId graphicsStyleId = null)
{
if (sides < 3) sides = 3;
if (height <= 0) height = radius * 2;
var heightHalfZ = height * XYZ.BasisZ / 2.0;
var pyramidPoint = center + heightHalfZ;
center -= heightHalfZ;
var points = XYZUtils.CreateCircleLoopVertices(center, radius, sides);
var solid = TessellatedShapeCreator.Create((builder) =>
{
if (materialId is null) materialId = ElementId.InvalidElementId;
if (graphicsStyleId is not null) builder.GraphicsStyleId = graphicsStyleId;
for (int i = 0; i < points.Length; i++)
{
var p1 = points[(i + 0) % points.Length];
var p2 = points[(i + 1) % points.Length];
builder.AddFace(new List<XYZ> { p1, p2, pyramidPoint }, materialId);
}
builder.AddFace(points.ToList(), materialId);
}).OfType<Solid>().FirstOrDefault();
return solid;
}
#endregion
#region Utils
private static SolidOptions CreateSolidOptions(
ElementId materialId = null,
ElementId graphicsStyleId = null)
{
return new SolidOptions(materialId ?? ElementId.InvalidElementId, graphicsStyleId ?? ElementId.InvalidElementId);
}
/// <summary>
/// Create a Solid by union each of the input solids.
/// </summary>
/// <param name="solids"></param>
/// <returns></returns>
internal static Solid CreateSolid(params Solid[] solids)
{
return solids.Aggregate((a, b) => a.Union(b));
}
#endregion
#region Arrow / Gizmo
/// <summary>
/// Create Arrow pointing to axis
/// </summary>
/// <param name="axis"></param>
/// <param name="materialId"></param>
/// <param name="graphicsStyleId"></param>
/// <returns></returns>
public static Solid CreateArrow(
XYZ axis,
ElementId materialId = null,
ElementId graphicsStyleId = null)
{
return ShapeCreator.CreateArrow(materialId, graphicsStyleId)
.CreateTransformed(TransformUtils.CreateRotation(axis));
}
/// <summary>
/// CreateArrow
/// </summary>
/// <param name="materialId"></param>
/// <param name="graphicsStyleId"></param>
/// <returns></returns>
public static Solid CreateArrow(
ElementId materialId = null,
ElementId graphicsStyleId = null)
{
var cylinderHeight = 1.0 / 4.0;
var cylinderRadius = 1.0 / 48.0 / 4.0;
var coneHeight = 1.0 / 12.0;
var coneRadius = 1.0 / 48.0;
var cylinderCenter = XYZ.BasisZ * (cylinderHeight) / 2;
var coneCenter = cylinderCenter + XYZ.BasisZ * (cylinderHeight + coneHeight) / 2;
var cylinder = ShapeCreator.CreateCylinder(cylinderCenter, cylinderRadius, cylinderHeight, materialId, graphicsStyleId);
var cone = ShapeCreator.CreateCone(coneCenter, coneRadius, coneHeight, materialId, graphicsStyleId);
var solid = ShapeCreator.CreateSolid(cylinder, cone);
return solid;
}
/// <summary>
/// CreateArrow
/// </summary>
/// <param name="sides"></param>
/// <param name="axis"></param>
/// <param name="materialId"></param>
/// <param name="graphicsStyleId"></param>
/// <returns></returns>
/// <remarks>Sides limit equal to 10.</remarks>
internal static Solid CreateArrow(
int sides,
XYZ axis,
ElementId materialId = null,
ElementId graphicsStyleId = null)
{
return ShapeCreator.CreateArrow(sides, materialId, graphicsStyleId)
.CreateTransformed(TransformUtils.CreateRotation(axis));
}
/// <summary>
/// CreateArrow
/// </summary>
/// <param name="sides"></param>
/// <param name="materialId"></param>
/// <param name="graphicsStyleId"></param>
/// <returns></returns>
/// <remarks>Sides limit equal to 10.</remarks>
public static Solid CreateArrow(
int sides,
ElementId materialId = null,
ElementId graphicsStyleId = null)
{
if (sides > 10) sides = 10;
var cylinderHeight = 1.0 / 4.0;
var cylinderRadius = 1.0 / 48.0 / 4.0;
var coneHeight = 1.0 / 12.0;
var coneRadius = 1.0 / 48.0;
var cylinderCenter = XYZ.BasisZ * (cylinderHeight) / 2;
var coneCenter = cylinderCenter + XYZ.BasisZ * (cylinderHeight + coneHeight) / 2;
var cylinder = ShapeCreator.CreatePrism(sides, cylinderCenter, cylinderRadius, cylinderHeight, materialId, graphicsStyleId);
var cone = ShapeCreator.CreatePyramid(sides, coneCenter, coneRadius, coneHeight, materialId, graphicsStyleId);
var solid = ShapeCreator.CreateSolid(cylinder, cone);
return solid;
}
/// <summary>
/// CreateGizmo with base material colors.
/// </summary>
/// <param name="document"></param>
/// <param name="graphicsStyleId"></param>
/// <returns></returns>
/// <remarks>This method creates Material if not exist in the <paramref name="document"/></remarks>
public static Solid[] CreateGizmo(
Document document,
ElementId graphicsStyleId = null)
{
var materialRed = MaterialUtils.CreateMaterialRed(document);
var materialGreen = MaterialUtils.CreateMaterialGreen(document);
var materialBlue = MaterialUtils.CreateMaterialBlue(document);
return CreateGizmo(materialRed.Id, materialGreen.Id, materialBlue.Id, graphicsStyleId);
}
/// <summary>
/// CreateGizmo
/// </summary>
/// <param name="materialIdX"></param>
/// <param name="materialIdY"></param>
/// <param name="materialIdZ"></param>
/// <param name="graphicsStyleId"></param>
/// <returns></returns>
public static Solid[] CreateGizmo(
ElementId materialIdX = null,
ElementId materialIdY = null,
ElementId materialIdZ = null,
ElementId graphicsStyleId = null)
{
var solidRed = ShapeCreator.CreateArrow(XYZ.BasisX, materialIdX, graphicsStyleId);
var solidGreen = ShapeCreator.CreateArrow(XYZ.BasisY, materialIdY, graphicsStyleId);
var solidBlue = ShapeCreator.CreateArrow(XYZ.BasisZ, materialIdZ, graphicsStyleId);
return new[] { solidRed, solidGreen, solidBlue };
}
/// <summary>
/// CreateGizmo with base material colors.
/// </summary>
/// <param name="document"></param>
/// <param name="sides"></param>
/// <param name="graphicsStyleId"></param>
/// <returns></returns>
/// <remarks>This method creates Material if not exist in the <paramref name="document"/></remarks>
public static Solid[] CreateGizmo(
Document document,
int sides,
ElementId graphicsStyleId = null)
{
var materialRed = MaterialUtils.CreateMaterialRed(document);
var materialGreen = MaterialUtils.CreateMaterialGreen(document);
var materialBlue = MaterialUtils.CreateMaterialBlue(document);
return CreateGizmo(sides, materialRed.Id, materialGreen.Id, materialBlue.Id, graphicsStyleId);
}
/// <summary>
/// CreateGizmo
/// </summary>
/// <param name="sides"></param>
/// <param name="materialIdX"></param>
/// <param name="materialIdY"></param>
/// <param name="materialIdZ"></param>
/// <param name="graphicsStyleId"></param>
/// <returns></returns>
public static Solid[] CreateGizmo(
int sides,
ElementId materialIdX = null,
ElementId materialIdY = null,
ElementId materialIdZ = null,
ElementId graphicsStyleId = null)
{
var solidRed = ShapeCreator.CreateArrow(sides, XYZ.BasisX, materialIdX, graphicsStyleId);
var solidGreen = ShapeCreator.CreateArrow(sides, XYZ.BasisY, materialIdY, graphicsStyleId);
var solidBlue = ShapeCreator.CreateArrow(sides, XYZ.BasisZ, materialIdZ, graphicsStyleId);
return new[] { solidRed, solidGreen, solidBlue };
}
#endregion
}
}