How can I change the Sun's position (Date & Time) in Revit with Dynamo?

#1

Possible? I only find Query nodes with 0.7.5.

#2

Adding nodes to allow changing would be easy to add but at this point, it’s just query. What are you looking to achieve?

-matt

#3

Animate sun movement, of course:) Could be possible with Python and API?

#4

any luck?

i’m currently turning Dynamo script on automatic mode and moving sun manually in Revit, can it be done via Dynamo and/or Python / C#? i mean automatically moving sun

#5

Hi,

if you use solar study like this:
obraz

you can change the active frame via python:

import clr

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

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Transactions import TransactionManager
from RevitServices.Persistence import DocumentManager

#The inputs to this node will be stored as a list in the IN variables.
view = UnwrapElement(IN[0])
frame = IN[1]

doc = DocumentManager.Instance.CurrentDBDocument
sunSettings = view.SunAndShadowSettings

TransactionManager.Instance.EnsureInTransaction(doc)

sunSettings.ActiveFrame = frame

TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable.
OUT = 0

obraz

1 Like
#6


cool, thanks maciek.

the only problem is how to integrate into existing Dynamo, i used frame list so for each frame, modification of Revit element is desired to be seen, in short, very similar to Revit OOTB Preview Solar Study.

#7

hi,
I am not sure if I understood you correctly, but maybe you can delay the code after each frame iteration. Smth like that: https://www.pythoncentral.io/pythons-time-sleep-pause-wait-sleep-stop-your-code/

Don’t know though, how it will work in Dynamo.

#8

right, but it will only work if i convert all Dynamo nodes into Python code, hope i’m wrong

#9

I don’t know any other way…
Also it might be necessary to commit a transaction after each sun position shift to see the results…

I am not sure what you’re exactly after but maybe it would be easier to take image snapshots at each frame?

#10

thanks maciek, didn’t work even if i added transaction inside frame loop, there’s no way to “synchronize” w/ Dynamo nodes, as i said before, element modification needs to be done inside Python