View Orientation and Python Script refresh


#1

The Python script below is one I’m using to capture the view orientation of one 3D view and set the view orientation of a list of views to match the captured one. It works perfectly…the first time. On subsequent runs after the first view is changed, the list of views do not update themselves. This does not appear to have anything to do with the Unlock and Save/Lock, as removal of those lines does not improve the behavior at all.

At this point, my remedy is to disconnect one of the script inputs, run the dyn, reconnect, then run again. Then it treats it like a “first run” and the views update…once. Then it goes back to not working.

I am not a very good Python writer, so is there something I am missing that I need to do to clear some value from the memory or something? or is there some sort of view refresh that needs to happen in Revit?

ViewSettingCapture


Perspective eye and target coordinate extraction
#2

I am using Document.Views from Clockwork, and it appears that the views from that node do not refresh either. I renamed one of my views, clicked run again, and the view name did not change in the list. It appears this may be the issue. Is there any remedy for this? Shouldn’t the FilteredElementCollector be capturing the latest and greatest of everything?ViewListNoRefresh


#3

Apparently this is not an isolated thing. I just wrote a small script to get the current time, (datetime.datetime.now()) and noticed that too only runs once. The time appears frozen with whatever it was at the time of the first run (until i close and reopen the dyn).


#4

This seems to be a reoccurring issue: http://dynamobim.com/forums/topic/custom-node-behavior/

Temporary solution - create a custom node from your python script and add a “Not” node inside it. Connect a boolean to the “Not” input of the custom node and toggle it every time before running the workflow.


#5

what is needed is a node that can be included in the graph that forces dynamo to see the graph as dirty, there is a component of dynamo called live runner that attempts to only rerun parts of the graph that it detects have changed, it usually does this by looking at inputs, my understanding is that since the input to the python script has not changed it does not re execute the script.


#6

Hey Dimitar,

Have you figured out any solution/workaround to this? I usually add a Boolean Toggle to my nodes, but that forces me to toggle it on, run it, then toggle it off and run it before i put it back on and run yet again…its just stupid. Ideas?

 

Thanks!


#7

None so far. However I’m hoping that the new “run periodically” functionality can help. I imagine that a DateTime.Now or a Math.Random node that refreshes periodically every second, feeding fresh data into a function node and dirtying the graph, will negate the current problem.


#8

Hi Everyone! I am working with Konrad’s “Document.LinksAndImports” component to investigate and purge background DWGs that are popping up. I want to repeat the algorithm stepping through each redundant file until cleaned out. Basically I need the refresh function to update the stack of Import Instances each time I run the script. Dimitar mentioned using a “NOT” function in the python code… I’m just now really beginning to learn how to read/write python. Does anyone mind explaining how to incorporate that change so I can refresh the script? (below is a copy of the script)

 <span style="font-weight: bold;color: #f92672">import</span> clr
 clr.<span style="font-weight: bold;color: #ffffff">AddReference</span>(<span style="color: #e6db74">'RevitAPI'</span>)
 <span style="font-weight: bold;color: #f92672">from</span> Autodesk.Revit.DB <span style="font-weight: bold;color: #f92672">import</span> *
 <span style="font-weight: bold;color: #f92672">import</span> Autodesk
 
 clr.<span style="font-weight: bold;color: #ffffff">AddReference</span>(<span style="color: #e6db74">"RevitServices"</span>)
 <span style="font-weight: bold;color: #f92672">import</span> RevitServices
 <span style="font-weight: bold;color: #f92672">from</span> RevitServices.Persistence <span style="font-weight: bold;color: #f92672">import</span> DocumentManager
 
 doc = DocumentManager.Instance.CurrentDBDocument
 <span style="color: #75715e"># need to learn how to implement LINQ here...</span>
 collector = <span style="font-weight: bold;color: #ffffff">FilteredElementCollector</span>(doc)
 impinst = collector.<span style="font-weight: bold;color: #ffffff">OfClass</span>(ImportInstance).<span style="font-weight: bold;color: #ffffff">ToElements</span>()
 linkedlist = <span style="font-weight: bold;color: #ffffff">list</span>()
 importlist = <span style="font-weight: bold;color: #ffffff">list</span>()
 <span style="font-weight: bold;color: #f92672">for</span> item <span style="font-weight: bold;color: #f92672">in</span> impinst:
     <span style="font-weight: bold;color: #f92672">if</span> item.IsLinked:
         linkedlist.<span style="font-weight: bold;color: #ffffff">append</span>(item)
     <span style="font-weight: bold;color: #f92672">else</span>:
         importlist.<span style="font-weight: bold;color: #ffffff">append</span>(item)
 OUT = (linkedlist,importlist)

 


#9

Hi Tim,

All you really need to refresh your script, is an empty input that can be anything from a Boolean to a number slider. Have a look at the following example:


#10

Sorry I dropped off from the forum for awhile! Dimitar thanks so much for the helpful reply and tips. I will definitely revisit this as we have another project starting up of similar size and complexity as the one I was wrestling with at the time of this post. Cheers!