Haven’t delved into Notion API unfortunately, but I believe @john_pierson most likely has. The crew over at Speckle might have tips too if you reach out to them, they’ve whipped up a nifty speckle integration.
It appears to be a string formatting issue, at least to the point where the script fails. The apostrophe identified before might be the culprit but hard to say at face value (afk currently).
import sys
sys.path
sys.path.append('directory path')
from package import *
Assuming your library is a .py file sitting in that directory that should provide access to all functions/methods/classes in that file. I believe if you want to treat it like a library with multiple files/init etc. then the approach may be a bit different… still learning about the options to this approach. Pip etc. aren’t really the same in Dynamo as far as I’m aware.
So I am tabling this for the moment. It was a great idea that would be super handy given that we are needing to write notes in Notion while we model. It seemed pretty easy and straight-forward, especially after watching this tutorial on Youtube. I figured I could follow the steps in the video, add some UI with Data Structures, then we could have a button where we could add a page in Notion.
I can’t seem to figure it out at the moment though. I’ll be back though because I think this could be handy and useful for people.
I think I ran into a few issues as well when trying to integrate. Notion is a beast because objects are so Dynamic and can be nested (seemingly) infinite numbers of times.
The repo I linked above was kind of what I was starting to think to make sense of it all. Making it all object oriented.
So take Revit for example:
Wall (class of element)
Has properties like height and length
Can host other things, like doors
etc.
Notion:
Page (class)
Properties
can host tables, etc.
Maybe I can get back to it eventually. But I do think you might have better luck if you were to use the JSON nodes in Dynamo 2.13.
Well the reason I was thinking it would be so simple was that I wasn’t wanting to link or tie anything from Revit to Notion. I was just wanting a button on the ribbon I made via Pyrevit that when you click on it a UI would appear where you could enter the Page Titile, Description, and Assignee. Then when you hit ‘enter’ that would create a new page in the ‘Revit Review’ database. That way I didn’t have to stop working in Revit and go over to Notion.
In the video I posted the guy walks you through entering the code as he does it for the first time and it works. So I figured I could follow him and enter those lines of code into the Python Node in Dynamo, create some Data-Base UIs, then place it in my Toolbar folder.
I think my issues were stemming from the packages you have to use and not knowing how to import them. It could also be my little experience with Python and not doing something correctly. I say that because I was having issues with the packages in Thonny and in PyCharm Community.
So I couldn’t leave it alone (not sure why I thought I could, lol). I messed with it throughout the weekend and reached out for more help from the tutorial creator and on Reddit I officially have a working script!
I’ll revise it now to match the database I want to share it with and start working on the Revit part of it all. I’m debating if I want to continue down the route of Dynamo or look into the workflow that Erik Frits has been uploading videos about. That is using Python and running them through Pyrevit. I’m wondering if I won’t have the issues with requests and json going that route.
Here is the working script if anyone wants to check it out. →
Called it! Glad to see it worked out for you. This is a handy technique when working with custom libraries in Python, I use it often when developing my own .py files. Sort of like building custom packages, but only calling them in when they’re needed.
So, I had something interesting happen and I thought I would put it out there to see if anyone had any suggestions.
I got the script working, but then didn’t use it for a while. I decided to re-test it and it didn’t work. It said that it couldn’t import ‘requests’ because the module did not exist. I checked the folder location and it was there. What I did notice is that the windows explorer folder did not have the python folder, but the folder did exist in Google drive (Pretty much our entire server in via Drive). I did the only solution I know of which is to rename the file in Drive, the folder re-appears in the Windows Explorer folder, and then I renamed the folder back to what it was in Drive. I ran the script again and it didn’t work. So I plugged the script into Visual Studio, changed all the input variables to strings, ran the script and it worked.
So, obviously the script works but Dynamo is having some issue with accessing the drive folder. Any thoughts on why this is the case? I am thinking about talking to our Tech guy and asking his opinion on putting the dynamo folders on one of our computers. Twice now I have had Dynamo not work because the folder doesn’t exist in the Windows Explorer folder, but exists in Drive. The only solution our tech guy has is to rename the folders so they re-appear. Anyone else have this issue?