temanman Posted August 17, 2023 Share Posted August 17, 2023 I would like to know about how I can activate Google Spreadsheets from Vectorworks . I am struggling to output some data from Vectorworks using the code with Python. I cannot find any solution so far, so I’ll appreciate with you if you give me any tips. thanks. Quote Link to comment
JBenghiat Posted August 18, 2023 Share Posted August 18, 2023 What do you mean by “activate”? Are you looking to use the Google API to read or write to Sheets? On the Vectorworks side, do you want to pull from worksheets or directly from objects? 1 Quote Link to comment
temanman Posted August 18, 2023 Author Share Posted August 18, 2023 Thanks for your reply. I’ll try to pull some data from worksheets on the Vectorworks into Google Spreadsheets directly without using Google API. I think it seems like impossible to do that… Quote Link to comment
JBenghiat Posted August 18, 2023 Share Posted August 18, 2023 If you’re looking to manually move data, you can go to the file menu in the worksheet window, and export as csv or Excel, and import to Sheets. If you want to use python to do this programmatically, it is definitely possible — VectorScript can read your worksheet data, and you can either use Google’s API and an OAuth key to write directly to a Sheet, or post the data to the sheet and process with an Apps Script. 1 Quote Link to comment
temanman Posted August 18, 2023 Author Share Posted August 18, 2023 If you want to use python to do this programmatically, it is definitely possible — VectorScript can read your worksheet data, and you can use Google’s API. Is this possible??? If possible, could you write sample codes about it??? Quote Link to comment
JBenghiat Posted August 18, 2023 Share Posted August 18, 2023 The best solution depends a lot on exactly what you are trying to accomplish, and your current knowledge of Python and/or Javascript. This isn't the sort of thing where a 10-line example will give you what you need -- if you're new to coding, you may want to contract for this work on spec. One caveat -- you aren't going to be able to have a live connection between VW and GS with Python. You may be able to get some live sync by using an ODBC connection in VW and an Apps Script to build the sheet. You should also be able to build a live connection via the SDK. Possibly the most straight-forwards method is to write data to an Excel sheet on Google Drive, and then (if you don't want to manually import) create an Apps Script to import the Excel workbook into Sheets. VS has commands for working with Excel files here: https://developer.vectorworks.net/index.php/VS:Function_Reference#Excel. You can also find third party Excel libraries for Python. A tutorial for importing via Apps Scripts is here: https://spreadsheet.dev/automatically-convert-excel-spreadsheets-to-google-sheets-using-apps-script#use-apps-script-to-convert-excel-xls-xlsx-to-google-sheets Similarly, you can use Python's csv library to export your data and read via App Script. If importing to Sheets seems daunting, you can use an intermediary service like Zapier, which can monitor a cloud drive or web hook and create your Excel data: https://zapier.com If you want to create your Sheet directly from Vectorworks's Vectorworks, start with these commands to read worksheet data and formatting: https://developer.vectorworks.net/index.php/VS:Function_Reference#Worksheets Google offers a Python API for working with worksheets. You can find an overview and examples here: https://developers.google.com/sheets/api/guides/values#python Or a variant of that would be to use Python to post the data to the Sheet's web app, and process with Apps Scripts. https://trevorfox.com/2017/01/google-apps-script-doget-and-dopost-tutorial-6-web-app-examples/ 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.