Monday, 25 March 2019

Dynamo Dictionairies

Dictionaires in Dynamo have around for quiet a while now. So far most of the time I only encountered them with certain nodes. I know there are some nodes OOTB to create them but so far I had never seen a use for the things I do with Dynamo. Which doesn't mean there aren't any.

I have this script I created quiet some years ago that I so once in a while use. I extracts some information from a Revit project. Since the script always seems to work fine I never really bothered reviewing or updating it.

One of the things the script does is that it gets all the linked files and report back the instance and type worksets for that link. I link reviewing that information because often i get a pretty good insight in how much the user knows about Worksets in combination with links and I can often offer a solutions for improving performance.

This time the script worked but the data was all in the wrong columns. The script pushes out information to csv files which I read into power bi to make a pretty dashboard. But because someone decided to use comma's in the name of the worksets things ended up in the wrong columns....

So I needed to go into the script and fix this by adding a  string.replace node. While looking where to fix this in the script I ran into this part of the script:
Several replace by conditions after each other. That looks now like a lot of unnecessary nodes. It takes the values form the parameter discipline which are integers, these integers I like to replace with the actual name.

If I create a dictionary from the values and the words I want to replace them from it looks a lot more savvy.


The string "other" that gets added is because some views don't report a value for discipline, other is in my mind a bit neater than nothing.

I ofter tell people when doing Dynamo training that dynamo is like a toolbox and you need to learn what the tools do so you can expand your solution solving skills.

In other words practise what you preach...



Thursday, 28 February 2019

Revit Server Files

Recently I was setting up a dataset for analysis. The files were placed on a Revit server and later I noticed I should have saved them with a different file name. 

The save way and recommended way of doing this is by opening the file and saving it as a new central file on the Revit server, but that is also tedious and no fun.

Since my projects aren't live and basically I don't get in trouble for messing up my own files let's turn the safeties off and go free riding.

Disclaimer Do not do this at home work. It is only tested on my own configuration! From here on you are responsible for what you do with this information. 

If you go to your Revit server and where it save the files:
Notice the path and you see this thing that looks like a folder? If you rename this to for example this below:

Press F5 on your RevitServerAdmin, you will see it updates to the new names

The real test is ofcourse, does it open?
  1. Yes it does! (All of them are loadable)
  2. Do the links load?
  3. Yes they do! No reloading links or pointing to new files necessary.
  4. Do the files synchronise?
  5. Yes they do.

See the admin console below


Is this a good idea?

Probably not! But it was nice and quick for me though!




Monday, 18 February 2019

Numbers to Strings

I often run into the situation in Dynamo that I need to convert numbers to strings. Most of the time I end up with strings containing many decimals like .000000

Of course I can fix that with dynamo nodes but one python script node is handier. The only thing is I can't get the system locale working atm.

# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

"""
import locale
langlocale = locale.getdefaultlocale()[0]
locale.setlocale(locale.LC_ALL, langlocale)
dp = locale.localeconv()['decimal_point']
"""

if isinstance(IN[0], list):
    numbers = (IN[0])
else:
    numbers = [(IN[0])]

output = []

for n in numbers:
    tmp = str(n)
    # You might have to change the splitting character to work with your system regional settings
    splist = tmp.split(".")[0] # now the splitter is hard coded
    # splist = tmp.split(dp)[0] only use this line if locale is working     
    # split generates two items in a list this one gets the first
    output.append(splist)

OUT = output

Friday, 11 January 2019

Dynamo IF node

For quite some time I have run into issues with the IF node in Dynamo. It seems to have issues when you are presenting lists of different lengths. To avoid this I have created a little Python script that does the work for me. The python code might not be to pretty but so far it works.

My IF node keeps evolving I have removed the previous lines and replaced them:

"""
LIST: Replacement of Dynamo IF node
"""
__author__ = Daniel Gijsbers
__version__ = '2.0.0'

# Enable Python support and load DesignScript library
import clr

clr.AddReference('DSCoreNodes') 
import DSCore
from DSCore import *

# The inputs to this node will be stored as a list in the IN variables.
ToF = IN[0] # a boolean
List1 = IN[1]
List2 = IN[2]

Result = []

if ToF == True:
Result.append(List1)
else:
Result.append(List2)
# Making use of Design script for flattening

OUT = List.Flatten(Result,2) # The second input allows for the level of flattening
The code >




The output of this node goes into another Python node that creates worksets.
Credit to John from sixtysecondrevit for that bit of Python Code.


Thursday, 15 November 2018

Dynamo Functions

Being busy with Dynamo there is so much you can spend time on learning. I haven't taken the time to look into functions in Dynamo. Which I regret now, I could have saved myself a lot of time. Tonight I thought let's look into this as I found myself repeating something in Dynamo a lot. I often need to get a vector from a curve's start to endpoint. There are curves being created in dynamo that are straight and for which this function may work. This function of course could create havoc for any none straight curves. These straight curves typically come from PolyCurves, edges from flat surfaces and isolines from flat surfaces.

So after reading the dynamo primer for 1 minute.
7-4_functions
A bit of node to code and typing.

  1. Are the original nodes
  2. Is the function I defined at Number 3 in a Code Block
  3. The actual code

In other words this is embarrassingly simple... 

The code: 

/*This is a function for getting a vector from:
a curve start to endpoint*/

def VectorCurveSEPoints(curve1)
{
point1 = Curve.StartPoint(curve1);
point2 = Curve.EndPoint(curve1);
vector1 = Vector.ByTwoPoints(point1, point2);
return vector1;
};


Tuesday, 9 October 2018

Performance

A good friend of me has a computer which is completely water cooled. His setup is really cool, very quiet and very fast. He knows quite a bit about tweaking performance so we had a go at my machine.

I tend to work on a mobile workstation. I don't call it a laptop because the thing is rather heavy to carry around... He told me that a lot of processors can do with a lot less voltage than what they get by default from the factory. The factory tends to do this for stability and because not every processor is or behaves the same. The disadvantage of the higher voltage is that the temperature of the processor becomes higher. You might think so what. Laptop processors tend to reduce the clock speed once a processor gets to a certain temperature. My processor, Intel i7 8700K (unlocked), throttles  back when it reaches 85º celsius. It tends to go from 4700 mHz to 3700 Mhz. Revit performs better at higher clock speeds of the processor. (Revit is mostly a single threaded application, more cores hardly benefits Revit.) So if I can keep the temperature down than the processor won't throttle back.

So we did a little bit of testing with reducing the amount of volts and the setting the maximum Mhz to see if it would run stable. By default the processor was set to 1300 millevolts. We reduces it to 1085 millevolts and it runs now stable at 4400 Mhz constantly. The bios allows for setting the maximum mHz per core. Next thing I will try is see if I can have one core running at a bit higher clock speed and still stay stable and stay cool. After that setting I just have to test to see if Revit will pick that core that is running at a slightly higher clock speed.

After a bit of tinkering and the inevitable blue screens we found a setting that that gives me, stable,  more performance for Revit and Dynamo.

The two screenshots show the low and the high fluctuations in voltage usage. It Also shows the current clock speed and the temperature of each core.



To test the stability we ran this tool called: Prime from: http://mersenne.org
This tool uses every available core of your machine to calculate prime numbers.

For a little bit ore detailed info we also used: HWInfo. https://www.hwinfo.com/

In the end we also ran a benchmark that would both stress the video card and the processor to see if the extra heat from the video card would cause any issues. It didn't!

Next thing I have to do is turning of the hyper threading as this tends to also benefit Revit.

So that was a bit of fun tinkering!







Tuesday, 11 September 2018

Levels and Grids

Recently I received an email from Autodesk with Revit tips. One tip caught my eye right away: Turn all Level and Grids off in linked models in your entire project
Although the tip is fine and well explained I must say I do not favour this methode. For many years I tell, and many others, to Revit users, not to use Worksets for visibility purposes.

If you want to turn of Levels in a linked file you can do this with a filter. If the models are properly setup than you can use these parameters to filter upon.
Building Story and Structural are good parameters to use.
So basically you will turn of levels based upon parameter values:
Grids do not have this option, Grids only have few parameters. I tested what happen if would assign levels and grids to a scope box in the host model.  I could only get it to work if the filter setup was: See image below.
If I was filtering for a specif Scopebox name only found in the host model it would not work.(bug???)
What does work but is less elegant:
If you change the name of your levels and grids slightly you can filter on that. (In the example below I added DGi to the name of the levels and grids)
So the filter option might be a bit more tricky to get it to work for you but it when done right you only have to set it once. You don't have to traverse 20 linked files.... 
Put the filter in a view template and you are flying!