Cannot Clear Excel Contents with Bumblebee Node

I am attempting to clear Excel data with the use of Bumblebee’s Clear Contents node. However no matter what I do, the excel data will not clear. See video for example and attachments for test excel file and dynamo graph. Any help would be greatly appreciated.

exceltest.dyn (4.2 KB)

ExcelClearContentsTest.xlsx (8.8 KB)

I know this is a late time coming, and you may have moved on or since found a solution, but for anyone who stumbles upon this, just like I did, when recently having the same issues, I’m posting an answer here as an interim solution while I notify the Bumblebee’s author of the issue.

The issue occurs in line 105 of the python script driving the Clear Contents node of the plugin. The line reads if os.path.isfile(str(filePath)): inside of a try: statement. The problem is, the only time os is imported is in line 18: from os import path. This is an issue because line 105 has no idea what namespace os is, only the path namespace from os, and so it fails, causing the except: clause to kick into play. This bypasses any write operation onto the file and immediately ends the script and releases Excel com properties. Unfortunately, there’s no line setting a message override in that except: clause, so “Success!” is all that displays from the node dispite the overall operation failure.

The Solution:
There’s a few ways to handle this, but effectively you have to eliminate the “unknown” aspect of the os namespace.

Option A:
Remove “os.” entirely from lines 18 and 105.
NOTE: Least stable and readable due to lack of specificity of the name “path”

Option B:
Update line 18 to read as from os import path as ospath, then update line 105 from os.path to ospath.
NOTE: Recommended option.

Option C:
Change line 18 to import os.
NOTE: This would import all of the os namespace, which is otherwise unused. This option is not recommended due to possible and untested performance issues.

2 Likes

I have not understood how I have to rewrite the code to modify the Cleer Contents node of BumbleBee

Like I said in my post, I contacted the author of the addin, and I believe he has since corrected the issue. So if you’re running the latest version of Bumblebee, you should be fine and don’t have to correct anything. If you’re running an older version to match an earlier version of Revit, let me know and I’ll post a video as soon as I get time to record one (likely over the weekend) to demonstrate the Option B I listed above.

Exactly. The problem is that I’m working with Revit 2019 models and the latest Bumblebee update only works with Revit 2020

Anyway I have compared the code of the last update (January 2020) with the previous version (December 2018). Lines of code 18 and 105 have never been changed.
I saw the thread in which you wrote to the node creator. He replied that he would follow your suggestions but he didn’t it.

I just updated it earlier today. Please download version 2021.25.2.

Cheers!

-K

Thanks for quickly updating the node. I have created many scripts for exporting data from revit to excel,…my job is to make bill of quantities. I am now trying to use Clear Contens first to clear the A1: B10 matrix and then write excel to write on the A1: B20 matrix … I can’t do these two operations one after the other. can you confirm that it is not possible or is there a way to do it?

I apologize for my delayed response. I’ve had a similar issue with creating MTO’s from our models. You should create a python node with the following code:

if 'Success!' in IN[0]:
	OUT = True
else:
	OUT = False

Then link the output of the Clear Contents node to the input of the python node, and the output of the python node to the “runIt” input of the Excel Write node, as shown in the above picture. Thanks to this package being a python node, I have slightly modified the Excel Write node to operate on lists of types boolean and BBData to better suit my needs of categorical “gates”, so my picture looks slightly different with the List.Joint node than your script will appear (likely without that node).

Unfortunately, this workaround is the only possible solution for your proposed workflow due to the way Revit handles nodes that are not directly connected in an input chain. If a node does not have an output linked as an input to a given node or input node, it is considered to be running in parallel and thus cannot be dictated to run in a specific ordering, only consolidating if these nodes then both input into the same node later in the script.

This is assuming you do not, in fact, want Write Excel to run if Clear Contents does not succeed due to an error. If you want it to run regardless, and just ensure that it will run afterwards, simply change both assignments of OUT to:

OUT = True

Or add a second input to the Python Node, input the filepath used by Write Excel, and change both assignments of OUT to:

OUT = IN[1]