Element Binding in Revit

Thank you. it took me 3 days to figure this out, i was having trouble with views.
Every time i run the script, it just deleted the previous ones…

Hi @jacob.small,
I try to reproduce your example provided with the additional class materials from your AU class about element bindings. Can you please share the custom nodes you have used in the graph as well?


Thank you :slight_smile:

I don’t have that handy and they’re not of much value beyond this exercise so I have no plans on publishing a package for this. However, reproducing the same graph is less important than producing other versions you will need in the future, so knowing how to build your own version of each is a must.

Towards that end, those were just the same nodes in the associated type wrapping in a custom node. So the Elemwnt_Bindings-OOTBoxNodesWrapped is just a custom node made from the FamilyInstance.ByPoint node.

It gets a bit fuzzy at the end (ie: custom node inside a custom node passing through a python node), but give it a shot to reproduce what you can - it’ll help when there is a change in the behaviors someday. I’ll try to remember to post an expanded data set here next week when I have access to that dataset again.

2 Likes

Interesting to know how this works exactly…
Dynamo really should have a switch to turn bindings on and off in the active script, for when you DO want to create new elements each time.
In the meantime, would it possible to make ‘Clear Binding’ node that if used in a .dyn will will clear out all the binding data from the active .dyn before or after each run?

1 Like

Not likely. You would need to change the way the Dynamo works holistically so likely a modification to Dynamo would be required. Many ‘bad things’ could stem from altering this though so be careful as you look into it.

Ok, thanks. Ill just stick to using the player for this then.

Thanks @jacob.small for the great explanation!

1 Like

What version of Rhythm has the Helpers.ToggleElementBinder node?
I have Rhythm 2019.1.21 but I cannot find this node.

Hi @Revit_Noob you are using a 2 years late version of Rhythm.

  1. Try downloading a new version first
  2. and make a new topic in the forum.

I cannot install higher version of rhythm as I only have this dynamo version installed :

Dynamo Core 2.0.2.6826
Dynamo Revit 2.0.2.6833

@Revit_Noob that shouldn’t be an issue. Please try and install the latest version. @john_pierson builds its nodes in such a way that you should be good to go with Revit 2018+ et Dynamo anything above 2.0 version

Not all nodes will work in Revit 2018 i think. :slight_smile:

@Marcel_Rijsmus obviously not all because of Revit API new features such as the warnings access for example. but most of them will.

1 Like

also, @Revit_Noob , the helper was created in april 2019, whereas your specific version of the package is older.


therefore :grin:

1 Like

Ok will try. Thank you.

Unfortunately none of these work for me. I have a script which selects the edges of of elements and turns it to a poly curve which forms the path for the sweep of a family profile. This is then inserted into the project by direct shape. This procedure has to be repeated many times over, but every time it creates a the sweep at the new location only. I have literally tried everything including saving as different rvt files. but nothing works. I have even tried flush bindings from monocle. No use.

  1. Clear the bindings via monocle, and save and close the graph.
  2. Check to confirm bindings are clear by opening the file in a text editor and confirming nothing rests under the “Bindings” section of the file (watch the AU class for more info)
  3. Only run the graph via Dynamo Player once you confirm the bindings are clear.

This will ensure that each time you hit run new elements are created, while the old ones are left in place. Running by standard Dynamo is also possible if you close the file without saving between pressing ‘run’.

A final option which I didn’t cover is building and using a function for the element creation efforts. This wasn’t covered before because it’s more complex and would require another hour or so to get into the intricacies. I’ll add it to the list of stuff to cover in a future Dynamo Office Hour though.

If you can’t make any of these work start a new topic and attach an RVT and your current DYN.

3 Likes

Thank you for the quick response. It is working now. One mistake I was making was not changing the name of the element between runs. The direct shape was created using brepshape which is a springs node which requires a name to be provided for the created element. I also used the toggle mentioned in one of the posts here. Now it is working without editing the text file. Thank you.

2 Likes

Thanks @jacob.small, for a big article on Element Binding. The removal of Bindings section works for me today after hunting a solution for an hour.

1 Like

Hey guys,

I also made two handy scripts to auto-delete the bindings in .dyn files. You need to create one .bat and one .ps1 file. So a Batch and a PowerShell-File.
The Batch-File executes the PowerShell-File on double-click. The PowerShell-File deletes all Bindings in all .dyn files wihtin the same folder where the ps1 is located. Do not rename both files as the names are being referred in the code unless you know how to change the code accordingly. So the easiest way is to copy both files into the same folder where your .dyn files are located and just double click the .bat.
Attention: Be aware that you maybe have to allow execution of PowerShell-Scripts on your machine. Otherwise the PowerShell-Script won’t execute.

The Filenames (incl. extensions) are:

“ExecutePowerShell.bat” and “PS_Script_DeleteBindingsInDynamoFile.ps1”

Here is the Code for the .bat:

@ECHO OFF
SET ThisScriptDirectory=%~dp0
SET PowerShellScriptPath=%ThisScriptDirectory%PS_Script_DeleteBindingsInDynamoFile.ps1
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%PowerShellScriptPath%'";

Here is the Code for the .ps1:

$path = $MyInvocation.MyCommand.Path
$path = Split-Path $path -Parent
$files = Get-ChildItem -Path $path -Filter *.dyn
<#
ForEach ($file in $files){
    If ($file.Name.Contains("new")){
        Remove-Item -Path $file.FullName
    }
}
#>
$files = Get-ChildItem -Path $path -Filter *.dyn
ForEach ($file in $files){
    #$NewName = $file.FullName -replace ".dyn", "_new.dyn"
    #Copy-Item -path $file.FullName -Destination $NewName
    (Get-Content -Path $file.FullName -Raw) -replace "(?ms)Bindings.*?]", "Bindings`": []" |
    Set-Content -Path $file.FullName  
}

7 Likes