Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
C:\Users\User\AppData\Roaming\Dynamo\Dynamo Core\2.1\packages\Sample View Extension
│ pkg.json
├───bin
│ SampleViewExtension.dll
├───dyf
└───extra
SampleViewExtension_ViewExtensionDefinition.xml<ViewExtensionDefinition>
<AssemblyPath>..\bin\MyViewExtension.dll</AssemblyPath>
<TypeName>MyViewExtension.MyViewExtension</TypeName>
</ViewExtensionDefinition><TargetFrameworks>net8.0;net10.0</TargetFrameworks>.dll namespace MyCustomNode
{
public class SampleFunctions
{
public static double MultiplyByTwo(double inputNumber)
{
return inputNumber * 2.0;
}
}
}namespace MyCustomNode
{
public class SampleFunctions
{
//The empty private constructor.
//This will be not imported into Dynamo.
private SampleFunctions() { }
//The public multiplication method.
//This will be imported into Dynamo.
public static double MultiplyByTwo(double inputNumber)
{
return inputNumber * 2.0;
}
}
} <evaluations>
<evaluation0>
<Node guid="e2a6a828-19cb-40ab-b36c-cde2ebab1ed3">
<output0 value="str" />
</Node>
<Node guid="67139026-e3a5-445c-8ba5-8a28be5d1be0">
<output0 value="C:\Users\Dale\state1.txt" />
</Node>
<Node guid="579ebcb8-dc60-4faa-8fd0-cb361443ed94">
<output0 value="null" />
</Node>
</evaluation0>
<evaluation1>
<Node guid="e2a6a828-19cb-40ab-b36c-cde2ebab1ed3">
<output0 value="str" />
</Node>
<Node guid="67139026-e3a5-445c-8ba5-8a28be5d1be0">
<output0 value="C:\Users\Dale\state2.txt" />
</Node>
<Node guid="579ebcb8-dc60-4faa-8fd0-cb361443ed94">
<output0 value="null" />
</Node>
</evaluation1>
</evaluations>public class Application
{
string m_sProdID = "SomeNamespace.Application";
public dynamic m_oApp = null; // Use dynamic so you do not need the PIA types
public Application()
{
this.GetApplication();
}
internal void GetApplication()
{
try
{
m_oApp = System.Runtime.InteropServices.Marshal.GetActiveObject(m_sProdID);
}
catch (Exception /*ex*/)
{}
}
}
}namespace SampleLibraryUI.Examples// Class Attribute
[NodeName("MyNodeModel")]
public class MyNewNodeModel : NodeModel
// or
// Constructor
public ButtonCustomNodeModel()
{
this.Name = "MyNodeModel";
}
SampleLibraryUI/Examples/MyNodeModel// Class Attribute
[NodeCategory("NewSampleLibraryUI.Examples")]
// or
// Constructor
public ButtonCustomNodeModel()
{
this.Category = "NewSampleLibraryUI.Examples";
}NewSampleLibraryUI/Examples/MyNodeModelnamespace MyZTLibrarypublic class Utilities
{
public double doubleValue(double num)
{
return num * 2;
}
}MyZTLibrary/Utilities/doubleValue<?xml version="1.0"?>
<doc>
<assembly>
<name>MeshToolkit</name>
</assembly>
<namespaces>
<!--Remap Namespaces-->
<namespace name="Autodesk.Dynamo.MeshToolkit">
<category>MeshToolkit</category>
</namespace>
<namespace name="Autodesk.Dynamo.MeshToolkit.Display">
<category>Display</category>
</namespace>
</namespaces>
<classes>
<!--Remap Class Names-->
<class name="Autodesk.Dynamo.MeshToolkit.Display.MeshDisplay" shortname="MeshDisplay"/>
<class name="Autodesk.Dynamo.MeshToolkit.Mesh" shortname="Mesh"/>
</classes>
</doc>
{
"Uuid": "85066088-1616-40b1-96e1-c33e685c6948",
"IsCustomNode": true,
"Category": "MyCustomNodes.Utilities.Actions",
"Description": "This is an example custom nodes.",
"Name": "doubleValue",
"ElementResolver": {
"ResolutionMap": {}
},...<Workspace Version="1.3.0.0000" X="100" Y="100" zoom="1.0000000" Description="This is an example custom nodes." Category="MyCustomNodes.Utilities.Actions" Name="doubleValue" ID="85066088-1616-40b1-96e1-c33e685c6948"><?xml version="1.0"?>
<migrations>
<priorNameHint>
<oldName>MyZeroTouchLib.MyNodes.SayHello</oldName>
<newName>MyZeroTouchLib.MyNodes.SayHelloRENAMED</newName>
</priorNameHint>
</migrations>namespace SampleLibraryUI.Examples
{
[NodeName("Drop Down Example")]
[NodeDescription("An example drop down node.")]
[IsDesignScriptCompatible]
[AlsoKnownAs("SampleLibraryUI.Examples.DropDownExample")]
public class DropDownExampleRENAMED : DSDropDownBase
{
...
}
{CustomNodeModel
> src
> CustomNodeModel
> CustomNodeModelFunction
> packages
> CustomNodeModel.sln <Target Name="AfterBuild">
<ItemGroup>
<Dlls Include="$(OutDir)*.dll" />
<Pdbs Include="$(OutDir)*.pdb" />
<Xmls Include="$(OutDir)*.xml" />
<Configs Include="$(OutDir)*.config" />
</ItemGroup>
<Copy SourceFiles="@(Dlls)" DestinationFolder="$(SolutionDir)..\packages\CustomNodeModel\bin\" />
<Copy SourceFiles="@(Pdbs)" DestinationFolder="$(SolutionDir)..\packages\CustomNodeModel\bin\" />
<Copy SourceFiles="@(Xmls)" DestinationFolder="$(SolutionDir)..\packages\CustomNodeModel\bin\" />
<Copy SourceFiles="@(Configs)" DestinationFolder="$(SolutionDir)..\packages\CustomNodeModel\bin\" />
<MakeDir Directories="$(SolutionDir)..\packages\CustomNodeModel\dyf" />
<MakeDir Directories="$(SolutionDir)..\packages\CustomNodeModel\extra" />
</Target><ItemGroup>
<Dlls Include="$(OutDir)*.dll" />
</ItemGroup><Copy SourceFiles="@(Dlls)" DestinationFolder="$(SolutionDir)..\packages\CustomNodeModel\bin\" /><MakeDir Directories="$(SolutionDir)..\packages\CustomNodeModel\extra" />using Autodesk.DesignScript.Geometry;
using System.Collections.Generic;
namespace CustomNodes
{
public class Grids
{
public static List<Rectangle> RectangularGrid(int xCount, int yCount)
{
//The method for creating a rectangular grid will live in here
}
}
}using Autodesk.DesignScript.Geometry;
using System.Collections.Generic;
namespace CustomNodes
{
public class Grids
{
public static List<Rectangle> RectangularGrid(int xCount, int yCount)
{
double x = 0;
double y = 0;
var pList = new List<Rectangle>();
for (int i = 0; i < xCount; i++)
{
y++;
x = 0;
for (int j = 0; j < yCount; j++)
{
x++;
Point pt = Point.ByCoordinates(x, y);
Vector vec = Vector.ZAxis();
Plane bP = Plane.ByOriginNormal(pt, vec);
Rectangle rect = Rectangle.ByWidthLength(bP, 1, 1);
pList.Add(rect);
}
}
return pList;
}
}
}using Autodesk.DesignScript.Geometry;
using System.Collections.Generic;
namespace CustomNodes
{
public class Grids
{
/// <summary>
/// This method creates a rectangular grid from an X and Y count.
/// </summary>
/// <param name="xCount">Number of grid cells in the X direction</param>
/// <param name="yCount">Number of grid cells in the Y direction</param>
/// <returns>A list of rectangles</returns>
/// <search>grid, rectangle</search>
public static List<Rectangle> RectangularGrid(int xCount = 10, int yCount = 10)
{
double x = 0;
double y = 0;
var pList = new List<Rectangle>();
for (int i = 0; i < xCount; i++)
{
y++;
x = 0;
for (int j = 0; j < yCount; j++)
{
x++;
Point pt = Point.ByCoordinates(x, y);
Vector vec = Vector.ZAxis();
Plane bP = Plane.ByOriginNormal(pt, vec);
Rectangle rect = Rectangle.ByWidthLength(bP, 1, 1);
pList.Add(rect);
Point cPt = rect.Center();
}
}
return pList;
}
}
}using IronPython.Hosting;
using Microsoft.Scripting.Hosting;
namespace PythonLibrary
{
public class PythonZT
{
// Unless a constructor is provided, Dynamo will automatically create one and add it to the library
// To avoid this, create a private constructor
private PythonZT() { }
// The method that executes the Python string
public static string executePyString(string pyString)
{
ScriptEngine engine = Python.CreateEngine();
ScriptScope scope = engine.CreateScope();
engine.Execute(pyString, scope);
// Return the value of the 'output' variable from the Python script below
var output = scope.GetVariable("output");
return (output);
}
}
}import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
cube = Cuboid.ByLengths(10,10,10);
volume = cube.Volume
output = str(volume)using IronPython.Hosting;
using Microsoft.Scripting.Hosting;
using System.Collections.Generic;
using Autodesk.DesignScript.Runtime;
namespace PythonLibrary
{
public class PythonZT
{
private PythonZT() { }
[MultiReturn(new[] { "output1", "output2" })]
public static Dictionary<string, object> executePyString(string pyString)
{
ScriptEngine engine = Python.CreateEngine();
ScriptScope scope = engine.CreateScope();
engine.Execute(pyString, scope);
// Return the value of 'output1' from script
var output1 = scope.GetVariable("output1");
// Return the value of 'output2' from script
var output2 = scope.GetVariable("output2");
// Define the names of outputs and the objects to return
return new Dictionary<string, object> {
{ "output1", (output1) },
{ "output2", (output2) }
};
}
}
}import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
cube = Cuboid.ByLengths(10,10,10);
centroid = Cuboid.Centroid(cube);
volume = cube.Volume
output1 = str(volume)
output2 = str(centroid)# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Revit API
from Autodesk.Revit.DB import *
# Revit Geometry Conversion Library
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
# Input: Dynamo Point
dyn_point = IN[0]
# Convert to Revit XYZ
revit_point = dyn_point.ToXyz()
# Output
OUT = revit_point
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Revit API
from Autodesk.Revit.DB import *
# Revit Geometry Conversion Library
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
# Input: Dynamo Point
dyn_point = IN[0]
# Convert to Revit XYZ
revit_point = dyn_point.ToPoint()
# Output
OUT = revit_pointimport sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Revit API
from Autodesk.Revit.DB import *
# Revit Geometry Conversion Library
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
# Input: Measure Angle
degree_angle = IN[0]
# Convert to Radians
radian_angle = Revit.GeometryConversion.GeometryPrimitiveConverter.ToRadians(degree_angle)
# Output
OUT = radian_angleimport clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Revit API
from Autodesk.Revit.DB import *
# Revit Geometry Conversion Library
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
# Input Dynamo Vector
input_vector = IN[0]
# Get perpendicular vector using GetPerpendicular
perpendicular_vector = Revit.GeometryConversion.GeometryPrimitiveConverter.GetPerpendicular(input_vector)
# Output the perpendicular vector
OUT = perpendicular_vector
/// <returns>...</returns><priorNameHint>...</priorNameHint> para cada alteração de nomeZeroTouchEssentials.Migrations.xml.xamlSampleViewExtensionnamespace ZeroTouchEssentials
{
public class ZeroTouchEssentials
{
// Set the method parameter to a default value
public static double MultiplyByTwo(double inputNumber = 2.0)
{
return inputNumber * 2.0;
}
}
}using System.Collections.Generic;
using Autodesk.DesignScript.Runtime;
namespace ZeroTouchEssentials
{
public class ZeroTouchEssentials
{
[MultiReturn(new[] { "add", "mult" })]
public static Dictionary<string, object> ReturnMultiExample(double a, double b)
{
return new Dictionary<string, object>
{ "add", (a + b) },
{ "mult", (a * b) }
};
}
}
}using Autodesk.DesignScript.Geometry;
namespace ZeroTouchEssentials
{
public class ZeroTouchEssentials
{
/// <summary>
/// This method demonstrates how to use a native geometry object from Dynamo
/// in a custom method
/// </summary>
/// <param name="curve">Input Curve. This can be of any type deriving from Curve, such as NurbsCurve, Arc, Circle, etc</param>
/// <returns>The twice the length of the Curve </returns>
/// <search>example,curve</search>
public static double DoubleLength(Curve curve)
{
return curve.Length * 2.0;
}
}
}namespace ZeroTouchEssentials
{
public class ZeroTouchEssentials
{
private double _a;
private double _b;
// Make the constructor internal
internal ZeroTouchEssentials(double a, double b)
{
_a = a;
_b = b;
}
// The static method that Dynamo will convert into a Create node
public static ZeroTouchEssentials ByTwoDoubles(double a, double b)
{
return new ZeroTouchEssentials(a, b);
}
}
}using Autodesk.DesignScript.Geometry;
namespace ZeroTouchEssentials
{
public class ZeroTouchEssentials
{
// "Autodesk.DesignScript.Geometry.Curve" is specifying the type of geometry input,
// just as you would specify a double, string, or integer
public static double DoubleLength(Autodesk.DesignScript.Geometry.Curve curve)
{
return curve.Length * 2.0;
}
}
}using (Point p1 = Point.ByCoordinates(0, 0, 0))
{
using (Point p2 = Point.ByCoordinates(10, 10, 0))
{
return Line.ByStartPointEndPoint(p1, p2);
}
}Point p1 = Point.ByCoordinates(0, 0, 0);
Point p2 = Point.ByCoordinates(10, 10, 0);
Line l = Line.ByStartPointEndPoint(p1, p2);
p1.Dispose();
p2.Dispose();
return l;<?xml version="1.0"?>
<migrations>
<priorNameHint>
<oldName>Autodesk.DesignScript.Geometry.Geometry.GetClosestPoint</oldName>
<newName>Autodesk.DesignScript.Geometry.Geometry.ClosestPointTo</newName>
</priorNameHint>
</migrations>public class SomeGenericClass<T>
{
public SomeGenericClass()
{
Console.WriteLine(typeof(T).ToString());
}
}public class SomeWrapper
{
public object wrapped;
public SomeWrapper(SomeGenericClass<double> someConstrainedType)
{
Console.WriteLine(this.wrapped.GetType().ToString());
}
}using System;
using System.Windows;
using System.Windows.Controls;
using Dynamo.Wpf.Extensions;
namespace SampleViewExtension
{
public class SampleViewExtension : IViewExtension
{
private MenuItem sampleMenuItem;
public void Dispose()
{
}
public void Startup(ViewStartupParams p)
{
}
public void Loaded(ViewLoadedParams p)
{
// Save a reference to your loaded parameters.
// You'll need these later when you want to use
// the supplied workspaces
sampleMenuItem = new MenuItem {Header = "Show View Extension Sample Window"};
sampleMenuItem.Click += (sender, args) =>
{
var viewModel = new SampleWindowViewModel(p);
var window = new SampleWindow
{
// Set the data context for the main grid in the window.
MainGrid = { DataContext = viewModel },
// Set the owner of the window to the Dynamo window.
Owner = p.DynamoWindow
};
window.Left = window.Owner.Left + 400;
window.Top = window.Owner.Top + 200;
// Show a modeless window.
window.Show();
};
p.AddExtensionMenuItem(sampleMenuItem);
}
public void Shutdown()
{
}
public string UniqueId
{
get
{
return Guid.NewGuid().ToString();
}
}
public string Name
{
get
{
return "Sample View Extension";
}
}
}
}using System;
using Dynamo.Core;
using Dynamo.Extensions;
using Dynamo.Graph.Nodes;
namespace SampleViewExtension
{
public class SampleWindowViewModel : NotificationObject, IDisposable
{
private string activeNodeTypes;
private ReadyParams readyParams;
// Displays active nodes in the workspace
public string ActiveNodeTypes
{
get
{
activeNodeTypes = getNodeTypes();
return activeNodeTypes;
}
}
// Helper function that builds string of active nodes
public string getNodeTypes()
{
string output = "Active nodes:\n";
foreach (NodeModel node in readyParams.CurrentWorkspaceModel.Nodes)
{
string nickName = node.Name;
output += nickName + "\n";
}
return output;
}
public SampleWindowViewModel(ReadyParams p)
{
readyParams = p;
p.CurrentWorkspaceModel.NodeAdded += CurrentWorkspaceModel_NodesChanged;
p.CurrentWorkspaceModel.NodeRemoved += CurrentWorkspaceModel_NodesChanged;
}
private void CurrentWorkspaceModel_NodesChanged(NodeModel obj)
{
RaisePropertyChanged("ActiveNodeTypes");
}
public void Dispose()
{
readyParams.CurrentWorkspaceModel.NodeAdded -= CurrentWorkspaceModel_NodesChanged;
readyParams.CurrentWorkspaceModel.NodeRemoved -= CurrentWorkspaceModel_NodesChanged;
}
}
}<Window x:Class="SampleViewExtension.SampleWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SampleViewExtension"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Width="500" Height="100">
<Grid Name="MainGrid"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<TextBlock HorizontalAlignment="Stretch" Text="{Binding ActiveNodeTypes}" FontFamily="Arial" Padding="10" FontWeight="Medium" FontSize="18" Background="#2d2d2d" Foreground="White"/>
</Grid>
</Window>using System.Windows;
namespace SampleViewExtension
{
/// <summary>
/// Interaction logic for SampleWindow.xaml
/// </summary>
public partial class SampleWindow : Window
{
public SampleWindow()
{
InitializeComponent();
}
}
}<ViewExtensionDefinition>
<AssemblyPath>C:\Users\username\Documents\Visual Studio 2015\Projects\SampleViewExtension\SampleViewExtension\bin\Debug\SampleViewExtension.dll</AssemblyPath>
<TypeName>SampleViewExtension.SampleViewExtension</TypeName>
</ViewExtensionDefinition>using System;
using System.Collections.Generic;
using Dynamo.Graph.Nodes;
using CustomNodeModel.CustomNodeModelFunction;
using ProtoCore.AST.AssociativeAST;
using Autodesk.DesignScript.Geometry;
namespace CustomNodeModel.CustomNodeModel
{
[NodeName("RectangularGrid")]
[NodeDescription("An example NodeModel node that creates a rectangular grid. The slider randomly scales the cells.")]
[NodeCategory("CustomNodeModel")]
[InPortNames("xCount", "yCount")]
[InPortTypes("double", "double")]
[InPortDescriptions("Number of cells in the X direction", "Number of cells in the Y direction")]
[OutPortNames("Rectangles")]
[OutPortTypes("Autodesk.DesignScript.Geometry.Rectangle[]")]
[OutPortDescriptions("A list of rectangles")]
[IsDesignScriptCompatible]
public class GridNodeModel : NodeModel
{
private double _sliderValue;
public double SliderValue
{
get { return _sliderValue; }
set
{
_sliderValue = value;
RaisePropertyChanged("SliderValue");
OnNodeModified(false);
}
}
public GridNodeModel()
{
RegisterAllPorts();
}
public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
{
if (!HasConnectedInput(0) || !HasConnectedInput(1))
{
return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), AstFactory.BuildNullNode()) };
}
var sliderValue = AstFactory.BuildDoubleNode(SliderValue);
var functionCall =
AstFactory.BuildFunctionCall(
new Func<int, int, double, List<Rectangle>>(GridFunction.RectangularGrid),
new List<AssociativeNode> { inputAstNodes[0], inputAstNodes[1], sliderValue });
return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), functionCall) };
}
}
}[JsonConstructor]
protected GridNodeModel(IEnumerable<PortModel> Inports, IEnumerable<PortModel> Outports ) :
base(Inports,Outports)
{
}[InPortNames("xCount", "yCount")]
[InPortTypes("double", "double")] public ButtonCustomNodeModel()
{
// When you create a UI node, you need to do the
// work of setting up the ports yourself. To do this,
// you can populate the InPorts and the OutPorts
// collections with PortData objects describing your ports.
InPorts.Add(new PortModel(PortType.Input, this, new PortData("inputString", "a string value displayed on our button")));
// Nodes can have an arbitrary number of inputs and outputs.
// If you want more ports, just create more PortData objects.
OutPorts.Add(new PortModel(PortType.Output, this, new PortData("button value", "returns the string value displayed on our button")));
OutPorts.Add(new PortModel(PortType.Output, this, new PortData("window value", "returns the string value displayed in our window when button is pressed")));
// This call is required to ensure that your ports are
// properly created.
RegisterAllPorts();
// Listen for input port disconnection to trigger button UI update
this.PortDisconnected += ButtonCustomNodeModel_PortDisconnected;
// The arugment lacing is the way in which Dynamo handles
// inputs of lists. If you don't want your node to
// support argument lacing, you can set this to LacingStrategy.Disabled.
ArgumentLacing = LacingStrategy.Disabled;
// We create a DelegateCommand object which will be
// bound to our button in our custom UI. Clicking the button
// will call the ShowMessage method.
ButtonCommand = new DelegateCommand(ShowMessage, CanShowMessage);
// Setting our property here will trigger a
// property change notification and the UI
// will be updated to reflect the new value.
ButtonText = defaultButtonText;
WindowText = defaultWindowText;
} // This constructor is called when opening a Json graph.
[JsonConstructor]
ButtonCustomNodeModel(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
{
this.PortDisconnected += ButtonCustomNodeModel_PortDisconnected;
ButtonCommand = new DelegateCommand(ShowMessage, CanShowMessage);
}OnLogWarningMessageOnLogWarningMessage para registrar o avisoOnLogWarningMessageOnLogWarningMessageOnLogInfoMessageOnLogInfoMessageOnLogInfoMessage para registrar mensagens informativasOnLogInfoMessageOnLogInfoMessage.dll e o .customization.dll estão na pasta bin.using DynamoServices;LogWarningMessageEvents.OnLogWarningMessage("Your warning message here.");public static List<Rectangle> CreateGrid(int xCount, int yCount)
{
// Check if xCount and yCount are positive
if (xCount <= 0 || yCount <= 0)
{
LogWarningMessageEvents.OnLogWarningMessage("Grid count values must be positive integers.");
return new List<Rectangle>(); // Return an empty list if inputs are invalid
}
// Proceed with grid creation...
}using Autodesk.DesignScript.Geometry;
using DynamoServices;
namespace CustomNodes
{
public class Grids
{
// The empty private constructor.
// This will not be imported into Dynamo.
private Grids() { }
/// <summary>
/// This method creates a rectangular grid from an X and Y count.
/// </summary>
/// <param name="xCount">Number of grid cells in the X direction</param>
/// <param name="yCount">Number of grid cells in the Y direction</param>
/// <returns>A list of rectangles</returns>
/// <search>grid, rectangle</search>
public static List<Rectangle> RectangularGrid(int xCount = 10, int yCount = 10)
{
// Check for valid input values
if (xCount <= 0 || yCount <= 0)
{
// Log a warning message if the input values are invalid
LogWarningMessageEvents.OnLogWarningMessage("Grid count values must be positive integers.");
return new List<Rectangle>(); // Return an empty list if inputs are invalid
}
double x = 0;
double y = 0;
var pList = new List<Rectangle>();
for (int i = 0; i < xCount; i++)
{
y++;
x = 0;
for (int j = 0; j < yCount; j++)
{
x++;
Point pt = Point.ByCoordinates(x, y);
Vector vec = Vector.ZAxis();
Plane bP = Plane.ByOriginNormal(pt, vec);
Rectangle rect = Rectangle.ByWidthLength(bP, 1, 1);
pList.Add(rect);
Point cPt = rect.Center();
}
}
return pList;
}
}
}public static Polygon CreatePolygonFromPoints(List<Point> points)
{
if (points == null || points.Count < 3)
{
LogWarningMessageEvents.OnLogWarningMessage("Point list cannot be null or have fewer than three points.");
return null; // Return null if the input list is invalid
}
// Proceed with polygon creation...
}public static void ProcessFile(string filePath)
{
if (!filePath.EndsWith(".csv"))
{
LogWarningMessageEvents.OnLogWarningMessage("Only CSV files are supported.");
return;
}
// Proceed with file processing...
}LogWarningMessageEvents.OnLogInfoMessage("Your info message here.");public static List<Rectangle> CreateGrid(int xCount, int yCount)
{
var pList = new List<Rectangle>();
// Grid creation code here...
// Confirm successful grid creation
LogWarningMessageEvents.OnLogInfoMessage($"Successfully created a grid with dimensions {xCount}x{yCount}.");
return pList;
}using Autodesk.DesignScript.Geometry;
using DynamoServices;
namespace CustomNodes
{
public class Grids
{
// The empty private constructor.
// This will not be imported into Dynamo.
private Grids() { }
/// <summary>
/// This method creates a rectangular grid from an X and Y count.
/// </summary>
/// <param name="xCount">Number of grid cells in the X direction</param>
/// <param name="yCount">Number of grid cells in the Y direction</param>
/// <returns>A list of rectangles</returns>
/// <search>grid, rectangle</search>
public static List<Rectangle> RectangularGrid(int xCount = 10, int yCount = 10)
{
double x = 0;
double y = 0;
var pList = new List<Rectangle>();
for (int i = 0; i < xCount; i++)
{
y++;
x = 0;
for (int j = 0; j < yCount; j++)
{
x++;
Point pt = Point.ByCoordinates(x, y);
Vector vec = Vector.ZAxis();
Plane bP = Plane.ByOriginNormal(pt, vec);
Rectangle rect = Rectangle.ByWidthLength(bP, 1, 1);
pList.Add(rect);
Point cPt = rect.Center();
}
}
// Log an info message indicating the grid was successfully created
LogWarningMessageEvents.OnLogInfoMessage($"Successfully created a grid with dimensions {xCount}x{yCount}.");
return pList;
}
}
}public static List<Point> ProcessPoints(List<Point> points)
{
var processedPoints = new List<Point>();
foreach (var point in points)
{
// Process each point...
processedPoints.Add(point);
}
// Log info about the count of processed points
LogWarningMessageEvents.OnLogInfoMessage($"{processedPoints.Count} points were processed successfully.");
return processedPoints;
}public static void ExportData(string filePath, List<string> data)
{
// Code to write data to the specified file path...
// Log the file path used for export
LogWarningMessageEvents.OnLogInfoMessage($"Data exported successfully to {filePath}.");
}<Target Name="CreateNodeIcons" AfterTargets="PostBuildEvent">
<!-- Get System.Drawing.dll -->
<GetReferenceAssemblyPaths TargetFrameworkMoniker=".NETFramework, Version=v4.8">
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="FrameworkAssembliesPath" />
</GetReferenceAssemblyPaths>
<!-- Get assembly -->
<GetAssemblyIdentity AssemblyFiles="$(OutDir)$(TargetName).dll">
<Output TaskParameter="Assemblies" ItemName="AssemblyInfo" />
</GetAssemblyIdentity>
<!-- Generate customization dll -->
<GenerateResource SdkToolsPath="$(TargetFrameworkSDKToolsDirectory)" UseSourcePath="true" Sources="$(ProjectDir)ZeroTouchNodeIconsImages.resx" OutputResources="$(ProjectDir)ZeroTouchNodeIconsImages.resources" References="$(FrameworkAssembliesPath)System.Drawing.dll" />
<AL SdkToolsPath="$(TargetFrameworkSDKToolsDirectory)" TargetType="library" EmbedResources="$(ProjectDir)ZeroTouchNodeIconsImages.resources" OutputAssembly="$(OutDir)ZeroTouchNodeIcons.customization.dll" Version="%(AssemblyInfo.Version)" />
</Target>DeleteRevitUINodes.dllprivate static readonly List<string> ProductsWithASM = new List<string>()
{ "Revit", "Civil", "Robot Structural Analysis", "FormIt" }; internal static Version PreloadAsmFromRevit()
{
var asmLocation = AppDomain.CurrentDomain.BaseDirectory;
Version libGVersion = findRevitASMVersion(asmLocation);
var dynCorePath = DynamoRevitApp.DynamoCorePath;
var preloaderLocation = DynamoShapeManager.Utilities.GetLibGPreloaderLocation(libGVersion, dynCorePath);
Version preLoadLibGVersion = PreloadLibGVersion(preloaderLocation);
DynamoShapeManager.Utilities.PreloadAsmFromPath(preloaderLocation, asmLocation);
return preLoadLibGVersion;
} <PreferenceSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<IsFirstRun>false</IsFirstRun>
<IsUsageReportingApproved>false</IsUsageReportingApproved>
<IsAnalyticsReportingApproved>false</IsAnalyticsReportingApproved>
<LibraryWidth>204</LibraryWidth>
<ConsoleHeight>0</ConsoleHeight>
<ShowPreviewBubbles>true</ShowPreviewBubbles>
<ShowConnector>true</ShowConnector>
<ConnectorType>BEZIER</ConnectorType>
<BackgroundPreviews>
<BackgroundPreviewActiveState>
<Name>IsBackgroundPreviewActive</Name>
<IsActive>true</IsActive>
</BackgroundPreviewActiveState>
<BackgroundPreviewActiveState>
<Name>IsRevitBackgroundPreviewActive</Name>
<IsActive>true</IsActive>
</BackgroundPreviewActiveState>
</BackgroundPreviews>
<IsBackgroundGridVisible>true</IsBackgroundGridVisible>
<RenderPrecision>128</RenderPrecision>
<ShowEdges>false</ShowEdges>
<ShowDetailedLayout>true</ShowDetailedLayout>
<WindowX>553</WindowX>
<WindowY>199</WindowY>
<WindowW>800</WindowW>
<WindowH>676</WindowH>
<UseHardwareAcceleration>true</UseHardwareAcceleration>
<NumberFormat>f3</NumberFormat>
<MaxNumRecentFiles>10</MaxNumRecentFiles>
<RecentFiles>
<string></string>
</RecentFiles>
<BackupFiles>
<string>..AppData\Roaming\Dynamo\Dynamo Revit\backup\backup.DYN</string>
</BackupFiles>
<CustomPackageFolders>
<string>..AppData\Roaming\Dynamo\Dynamo Revit\2.5</string>
</CustomPackageFolders>
<PackageDirectoriesToUninstall />
<PythonTemplateFilePath />
<BackupInterval>60000</BackupInterval>
<BackupFilesCount>1</BackupFilesCount>
<PackageDownloadTouAccepted>true</PackageDownloadTouAccepted>
<OpenFileInManualExecutionMode>false</OpenFileInManualExecutionMode>
<NamespacesToExcludeFromLibrary>
<string>ProtoGeometry.dll:Autodesk.DesignScript.Geometry.TSpline</string>
</NamespacesToExcludeFromLibrary>
</PreferenceSettings>
viewModel = DynamoViewModel.Start(
new DynamoViewModel.StartConfiguration()
{
CommandFilePath = commandFilePath,
DynamoModel = model,
Watch3DViewModel =
HelixWatch3DViewModel.TryCreateHelixWatch3DViewModel(
null,
new Watch3DViewModelStartupParams(model),
model.Logger),
ShowLogin = true
});
var view = new DynamoView(viewModel);
"Bindings": [
{
"NodeId": "1e83cc25-7de6-4a7c-a702-600b79aa194d",
"Binding": {
"WrapperObject_InClassDecl-1_InFunctionScope-1_Instance0_1e83cc25-7de6-4a7c-a702-600b79aa194d": "Base64 Encoded Data"
}
},
{
"NodeId": "c69c7bec-d54b-4ead-aea8-a3f45bea9ab2",
"Binding": {
"WrapperObject_InClassDecl-1_InFunctionScope-1_Instance0_c69c7bec-d54b-4ead-aea8-a3f45bea9ab2": "Base64 Encoded Data"
}
}
],
public static string GetTraceData(string key)
///Returns the data that is bound to a particular key
public static void SetTraceData(string key, string value)
///Set the data bound to a particular key public IDictionary<Guid, List<CallSite.RawTraceData>>
GetTraceDataForNodes(IEnumerable<Guid> nodeGuids, Executable executable) /*
* After a graph update, Dynamo typically disposes of all
* objects created during the graph update. But what if there are
* objects which are expensive to re-create, or which have other
* associations in a host application? You wouldn't want those those objects
* re-created on every graph update. For example, you might
* have an external database whose records contain data which needs
* to be re-applied to an object when it is created in Dynamo.
* In this example, we use a wrapper class, TraceExampleWrapper, to create
* TraceExampleItem objects which are stored in a static dictionary
* (they could be stored in a database as well). On subsequent graph updates,
* the objects will be retrieved from the data store using a trace id stored
* in the trace cache.
*/ [IsVisibleInDynamoLibrary(false)]
public class TraceableId
{
} private void InitWall(Curve curve, Autodesk.Revit.DB.WallType wallType, Autodesk.Revit.DB.Level baseLevel, double height, double offset, bool flip, bool isStructural)
{
// This creates a new wall and deletes the old one
TransactionManager.Instance.EnsureInTransaction(Document);
//Phase 1 - Check to see if the object exists and should be rebound
var wallElem =
ElementBinder.GetElementFromTrace<Autodesk.Revit.DB.Wall>(Document);
bool successfullyUsedExistingWall = false;
//There was a modelcurve, try and set sketch plane
// if you can't, rebuild
if (wallElem != null && wallElem.Location is Autodesk.Revit.DB.LocationCurve)
{
var wallLocation = wallElem.Location as Autodesk.Revit.DB.LocationCurve;
<SNIP>
if(!CurveUtils.CurvesAreSimilar(wallLocation.Curve, curve))
wallLocation.Curve = curve;
<SNIP>
}
var wall = successfullyUsedExistingWall ? wallElem :
Autodesk.Revit.DB.Wall.Create(Document, curve, wallType.Id, baseLevel.Id, height, offset, flip, isStructural);
InternalSetWall(wall);
TransactionManager.Instance.TransactionTaskDone();
// delete the element stored in trace and add this new one
ElementBinder.CleanupAndSetElementForTrace(Document, InternalWall);
} if(!CurveUtils.CurvesAreSimilar(wallLocation.Curve, curve))
wallLocation.Curve = curve; var wall = successfullyUsedExistingWall ? wallElem :
Autodesk.Revit.DB.Wall.Create(Document, curve, wallType.Id, baseLevel.Id, height, offset, flip, isStructural);
ElementBinder.CleanupAndSetElementForTrace(Document, InternalWall);{
"sections": [
{
"text": "default",
"iconUrl": "",
"elementType": "section",
"showHeader": false,
"include": [ ],
"childElements": [
{
"text": "Revit",
"iconUrl": "",
"elementType": "category",
"include": [],
"childElements": [
{
"text": "some sub group name",
"iconUrl": "",
"elementType": "group",
"include": [
{
"path": "bltinpkg://namespace.namespace",
"inclusive": false
}
],
"childElements": []
}
]
}
]
}
]
}using System;
using System.Collections.Generic;
using Dynamo.Graph.Nodes;
using CustomNodeModel.CustomNodeModelFunction;
using ProtoCore.AST.AssociativeAST;
using Autodesk.DesignScript.Geometry;
namespace CustomNodeModel.CustomNodeModel
{
[NodeName("RectangularGrid")]
[NodeDescription("An example NodeModel node that creates a rectangular grid. The slider randomly scales the cells.")]
[NodeCategory("CustomNodeModel")]
[InPortNames("xCount", "yCount")]
[InPortTypes("double", "double")]
[InPortDescriptions("Number of cells in the X direction", "Number of cells in the Y direction")]
[OutPortNames("Rectangles")]
[OutPortTypes("Autodesk.DesignScript.Geometry.Rectangle[]")]
[OutPortDescriptions("A list of rectangles")]
[IsDesignScriptCompatible]
public class GridNodeModel : NodeModel
{
private double _sliderValue;
public double SliderValue
{
get { return _sliderValue; }
set
{
_sliderValue = value;
RaisePropertyChanged("SliderValue");
OnNodeModified(false);
}
}
public GridNodeModel()
{
RegisterAllPorts();
}
public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
{
if (!HasConnectedInput(0) || !HasConnectedInput(1))
{
return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), AstFactory.BuildNullNode()) };
}
var sliderValue = AstFactory.BuildDoubleNode(SliderValue);
var functionCall =
AstFactory.BuildFunctionCall(
new Func<int, int, double, List<Rectangle>>(GridFunction.RectangularGrid),
new List<AssociativeNode> { inputAstNodes[0], inputAstNodes[1], sliderValue });
return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), functionCall) };
}
}
}using Autodesk.DesignScript.Geometry;
using Autodesk.DesignScript.Runtime;
using System;
using System.Collections.Generic;
namespace CustomNodeModel.CustomNodeModelFunction
{
[IsVisibleInDynamoLibrary(false)]
public class GridFunction
{
[IsVisibleInDynamoLibrary(false)]
public static List<Rectangle> RectangularGrid(int xCount = 10, int yCount = 10, double rand = 1)
{
double x = 0;
double y = 0;
Point pt = null;
Vector vec = null;
Plane bP = null;
Random rnd = new Random(2);
var pList = new List<Rectangle>();
for (int i = 0; i < xCount; i++)
{
y++;
x = 0;
for (int j = 0; j < yCount; j++)
{
double rNum = rnd.NextDouble();
double scale = rNum * (1 - rand) + rand;
x++;
pt = Point.ByCoordinates(x, y);
vec = Vector.ZAxis();
bP = Plane.ByOriginNormal(pt, vec);
Rectangle rect = Rectangle.ByWidthLength(bP, scale, scale);
pList.Add(rect);
}
}
pt.Dispose();
vec.Dispose();
bP.Dispose();
return pList;
}
}
}using Dynamo.Controls;
using Dynamo.Wpf;
namespace CustomNodeModel.CustomNodeModel
{
public class CustomNodeModelView : INodeViewCustomization<GridNodeModel>
{
public void CustomizeView(GridNodeModel model, NodeView nodeView)
{
var slider = new Slider();
nodeView.inputGrid.Children.Add(slider);
slider.DataContext = model;
}
public void Dispose()
{
}
}
}<UserControl x:Class="CustomNodeModel.CustomNodeModel.Slider"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:CustomNodeModel.CustomNodeModel"
mc:Ignorable="d"
d:DesignHeight="75" d:DesignWidth="100">
<Grid Margin="10">
<Slider Grid.Row="0" Width="80" Minimum="0" Maximum="1" IsSnapToTickEnabled="True" TickFrequency="0.01" Value="{Binding SliderValue}"/>
</Grid>
</UserControl>using System.Windows.Controls;
namespace CustomNodeModel.CustomNodeModel
{
/// <summary>
/// Interaction logic for Slider.xaml
/// </summary>
public partial class Slider : UserControl
{
public Slider()
{
InitializeComponent();
}
}
}{
"license": "MIT",
"file_hash": null,
"name": "CustomNodeModel",
"version": "1.0.0",
"description": "Sample node",
"group": "CustomNodes",
"keywords": [ "grid", "random" ],
"dependencies": [],
"contents": "Sample node",
"engine_version": "1.3.0",
"engine": "dynamo",
"engine_metadata": "",
"site_url": "",
"repository_url": "",
"contains_binaries": true,
"node_libraries": [
"CustomNodeModel, Version=1.0.0, Culture=neutral, PublicKeyToken=null",
"CustomNodeModelFunction, Version=1.0.0, Culture=neutral, PublicKeyToken=null"
]
}


