i’m exploring the possibilities given by Sketchup
Ruby API,and i found the “attrreporter.rb” file but it only generates csv and html files and only from groups or components.
I have a question is it possible to generate a Word or PDF documents that contains information extracted from Sketchup models ?
and those the model has to contain groups and components to do so ?
The SketchUp API doesn’t come with any methods by itself to generate these specific files. But you can certainly traverse the model, collect the info you need and generate these files yourself - using libraries that allows you to do so.
in the attrreport.rb file it generates csv and html files but they say :
# Currently we support CSV and HTML.
# More format can be easily defined here by defining the @filetype expected and the
# various variables @doc_start, @doc_end, @row_start, @row_end, @cell_start, @cell_mid, and @cell_end
how can i know the values to give t those variables ?
i kept searching but didn’t found anything about it ?
can u give an example of libraries that allows me to generate Word/PDF files ?
i didn’t try that by i tried to change the .csv to .pfd in code i found in the link above, it generates a pdf file but when i want to open it it says that the doc wasn’t decoded correctly.
i guess it has something to do with the # various variables @doc_start, @doc_end, @row_start, @row_end, @cell_start, @cell_mid, and @cell_end
because in that code they say if u want other file forma change those variables.
yeah it workd with the htm method but it generates a htm and i need to open it with Microsoft Word, isn’t there a possibility to generate a Word file directly ?
i found a library named Prawn File: README — Prawn Documentation
do u have an idea about it ? how can i integrate those kind of libraries to sketchup ruby API ?
The prawn site says it is pure Ruby (vs compiled code) and distributed as a Gem, so there is a fair chance it will work within SketchUp. Try the following in the Ruby Console:
Gem.install(“prawn”)
and see what happens. Note: it writes PDF, not MS Word. The Word file format is proprietary, there are no free published specs and an author probably has to pay a fee to MS to get access.