Donate Now Goal amount for this year: 3000 USD, Received: 1207 USD (40%)

Results 1 to 5 of 5
Like Tree8Likes
  • 2 Post By Kate
  • 3 Post By amoursol
  • 2 Post By amoursol
  • 1 Post By Kate

Thread: Dynamo - Disable Analytical Model

  1. #1
    Junior Member Kate's Avatar
    Join Date
    September 4, 2014
    Location
    Ann Arbor, MI
    Posts
    46
    Current Local Time
    06:54 AM

    Dynamo - Disable Analytical Model

    A while back Aaron mentioned creating a Dynamo script to kill analytical elements. We aren't using Revit to round trip to our structural models right now, so I thought I'd try my hand at making something similar.

    Below is the Dynamo graph I made to achieve this. I'm no Dynamo master, so if anyone has feedback or ideas for how to improve this I'd appreciate it!

    I'm particularly curious if there is a more efficient way to select elements to try and disable analytical model - in the graph below I've just made list of every category that I think is relevant.

    Attached Thumbnails Attached Thumbnails Dynamo - Disable Analytical Model-disable-analytical-model.png  
    johnp and JWR like this.

  2. #2
    Senior Member amoursol's Avatar
    Join Date
    November 21, 2012
    Location
    London, United Kingdom
    Posts
    612
    Current Local Time
    11:54 AM
    Hello Kate! Looking awesome. One thing I would consider doing is adding in a Filtered Element Collector at the start in lieu of the Categories nodes - this way it will pull everything inside of the document itself.

    Code:
    """
    FILTERED ELEMENT COLLECTOR - ANALYTICAL MODEL PARAMETER ELEMENTS ONLY
    """
    __author__ = 'Sol Amour - sol.amour@designtech.io'
    __twitter__ = '@solamour'
    __copyright__ = 'designtech.io 2018'
    __version__ = '1.0.0'
    
    
    # Importing Reference Modules
    import clr # CLR ( Common Language Runtime Module )
    clr.AddReference("RevitServices") # Adding the RevitServices.dll special Dynamo module to deal with Revit
    import RevitServices # Importing RevitServices
    from RevitServices.Persistence import DocumentManager # From RevitServices import the Document Manager
    clr.AddReference("RevitAPI") # Adding the RevitAPI.dll module to access the Revit API
    import Autodesk # Here we import the Autodesk namespace
    # From the Autodesk namespace - derived down to the Revit Database, we import only the Filtered Element Collector and BuiltInCategory classes
    from Autodesk.Revit.DB import *
    
    # Here we give the Revit Document a nickname of 'doc' which allows us to simply call 'doc' later without having to type the long namespace name 
    doc = DocumentManager.Instance.CurrentDBDocument
    
    # Here we use the Built In Parameter method to choose the parameter (yes/no tickbox) of 'Enable Analytical Model' across all Elements inside of the Revit Document
    param = BuiltInParameter.STRUCTURAL_ANALYTICAL_MODEL
    # Once we have our BuiltInParameter, we need to get it's Element Id and convert it to a Parameter Value Provider in order to use it inside of our filter
    provider = ParameterValueProvider( ElementId( param ) )
    
    # We then set up an empty instance of a Filter Numeric Equals to test against a set value (In this case - whether or not the Element has the box ticked for 'Enable Analytical Model'
    evaluator = FilterNumericEquals()
    # After we have the empty instance set up as our evaluator, we run a Filter Integer Rule that checks the chosen parameter (Enable Anyalytical Model), runs against the evaluator (Does this Number equal) and our value (1 which correlates to the tick inside of our yes/no tickbox)
    rule = FilterIntegerRule( provider, evaluator, 1 )
    # After we have generated our Rule, we can generate a filter based off this rule
    filter = ElementParameterFilter( rule )
    
    # Now we have a valid rule to run against our Filtered Element Collector. So in this case we pull everything inside the document - but only if it passes our filter (i.e has the box ticked on for 'Enable Analytical Model') then make sure we return the elements themselves. 
    analyticalCollector = FilteredElementCollector( doc ).WherePasses( filter ).ToElements()
    
    # To get our results back inside of Dynamo, we need to append a list to the OUT port
    OUT = analyticalCollector
    I've heavily annotated the Python above so it should explain exactly what is going on for you - but please do reach out if you wish further explanation.

    This means that all categories are picked - without having to stipulate so. It also cleans up the front of your graph a little. In essence, you could go and reset everything inside of this node with a few more lines of code - but where's the fun in that!

    NOTE: The colour in the Code section above are as per the Python Node IDE - so some are white (And thus invisible). Simply copy it through into a Python node, hit run and watch the magic unfold
    Last edited by amoursol; June 22nd, 2018 at 09:04 AM.
    elton williams, johnp and Kate like this.

  3. #3
    Junior Member Kate's Avatar
    Join Date
    September 4, 2014
    Location
    Ann Arbor, MI
    Posts
    46
    Current Local Time
    06:54 AM
    Sol, thank you so much! This works like a charm and definitely cleans up the graph.

    I'm just starting to use Python myself, and I'm curious - what types of rules of thumb do you use for accomplishing something in Python vs. with Dynamo nodes?

    The only Python I've used so far has been an "If" node I wrote myself to handle empty lists, and another Python node shared on the forum for getting Revision information.

    Thanks again for taking the time to write and annotate this code, it was very helpful!

  4. #4
    Senior Member amoursol's Avatar
    Join Date
    November 21, 2012
    Location
    London, United Kingdom
    Posts
    612
    Current Local Time
    11:54 AM
    Quote Originally Posted by Kate View Post
    ...I'm curious - what types of rules of thumb do you use for accomplishing something in Python vs. with Dynamo nodes?
    Hey Kate,

    The if node is a great place to start (As the out-of-the-box node doesn't function as expected - you have to use ScopeIf instead). Another great simple win is to create strings from objects - you don't get the same rounding issues you get with the out-of-the-box node either.

    Code:
    OUT = str(IN[0])
    It's as simple as that.

    Typically, there are a couple of use cases for Python as follows:


    • Access the Revit API for functionality that isn't exposed out-of-the-box.
    • Access the .NET framework modules (CSV for Excel stuff, copying files, renaming content, databases, high math functions, operating system stuff etc).
    • Build pop-up windows (See Data-Shapes package for an example)
    • Create faster graphs by disposing of Geometry (Every single node will hex Geometry upon execution - and this can cause slowdown over time or over big graphs. Wrapping it all up inside a single python node, and disposing of the Geometry where you can allows for a release of memory and speedier execution).
    • Allows you to build external modules to control from one single secure location (Rather advanced this one).
    • Build on the back of Giants (Machine Learning modules, data-science modules, optimisation algorithms etc)


    There's a few more beyond this but that's typically what I use it for (Or want to haha)!
    Kate and JWR like this.

  5. #5
    Junior Member Kate's Avatar
    Join Date
    September 4, 2014
    Location
    Ann Arbor, MI
    Posts
    46
    Current Local Time
    06:54 AM
    Thanks so much for the feedback - very useful to have some rules of thumb going forward!

    I ended up writing my own if node because the ScopeIf seemed to be causing some strange behavior in my graph, but that may have been 'user error'.

    Looking forward to developing more in Dynamo!
    amoursol likes this.

Similar Threads

  1. How to adjust analytical model and nodes with physical model
    By saif abedin in forum Structure - General Questions
    Replies: 0
    Last Post: August 28th, 2016, 05:11 PM
  2. Analytical model of a model in-place
    By pttpx2 in forum Architecture and General Revit Questions
    Replies: 0
    Last Post: June 14th, 2016, 09:59 PM
  3. Analytical model
    By jbenoit44 in forum Structure - General Questions
    Replies: 12
    Last Post: June 21st, 2012, 03:34 PM
  4. Analytical model for slabs
    By lucis29 in forum Structure - General Questions
    Replies: 4
    Last Post: January 7th, 2012, 02:36 PM
  5. Analytical Model Lines
    By dzatto in forum Architecture and General Revit Questions
    Replies: 40
    Last Post: December 16th, 2011, 11:18 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •