I’m new to Shapediver so I would be grateful for any tips in the following topic:
My goal is to create a pdf containing:
screenshots of generated 3D building
text generated by a Python component
tables with numbers generated by a Python component
static logos, images
The pdf would be created inside of a Shapediver, and then exported.
My plan is to implement another Python component, that would create such a pdf, however I’m nor sure if following things are possible:
screenshots. I’m able to use rhino python library to take same screenshots but in order to use them in python I need to save them locally in SD. Is it safe to save objects in SD and load them in the same request to create a pdf?
pdf export. I was able to export pdf but I had to use squid library to create it. Is there a way to export a pdf that was saved locally in SD?
logo. How can I store a logo image so that it’s accessible from a Python script in SD?
I do not recommend using Python components, as they will slow down your definition because they need to be compiled every single time. Additionally, there are already Grasshopper plugins to create PDFs: the Squid Plugin (ShapeDiver edition) and the PDF+ Plugin, both available in the package manager.
You can check out these video tutorials, where I teach how to create PDFs using the Squid plugin:
However, I recommend using the PDF+ plugin with out-of-the-box components to create tables. The principles shown in the video tutorials are the same.
Regarding the screenshot, this is only possible when taking a screenshot of our viewer at ShapeDiver. You can not take screenshots of the Rhino viewport while using the definition at ShapeDiver, as we do not allow access to the document. If this works for you, you need to use the “Import Bitmap” component to upload the screenshot either manually or via the API. If you use the API, you need to use this function: IViewportApi | Viewer and then send the result to the parameter also via the API. We are working on making this easier without using the API.
An alternative to taking a screenshot is using the Make2d component. However, make sure you feed it simplified geometry, as it takes time to compute. I can also give you other tips regarding this if you think this alternative could work for you.
Regarding exporting a local PDF that is not parametric, you can internalize it in the Grasshopper definition by using the “PDF Document” primitive:
Regarding a logo, you can internalize images in the definition by using the “Bitmap” primitive, or you can upload a logo after having your model in ShapeDiver by using the “Import Bitmap” component and leaving it as default.