# Totally useless scripts in Dynamo

**URL:** <https://forum.dynamobim.com/t/totally-useless-scripts-in-dynamo/107714>\
**Category:** Revit\
**Created:** [February 3, 2025, 5:47pm UTC](https://forum.dynamobim.com/t/totally-useless-scripts-in-dynamo/107714 "2025-02-03T17:47:23Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [February 3, 2025, 5:47pm UTC](https://forum.dynamobim.com/t/totally-useless-scripts-in-dynamo/107714/1 "2025-02-03T17:47:24Z")

</div>

After the discussion last night about loops (which I must admit may have involved wine)… I thought it’d be fun to create a script that did one thing… then did the next thing… and so on…

I can’t seem to get it to flow right on periodic… So I’ve put it in player and hit run, run, run…

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/e/4ed554286b67c2bd89117f8d15894072d9777eeb.png)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/f/1f5cf777aeb318a381c4fbd6b9d3e15d1d5f82f9.png)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/5/05069502ff1ccd8d1da3146ecfb9819b4fcee334.png)

So it runs through the entire list… Then when the list is finished …  
you get this:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/b/9bac95630c642e26a432b2e11454e58a1cea2b9f.png)

It’ll work with any length of list…

If anyone fancies trying to make it work on periodic I’d like to see how you actually did it.

[periodic.dyn](https://forum.dynamobim.com/uploads/short-url/iIbXrGCeCUZwo5kAcuS88xzXH2l.dyn) (7.4 KB)

_ **WARNING** _ This alters the project parameter, “Author” … so don’t go running it in a live Revit project. 😄

You’ll need IronPython for it to work… Unless the Py3 stuff has been fixed?

---

<div class="post-metadata">

**Author:** ![Marcel\_Rijsmus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marcel_rijsmus/32/8539_2.png) [@Marcel\_Rijsmus](https://forum.dynamobim.com/u/Marcel_Rijsmus)\
**Post date:** [February 3, 2025, 7:41pm UTC](https://forum.dynamobim.com/t/totally-useless-scripts-in-dynamo/107714/2 "2025-02-03T19:41:28Z")

</div>

I think there is a misunderstanding here  
Periodic in Dynamo terms is what you get if you use a DateTimeNow node

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/e/4ea2a3964d6a666d5fc95df7a036dab08634a743.jpeg)

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [February 3, 2025, 7:43pm UTC](https://forum.dynamobim.com/t/totally-useless-scripts-in-dynamo/107714/3 "2025-02-03T19:43:27Z")

</div>

Yes… but I couldn’t get it to work even using that…

Try and see. 🙂

---

<div class="post-metadata">

**Author:** ![Marcel\_Rijsmus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marcel_rijsmus/32/8539_2.png) [@Marcel\_Rijsmus](https://forum.dynamobim.com/u/Marcel_Rijsmus)\
**Post date:** [February 3, 2025, 7:50pm UTC](https://forum.dynamobim.com/t/totally-useless-scripts-in-dynamo/107714/4 "2025-02-03T19:50:56Z")

</div>

Why use mouse clicks anyway? DateTimeNow can get things moving

> **[More Families in Motion: New and Exciting Methods That Make Your Revit...](https://www.autodesk.com/autodesk-university/class/More-Families-Motion-New-and-Exciting-Methods-Make-Your-Revit-Families-Move-2016?linkId=72151666#video)**
>
> This class will show you how to create parameters within the Revit software massing, adaptive component, and traditional Family Editors so your families can move. Forget what you've learned about how to apply rotation and dimensional parameters to...

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [February 3, 2025, 8:25pm UTC](https://forum.dynamobim.com/t/totally-useless-scripts-in-dynamo/107714/5 "2025-02-03T20:25:17Z")

</div>

Yes… See if you can make that script I posted work.

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [February 3, 2025, 8:34pm UTC](https://forum.dynamobim.com/t/totally-useless-scripts-in-dynamo/107714/6 "2025-02-03T20:34:29Z")

</div>

The biggest misconception about the Periodic Run type is that it just runs continuously and automatically, when it doesn’t. It executes at the specific interval but still follows all the same runtime rules for code execution. It won’t just ignore all issues and then execute when it can.

If you want your code to run in Periodic, then you have to take into account when your code is running and when it isn’t. For example, if you set the graph to execute every second, then you would have to ensure that your code was able to execute and complete in less than a second. If you have any user interactions in your code, then your code is going to pause for some amount of time. You have to be sure that the pause will not interrupt the periodic execution of the code. I don’t think any of that is an issue with your specific code, but it’s always worth considering.

Just plugging the `DateTime.Now` node into an unused port is enough to make the python dialog run after each interaction, but that may not be the experience you’re looking for. You’d at least want an end condition so that the dialog doesn’t repeat indefinitely.

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [February 3, 2025, 8:41pm UTC](https://forum.dynamobim.com/t/totally-useless-scripts-in-dynamo/107714/7 "2025-02-03T20:41:31Z")

</div>

I tried that but it seemed to work for 2-3 runs then stop.  
I tried the periodic into another python node that changed from A-F every 10 seconds but that also didn’t make the other node update enough times (even though it only needs to run through 7 iterations on the one pasted).

I’ve only ever used periodic for fun moving things before… I was actually surprised this didn’t work easily.

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [February 3, 2025, 8:43pm UTC](https://forum.dynamobim.com/t/totally-useless-scripts-in-dynamo/107714/8 "2025-02-03T20:43:22Z")

</div>

How exactly do you expect it to work?

This works for me with no other changes:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/2/92b5ed7e597e0b66f84bb04937a1776029d2c2df.png)

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [February 3, 2025, 8:46pm UTC](https://forum.dynamobim.com/t/totally-useless-scripts-in-dynamo/107714/9 "2025-02-03T20:46:55Z")

</div>

Oh… How strange. It went, 1, 2, 3 and stopped for me.

As I said, I also tried plugging the date time into another Python node too.

Is it possible to get it to work in Py3 yet?

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [February 3, 2025, 8:53pm UTC](https://forum.dynamobim.com/t/totally-useless-scripts-in-dynamo/107714/10 "2025-02-03T20:53:18Z")

</div>

The issue with WinForms? I don’t believe so. I don’t know of any issues with CP3 and Periodic though.

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [February 3, 2025, 8:55pm UTC](https://forum.dynamobim.com/t/totally-useless-scripts-in-dynamo/107714/11 "2025-02-03T20:55:07Z")

</div>

Yes, I mean the winforms.

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [February 3, 2025, 9:01pm UTC](https://forum.dynamobim.com/t/totally-useless-scripts-in-dynamo/107714/12 "2025-02-03T21:01:17Z")

</div>

I believe PythonNet3 does fix those issues (along with many others). You can download it and give it a try.

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [February 5, 2025, 9:36am UTC](https://forum.dynamobim.com/t/totally-useless-scripts-in-dynamo/107714/13 "2025-02-05T09:36:29Z")

</div>

Hi @Alien

this syntax work only on IronPython (define proprieties directly in constructor like C#)

`label = Label(Text=Title_text)`

here the fixed code for Cpython3 or PythonNet3

```auto
import clr
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Drawing")

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

import System
from System.Windows.Forms import *
from System.Drawing import *
from System.Net import *
from System.IO import MemoryStream
import os
from System.Diagnostics import Process
import math
from System.Runtime.InteropServices import Marshal
import random 

Top_strip_text = "Alien woz ere"

# **Get current document**
doc = DocumentManager.Instance.CurrentDBDocument
proj_info = doc.ProjectInformation
param_name = "Auteur"

# **Start a transaction to modify the document**
TransactionManager.Instance.EnsureInTransaction(doc)
param = proj_info.LookupParameter(param_name)

try:
    current_value = int(param.AsString())  
    new_value = current_value + 1  
except (ValueError, TypeError):
    new_value = 0  

# **Set the new value for next run**
param.Set(str(new_value)) 
TransactionManager.Instance.TransactionTaskDone()

stuffIN = list(IN[0])  

if new_value < len(stuffIN):
    Title_text = stuffIN[new_value] # Get the message at index
else:
    Title_text = "FINISHED" # End message if out of range

### **Create UI Window**
class CreateWindow(Form):
    def __init__ (self):
        super(). __init__ ()
        self.Name = "Create Window"
        self.Text = Top_strip_text
        self.Size = Size(380, 230) # Overall size
        self.CenterToScreen()
        
        label = Label()
        label.Text=Title_text
        label.Parent = self
        label.Location = Point(200, 20)
        label.AutoSize = False
        label.Height = 100
        label.Width = 150
        label.Font = System.Drawing.Font("Arial", 16, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0)
        label.ForeColor = Color.CornflowerBlue

        picBox = PictureBox()
        picBox.SizeMode = PictureBoxSizeMode.AutoSize
        picBox.Location = System.Drawing.Point(20, 20)        
        
        # Download the image from a URL
        imagePath = r"https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/144/40701_2.png"
        client = WebClient()
        data = client.DownloadData(imagePath)        
        memoryStream = MemoryStream(data)        
        image = Image.FromStream(memoryStream)
        picBox.Image = image        
        self.Controls.Add(picBox) 

        self.button = Button()
        self.button.Parent = self
        self.button.Text = "Yay!"
        self.button.Location = Point(230, 130)
        self.button.Width = 100
        self.button.Height = 30
        self.button.Click += self.ButtonClicked
        self.button.BackColor = Color.CornflowerBlue
        self.button.ForeColor = Color.White     
        self.button.Font = Font(label.Font.Name, 10)
        
        # **Make the form always on top**
        self.TopMost = True

    def ButtonClicked(self, sender, args):
        self.Close()

form = CreateWindow()
form.ShowDialog()

OUT = new_value

```
