I see a lot of BOM extensions but none of them gives you the possibility to make your own layout of the columns exported to excel; I want to fit them to a specific import format from another application.
When you make an extension specifically for this; do you use the Ruby API or the Sketchup SDK ?
Use SketchUp’s classification system (which uses it’s special attribute dictionaries) and IFC attribute schema. These could be exported. Generate Report may or may not “see” these attributes. (Cannot remember offhand.)
You can also create your own custom classifications via a XML schema document.
For the SketchUp SDK you might need to seek out third party C libraries to read and write CSV, XLS or XLSX (XML) files. The SDK has some examples of writing out to an XML file. However, currently the SDK is standalone for reading and writing directly to SKP files. It is not easliy hooked into the “live” SketchUp application process.
def self.send_to_excel_book(book_name)
#connect to the workbook
begin
xl = WIN32OLE.connect("Excel.Application")
rescue
return
end
bk = nil
for bknum in 1..xl.workbooks.count
if xl.workbooks.item(bknum).name == book_name
bk = xl.workbooks.item(bknum)
break
end
end
for shtnum in 1..bk.worksheets.count
if bk.worksheets.item(shtnum).name == "Quotation"
sht = bk.worksheets.item(shtnum)
break
end
end
unless bk and sht
xl.ole_free
xl = nil
GC.start
return
end
#send to pictures to the workbook
path = bk.path
fpath1 = path + "\\images\\" + bk.name + '(1).jpg'
fpath2 = path + "\\images\\" + bk.name + '(2).jpg'
pic1 = @bcpath + 'sub programs/view1.jpg'
pic2 = @bcpath + 'sub programs/view2.jpg'
if File.file?(pic1) then FileUtils.cp_r(pic1, fpath1) end
if File.file?(pic2) then FileUtils.cp_r(pic2, fpath2) end
fpath11 = fpath1.gsub('/','\\')
fpath21 = fpath2.gsub('/','\\')
sht.Shapes.AddPicture(fpath11,0,-1,339.5,186,409.0313,251.7116)
sht.Shapes.AddPicture(fpath21,0,-1,339.5,438,409.0313,251.7116)
#show the workbook/sheet and bring it to the front
sht.activate
xl.application.WindowState = -4143
w = WIN32OLE.new("WScript.Shell")
w.AppActivate(xl.activewindow.Caption)
w.ole_free
xl.ole_free
xl = nil
GC.start
end