Can someone tell me how I can put the IFC export options if I (through the API (Ruby) wants to export a model.export file as .ifc?
In the documentation of the API there is nothing about it, but at a manual export ’ for example, I can specify which ifc export elements should be exported.
I want to export an IFC ifc elements with just only the ’ Ifc_Window ’ elements…
Most of the File import / export “Options” dialogs are exposed to the APIs.
There may be a hack for Windows using SendKeys and the WIN32OLE class.
https://msdn.microsoft.com/en-us/library/8c6yea83(v=vs.84).aspx
http://ruby-doc.org/stdlib-2.0.0/libdoc/win32ole/rdoc/WIN32OLE.html
require 'win32ole'
module Author::SomeLibrary
extend self
def export_my_ifc(ifc_filename="myexport.ifc")
# for SU2015+ using MS Common Dialogs v6
shell = WIN32OLE::new("WScript.Shell")
Sketchup::send_action(21149) # WIN only
Kernel.sleep(1.0)
# Set export filename:
shell.SendKeys(ifc_filename)
# Select IFC filetype:
shell.SendKeys("{TAB}i")
# Select "Options" button, and click it
shell.SendKeys("{TAB}{TAB}{ENTER}")
Kernel.sleep(0.5)
# "Export double-sided faces" checkbox has focus.
# Use "{SPACE}" to check check boxes, if wanted.
# Tab down to selection list:
shell.SendKeys("{TAB}{TAB}{TAB}")
# Switch to last item:
shell.SendKeys("{END}")
# Tab to OK button and click it:
shell.SendKeys("{TAB}{ENTER}")
Kernel.sleep(0.5)
# Back in File dialog, tab to "Export" button and click it:
shell.SendKeys("{TAB}{ENTER}")
end
end
The older file dialog is different. And this does not work on Mac.
This method will use the export directory path preset in:
Window > Preferences > Files > Export Models:
Otherwise you need to stuff a different directory into the filename box, and send an “{ENTER}”, and wait for the file broswer to update, before stuffing the ifc_filename
into the box:
shell.SendKeys("some/path/to/export_dir{ENTER}")
Kernel.sleep(2.0)
# then set the filename:
shell.SendKeys(ifc_filename)
# etc,... as above
And as you may notice, this is fragile because if the order changes, or the IfcWindow
is not the last, this’ll break and you’ll need to do a “{HOME}” followed by whatever number of “{DOWN}” arrows it takes to get to your item.
Thanks Dan!, yes it is fragile but it seems to work but…
anyway, you write “None of the File import / export “Options” dialogs are exposed to the APIs” Thats true, but for example: PDF options can be set. See: http://www.sketchup.com/intl/en/developer/docs/ourdoc/model#export I hope this will be possible in SU2017 for ifc too…
Okay, got me. DAE also has an options hash. I changed the original to “Most”.