Hello, i am working on project to create an extension that needs to work with a document base database precisely tinydb . I honestly dont know how to start and i have made my reading arounding telemetry but thats not the kind of data i need to save on the db i wamt to implement in my extension
Do you really need to save the data to tinydb, or can you save directly to csv?
CSV export can be easily done within pyrevit thanks to the python built-in library; on the other hand, to write to a tinydb database you need to use a separate package as @andreasd811 stated. For this, you need to create a lib extension for tinydb, which fortunately doesn’t have dependencies, but you have to use the version 3 to be able to use it with ironpython 2.7 (or use cpython 3).
Other than this, I suggest you to embrace the “programmer’s mindset” and break down your problem into smaller ones, and be more specific about each of them.
you want to extract data from revit. This statement is too generic, if you want us to point you in the right direction you need to be more specific:
Are you interested in all elements, or just some categories of elements, or only the selected ones? Or sheets, views, schedules…?
do you want to extract parameters? Built-in or shared? Or maybe their insertion point, bounding box, dimensions?
Once you figured out what you need, you will easily find the answer in other discussion on this forum, the documentation or the various tutorials (check the pinned quickstart guide for links)
You want to save them to tinydb (if you cannot avoid that). The only thing needed, apart from the issues I mentioned above, is to save the data from point one as dictionaries. The rest is accomplished by following the user guide or some tutorials.
You want to export csv files. This works even without tinydb, instead of fetching the documents from the database you can just use the dictionaries to build the csv thanks to the csv.DictWriter class. There are plenty of tutorials to learn how to use it (and it all boils down to a few lines of code).
hello @sanzoghenzo thanks for the reply
along the line of my research I was able to overcome by integrating csv to act as the database by using the append to file function (‘a’). all parameter extracted from the model will append to the csv file. i ll provide a sample of the code on request.
thanks for your time