### Using Replication Guides for List Pairing (Dominant List 1)
Source: https://dynamobim.org/cbns-for-dummies
Applies replication guides to pair elements from two lists of different lengths, resulting in a nested list structure. This example prioritizes the first list's length.
```Python
xCoords = {1, 2};
yCoords = {10, 20, 30, 40, 50};
// Result: {{<10>, <100>}, {<20>, <200>}, {<30>, <300>}, {<40>, <400>}, {<50>, <500>}}
```
--------------------------------
### Basic Cloud Rendering Setup in Dynamo
Source: https://dynamobim.org/pt-3-cloud-rendering-with-dynamo
This graph demonstrates the simplest setup for uploading a render job and viewing the resulting image. Ensure you are in the Revit project environment.
```Dynamo
// Specify the view name to render
viewName = "{3D}";
// Export render data
renderData = ExportRenderData.ByViewName(viewName);
// Set rendering dimensions (must be > 110 pixels)
width = 1000;
height = 800;
// Specify render type and quality
renderType = "Photorealistic";
renderQuality = "High";
// Create a cloud rendering job
renderJob = CloudRendering.Job(renderData, width, height, renderType, renderQuality);
// Initiate the cloud render and wait for completion
renderedImages = Cloud.Render(renderJob);
// Get the file path of the first rendered image
imagePath = List.FirstItem(renderedImages);
// Read the image into Dynamo for display
image = Image.ReadFromFile(imagePath);
```
--------------------------------
### Example WAV Filenames for Piano Notes
Source: https://dynamobim.org/feed
These are example filenames for .wav files, each representing a single piano note. Consistent naming is crucial for the script to function correctly.
```plaintext
C.wav
D.wav
E.wav
FS.wav
C_high.wav
D_high.wav
```
--------------------------------
### Example Filenames for Sound Files
Source: https://dynamobim.org/%F0%9F%8E%B9-auld-lang-syne-player-dynamo-forum-2025-winner
These are example filenames for the .wav sound files that correspond to individual piano notes. Each file must contain a single note and follow a consistent naming convention for the Python script to locate and play them.
```text
C.wav
D.wav
E.wav
FS.wav
C_high.wav
D_high.wav
```
--------------------------------
### Solid Volume Example
Source: https://dynamobim.org/wp-content/uploads/forum-assets/collin-mccrone/08/13/COVID-occupancy-by-instance.dyn
Calculates the volume of a solid. Requires a solid object as input.
```Python
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Example input
# Assume 'solid' is a valid solid object, e.g., a Cube or Extrusion
# For demonstration, create a sample cube
solid = Solid.ByExtrusion(Rectangle.ByWidthLength(10, 10), Vector.ZAxis().Scale(10))
# Calculate volume
volume = Solid.Volume(solid)
# Output
output = volume
```
--------------------------------
### Get All Elements of Category Example
Source: https://dynamobim.org/wp-content/uploads/forum-assets/collin-mccrone/08/13/COVID-occupancy-by-instance.dyn
Retrieves all elements belonging to a specified category. Useful for filtering and analysis.
```Python
import clr
# Assume 'category' is a valid Category object
# For demonstration, assume a category named 'Walls' exists
# In a real scenario, you would get the category using Document.Categories()
# Placeholder for category object
# category = IN[0] # Assuming category is an input
# Example of how to get elements if you have the category object
# elements = Category.Elements(category)
# For this example, we'll simulate a list of elements
class MockElement:
def __init__(self, name):
self.name = name
class MockCategory:
def __init__(self, name):
self.name = name
def Elements(self):
# Simulate returning elements of this category
return [MockElement('Wall1'), MockElement('Wall2')]
category = MockCategory('Walls')
elements = category.Elements()
# Output
output = elements
```
--------------------------------
### Get Origin Point
Source: https://dynamobim.org/wp-content/uploads/forum-assets/admin/07/16/Basket1.dyn
Returns the origin point (0,0,0) in space. This node is often used as a reference or starting point.
```Dynamo
```
```Dynamo
```
--------------------------------
### Dynamo Connector Configurations
Source: https://dynamobim.org/wp-content/uploads/forum-assets/colin-mccroneautodesk-com/03/13/Buffons-Needle.dyn
Examples of connector configurations in Dynamo, specifying the start and end nodes, indices, and port types for data flow between nodes.
```Dynamo XML
```
```Dynamo XML
```
```Dynamo XML
```
```Dynamo XML
```
```Dynamo XML
```
```Dynamo XML
```
```Dynamo XML
```
```Dynamo XML
```
```Dynamo XML
```
```Dynamo XML
```
```Dynamo XML
```
--------------------------------
### WPF Window with MVVM in PythonNet3
Source: https://dynamobim.org/pythonnet3-a-new-dynamo-python-to-fix-everything
Example demonstrating how to create a custom WPF window using an MVVM pattern in PythonNet3. It includes setting up a ViewModel, defining a XAML window, and handling button clicks.
```Python
import clr
import System
clr.AddReference("System.Xml")
clr.AddReference("PresentationFramework")
clr.AddReference("PresentationCore")
clr.AddReference("System.Windows")
clr.AddReference("DynamoCore")
from System.Windows import LogicalTreeHelper
from Dynamo.Core import NotificationObject
class ViewModel:
def __new__(cls, *args):
cls.args = args
# !! Modify namespace when modifying _ViewModel !!
cls.__namespace__ = "ViewModel_zlcg"
try:
return __import__(cls.__namespace__)._ViewModel(*cls.args)
except ImportError:
class _ViewModel(NotificationObject):
__namespace__ = cls.__namespace__
def __init__(self):
super().__init__()
_text = "Hieee"
def get_Text(self):
return self._text
def set_Text(self, value):
self._text = value
self.RaisePropertyChanged("Text")
Text = clr.clrproperty(str, get_Text, set_Text)
return _ViewModel(*cls.args)
class MyWindow(System.Windows.Window):
xaml = '''
'''
def __new__(cls):
reader = System.Xml.XmlReader.Create(System.IO.StringReader(cls.xaml))
window = System.Windows.Markup.XamlReader.Load(reader)
window.__class__ = cls
return window
def __init__(self):
super().__init__()
self.DataContext = ViewModel()
LogicalTreeHelper.FindLogicalNode(self, "Button").Click += self.buttonClick
def buttonClick(self, sender, e):
self.DataContext.Text = self.DataContext.Text[::-1]
def showWindow():
try:
window = MyWindow()
window.Title = "Test"
window.ShowDialog()
except Exception as ex:
print(ex)
System.Windows.Application.Current.Dispatcher.Invoke(System.Action(showWindow))
```
--------------------------------
### Custom Preview for a Star Node
Source: https://dynamobim.org/adding-protection-to-motorcycles-with-dynamo
This example illustrates how to implement custom previews for nodes, allowing users to visualize low-poly representations before generating detailed geometry. This improves user experience by providing immediate visual feedback.
```csharp
using Autodesk.DesignScript.Geometry;
using Autodesk.DesignScript.Runtime;
namespace MyNodes {
public static class PatternNodes {
[NodeName("Star")]
[NodeCategory("MyNodes.Patterns")]
[NodeDescription("Creates a Star pattern element.")]
public static Curve CreateStar(Point center, double radius, double rotation = 0) {
// Custom preview logic would go here
// For simplicity, returning a basic star shape
return Star.ByCenterRadiusRotation(center, radius, rotation);
}
}
}
```
--------------------------------
### Get Vertex Indices by Triangle
Source: https://dynamobim.org/meshtoolkit-1-2-0-release-2
This example demonstrates how to retrieve the vertex indices for each triangle in a mesh. This is useful for matching unique vertices to their corresponding triangle positions.
```Python
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('MeshToolkit')
import MeshToolkit
mesh = IN[0]
# Get the vertex indices for each triangle
vertex_indices_per_triangle = MeshToolkit.Mesh.VertexIndicesByTriangle(mesh)
# Example verification: Multiply number of triangles by 3 and compare with total vertex indices count
num_triangles = len(mesh.Triangles)
num_vertex_indices = len(vertex_indices_per_triangle)
# This check assumes vertex_indices_per_triangle is a flat list of all indices
# If it's a list of lists, the count would be different.
# Assuming it's a list of lists, where each inner list has 3 indices:
if num_triangles > 0 and len(vertex_indices_per_triangle[0]) == 3:
total_indices_expected = num_triangles * 3
actual_indices_count = sum(len(indices) for indices in vertex_indices_per_triangle)
if total_indices_expected == actual_indices_count:
print("Verification successful: Number of indices matches triangles * 3.")
else:
print("Verification failed: Mismatch in index count.")
OUT = vertex_indices_per_triangle
```
--------------------------------
### Number Range Syntax
Source: https://dynamobim.org/dynamo-sequences-and-ranges
Use 'Start..End' to create a sequence of integers. For example, '0..4' generates 0, 1, 2, 3, 4.
```Dynamo
0..4
```
--------------------------------
### Python Script for Geometry Operations
Source: https://dynamobim.org/wp-content/uploads/forum-assets/colin-mccroneautodesk-com/06/23/MathTransit.dyn
A basic Python script setup within Dynamo, including necessary imports for geometry manipulation. This serves as a starting point for custom scripting.
```Python
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import math
```
--------------------------------
### Dynamo Webcam Node (C#)
Source: https://dynamobim.org/london-hackathon-hackstreet-boys
This C# code demonstrates how to create a WPF window with a live webcam feed, a foundational step for the Mesh.ByFace node.
```csharp
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using AForge.Video;
using AForge.Video.DirectShow;
namespace DynamoWebcamNode
{
public partial class MainWindow : Window
{
private FilterInfoCollection videoDevices;
private VideoCaptureDevice finalVideo;
public MainWindow()
{
InitializeComponent();
videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
if (videoDevices.Count == 0)
{
MessageBox.Show("No video devices found.");
return;
}
finalVideo = new VideoCaptureDevice(videoDevices[0].MonikerString);
finalVideo.VideoResolution = finalVideo.AvailableResolutions[0];
// Start video streaming
var videoSourcePlayer = new System.Windows.Controls.Image();
videoSourcePlayer.Source = new BitmapImage();
InitializeVideoSource(videoSourcePlayer);
}
private void InitializeVideoSource(System.Windows.Controls.Image videoSourcePlayer)
{
if (finalVideo != null && finalVideo.IsRunning)
{
finalVideo.SignalToStop();
finalVideo.WaitForStop();
}
finalVideo = new VideoCaptureDevice(videoDevices[0].MonikerString);
finalVideo.NewFrame += new NewFrameEventHandler(Device_NewFrame);
finalVideo.Start();
}
private void Device_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
try
{
var bitmap = (System.Drawing.Bitmap)eventArgs.Frame.Clone();
Dispatcher.Invoke(() =>
{
// Update UI with the new frame
// This part would typically involve updating a WPF Image control
// For simplicity, we'll just acknowledge the frame here.
// Example: videoSourcePlayer.Source = BitmapToBitmapImage(bitmap);
});
}
catch (Exception ex)
{
// Handle exceptions
}
}
// Helper to convert System.Drawing.Bitmap to BitmapImage if needed for WPF
// private BitmapImage BitmapToBitmapImage(System.Drawing.Bitmap bitmap)
// {
// using (var memoryStream = new System.IO.MemoryStream())
// {
// bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);
// memoryStream.Position = 0;
// var bitmapImage = new BitmapImage();
// bitmapImage.BeginInit();
// bitmapImage.StreamSource = memoryStream;
// bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
// bitmapImage.EndInit();
// return bitmapImage;
// }
// }
protected override void OnClosed(EventArgs e)
{
if (finalVideo != null && finalVideo.IsRunning)
{
finalVideo.SignalToStop();
}
base.OnClosed(e);
}
}
}
```
--------------------------------
### Build Dynamo from Source
Source: https://dynamobim.org/dynamo-free-like-beer-free-like-speech
You can build Dynamo yourself by accessing its source code. This allows for exploration, contribution, and bug reporting.
```text
fire up your free SharpDevelop or other development environment and go build the code yourself RIGHT NOW. Explore the latest submissions, make your own, report bugs, all that good stuff.
```
--------------------------------
### Number Range with Interval Syntax
Source: https://dynamobim.org/dynamo-sequences-and-ranges
Use 'Start..End..Interval' to create a sequence with a specified step. For example, '0..4..2' generates 0, 2, 4.
```Dynamo
0..4..2
```
--------------------------------
### Number Range with Count Syntax
Source: https://dynamobim.org/dynamo-sequences-and-ranges
Use 'Start..End..#Count' to create a sequence with a specific number of items. For example, '0..1..#5' generates 0, 0.25, 0.5, 0.75, 1.
```Dynamo
0..1..#5
```
--------------------------------
### Create Site by Name
Source: https://dynamobim.org/dynamo-for-civil-3d-2025-1-release
Creates a new site in the Civil 3D project by specifying its name. Ensure the site name does not already exist.
```Python
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('DynamoRevit')
import Dynamo
from Autodesk.DesignScript.Geometry import *
clr.AddReference('Autodesk.Civil.BC')
clr.AddReference('Autodesk.Civil.DB')
clr.AddReference('Autodesk.Civil.Dynamo.Components')
import Autodesk
from Autodesk.Civil.DB import *
from Autodesk.Civil.Dynamo.Components import *
doc = DocumentManager.Instance.CurrentDBDocument
# Get input site name
site_name = IN[0]
# Create the site
try:
TransactionManager.Instance.EnsureInTransaction(doc)
site = Site.ByName(site_name)
TransactionManager.Instance.TransactionTaskDone()
OUT = site
except Exception as e:
OUT = "Error: {}".format(e)
```
--------------------------------
### WPF UI with MVVM Pattern in Dynamo
Source: https://dynamobim.org/feed
Example of setting up a ViewModel for a WPF UI in Dynamo using IronPython. This demonstrates how to bind data and handle property changes for UI elements.
```Python
import clr
import sys
import System
from System.Collections.ObjectModel import ObservableCollection
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
#Get Important vars
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
sdkNumber = int(app.VersionNumber)
clr.AddReference('System.Data')
from System.Data import *
clr.AddReference("System.Xml")
clr.AddReference("PresentationFramework")
clr.AddReference("System.Xml")
clr.AddReference("PresentationCore")
clr.AddReference("System.Windows")
import System.Windows.Controls
from System.Windows.Controls import *
from System.IO import StringReader
from System.Xml import XmlReader
from System.Windows import LogicalTreeHelper
from System.Windows.Markup import XamlReader, XamlWriter
from System.Windows import Window, Application
from System.ComponentModel import INotifyPropertyChanged, PropertyChangedEventArgs
import time
import traceback
import itertools
class ViewModel(INotifyPropertyChanged): # INotifyPropertyChanged
__namespace__ = "ViewModel_jhggsbUbwQpY" # rename it each edition class
def __init__(self, elem_type, lst_Workset):
super().__init__()
self._elem_type = elem_type
self._SelectValue = lst_Workset[0] # set default workset
self._lst_Workset = ObservableCollection[DB.Workset](lst_Workset)
#
self._property_changed_handlers = []
self.PropertyChanged = None
@clr.clrproperty(DB.Element)
def ElementType(self):
return self._elem_type
@clr.clrproperty(System.String)
def Name(self):
return self._elem_type.get_Name()
@clr.clrproperty(System.String)
def FamilyName(self):
return self._elem_type.FamilyName
def get_SelectValue(self):
return self._SelectValue
def set_SelectValue(self, value):
if self._SelectValue != value:
self._SelectValue = value
self.OnPropertyChanged("SelectValue")
# Add SelectValue as a clr property
SelectValue = clr.clrproperty(DB.Workset, get_SelectValue, set_SelectValue)
@clr.clrproperty(ObservableCollection[DB.Workset])
def LstWorkset(self):
return self._lst_Workset
def OnPropertyChanged(self, property_name):
event_args = PropertyChangedEventArgs(property_name)
for handler in self._property_changed_handlers:
handler(self, event_args)
# Implementation of add/remove_PropertyChanged
def add_PropertyChanged(self, handler):
if handler not in self._property_changed_handlers:
self._property_changed_handlers.append(handler)
def remove_PropertyChanged(self, handler):
```
--------------------------------
### AI Prompt for Schematic HVAC Narrative Generation
Source: https://dynamobim.org/turning-energy-models-into-design-narratives-with-agentic-nodes-in-dynamo
This prompt guides an AI agent to generate a schematic HVAC narrative based on provided project data and an example narrative. It specifies the AI's role and the desired output format.
```Prompt
Here is an Example of a Schematic Narrative for HVAC:
The proposed HVAC system is designed to support a building with a total conditioned floor area of approximately ft². Based on load calculations, the facility requires a peak heating capacity of 850 MBH, a peak cooling load of 120 Tons, and a peak sensible cooling load of 95 tons. Based on the site the suggestion is to use a Packaged Rooftop unit with VAVs with electrical Reheat.
Here is the data of my project: We gave the “Stringyfied” data that we had previously extracted.
Please Write a narrative like the example based on the given using the data provided.
```
--------------------------------
### Number Range with List Length and Interval Syntax
Source: https://dynamobim.org/dynamo-sequences-and-ranges
Use 'Start..#List Length..Interval' to define a range based on a list length and interval. For example, '0..#4..10' generates 0, 10, 20, 30.
```Dynamo
0..#4..10
```
--------------------------------
### PolyCurve.ByThickeningCurveNormal Geometry Node Example
Source: https://dynamobim.org/dynamo-core-2-9-release
Example usage of the new PolyCurve.ByThickeningCurveNormal geometry node introduced in Dynamo 2.9.
```text
11. PolyCurve.ByThickeningCurveNormal example
```
--------------------------------
### Add WPF API and Windows API Support
Source: https://dynamobim.org/dynamo-on-net-8
Configure your project to include Windows API access by setting `net8-windows` and enable WPF API access with `true`.
```xml
net8-windowstrue
```
--------------------------------
### Using DateTime.Now for Note Sequencing
Source: https://dynamobim.org/feed
This example uses `DateTime.Now` to step through an ordered list of musical notes. This approach is suitable for time-based sequencing of events in a program.
```csharp
DateTime.Now
```
--------------------------------
### Solid.ByRuledLoft Geometry Node Example
Source: https://dynamobim.org/dynamo-core-2-9-release
Example usage of the new Solid.ByRuledLoft geometry node introduced in Dynamo 2.9.
```text
10. Solid.ByRuledLoft example
```
--------------------------------
### Implement .NET Interface with Out/Ref Parameters
Source: https://dynamobim.org/pythonnet3-a-new-dynamo-python-to-fix-everything
Example of implementing the Revit API's IFamilyLoadOptions interface, demonstrating how to handle methods with 'out' or 'ref' parameters in Python.NET 3 by returning tuples.
```python
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
class MyFamilyLoadOptions(IFamilyLoadOptions):
__namespace__ = "ns"
def __init__(self):
super().__init__()
def OnFamilyFound(self, familyInUse, _overwriteParameterValues):
overwriteParameterValues = True
return (True, overwriteParameterValues)
def OnSharedFamilyFound(self, sharedFamily, familyInUse, source, _overwriteParameterValues):
overwriteParameterValues = True
return (True, overwriteParameterValues)
doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)
opts = MyFamilyLoadOptions()
loadFamily = doc.LoadFamily(IN[0], opts, None)
TransactionManager.Instance.TransactionTaskDone()
```
--------------------------------
### Solid.Separate Geometry Node Example
Source: https://dynamobim.org/dynamo-core-2-9-release
Example usage of the new Solid.Separate geometry node introduced in Dynamo 2.9.
```text
9. Solid.Separate example
```
--------------------------------
### Instance Method vs. Static Method in DesignScript
Source: https://dynamobim.org/dynamo-0-9-1-release
Illustrates the syntactic flexibility in DesignScript, allowing instance methods to be written as static methods. This change makes the syntax more forgiving for users.
```DesignScript
Instance method: | **_myCurve_**.**PointAtParameter**(0.5)
```
```DesignScript
Static method: | **Curve. PointAtParameter**(**_myCurve_** , 0.5)
```