-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBake.cs
55 lines (52 loc) · 2.1 KB
/
Bake.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
using Bentley.DgnPlatformNET.Elements;
using Bentley.GenerativeComponents;
using Bentley.GenerativeComponents.AddInSupport;
using Bentley.GenerativeComponents.DgnPlatformGC;
using Bentley.GenerativeComponents.ElementBasedNodes;
using Bentley.GenerativeComponents.GCScript;
using Bentley.GenerativeComponents.GeneralPurpose;
using Bentley.GenerativeComponents.GeneralPurpose.Atomic;
using Bentley.GenerativeComponents.View;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GCCommunity
{
[GCNamespace("User")]
[GCNodeTypePaletteCategory("Custom")]
[GCNodeTypeIcon("Resources/export.png")]
[GCSummary("Export GC Elements as generic MicroStation Elements, removing GC control.")]
public class Bake : GeometricNode
{
[GCDefaultTechnique]
[GCSummary("Copies the input geometry nodes into the active model, removing GC control over the elements.")]
[GCParameter("GeometryToBake", "Input geometry to bake into the active model")]
public NodeUpdateResult BakeElementsIntoActiveModel
(
NodeUpdateContext updateContext,
[GCIn, GCSingularOrPlural, GCDgnModelProvider] GeometricNode[] GeometryToBake
)
{
try
{
DialogResult dlg = MessageBox.Show($"Do you want to bake the geometry from {GeometryToBake.Length} nodes into the active model?", $"{this.Name} - Bake Elements", MessageBoxButtons.YesNo);
if (dlg == DialogResult.Yes)
{
foreach (GeometricNode node in GeometryToBake)
{
if (!node.Export(this.GCDgnModel(), isExternalDesignFile: false, null))
throw new Exception($"Failed to bake elements for node '{node.Name}'");
}
}
return NodeUpdateResult.Success;
}
catch (Exception ex)
{
return new NodeUpdateResult.TechniqueException(ex);
}
}
}
}