[Plugin] bim-tools 0.13.4(june 22, 2015)
-
Also in the [ Code Snippets ] sticky thread, I am endevouring to collect links on Platform Specific Quirks and Issues.
-
Some notes on
WebDialog
and the differences between platforms: http://forums.sketchucation.com/viewtopic.php?f=180&t=23445 -
I tried the export to IFC in v 0.9.2 and export worked fine and looked right with the FZK Viewer but when trying to import into Revit 2012 I got these errors: http://dl.dropbox.com/u/7990360/Bimtest01_Error%20Report.html
-
@pixero said:
I tried the export to IFC in v 0.9.2 and export worked fine and looked right with the FZK Viewer but when trying to import into Revit 2012 I got these errors: http://dl.dropbox.com/u/7990360/Bimtest01_Error%20Report.html
Thanks for trying and reporting back! I have had success importing the IFC's into ArchiCAD and Arkey(dutch CAD software we use at work) but I also got an error importing into bimserver.org. I haven't got around to further look into it. Can you also send me the IFC file? The errors revit reports only point to a row number, it does not explain on what kind of element it fails.
For the entire IFC export I still don know what's the best way to go, at the moment I see 3 possibilities:
- build the IFC translator myself(that's what I have done until now, but a huge amount of work to ever get full export AND import.
- use the TNO IFCengine dll( should work very well, I believe they have a MAC version as well, is free to use, but is not open source )
- use/contribute to [url]ifcopenshell.org[/url](I would like that best on the long term, but it is a work in progress itself)
I think for the moment I will add some more functionality(and fixes ) to my existing exporter, as long as there are only walls and windows and the like, I think that is quickest.
Anyone some more tips on this matter?
-
@dan rathbun said:
You cannot get away from platform specific quirks (oddities, etc.)
@dan rathbun said:
The advantage to dynamically defining methods that are platform specific.. is runtime speed. They will not be slowed down by any further platform conditional evaluations, because they are evaluated only at loadtime. (And a Mac will not magically morph into a PC, in mid-session.)
It seems like a good idea to me to start a side-project to catch and streamline all these platform specific quirks.
Like you say, create a general module that dynamically serves you the right methods based on the current platform. Set up a bit like Thomthom's webdialogpatch-class.module CROSSPLATFORM class CpWebDialog < WebDialog def show() if MAC show_modal() elsif WIN # this is not correct because it points to itself # but I hope you get what I mean... show() end end end end # call something like dialog = CROSSPLATFORM;;CpWebDialog.new # call show the same way on MAC and PC dialog.show
So all everyone has to do in your plugin-code is point to the "CROSSPLATFORM" module for these kinds of "quirky" API-calls.
It can imagine it's way too much overhead to include all these for every small plugin, but maybe make it "pluggable" by just adding a separate .rb for all used functions to a "crossplatform"-subfolder and dynamically require all ruby files present in this folder...
But still beeing a bit of a newbie, I probably miss a thing or two
-
Hi,
identifying the differences is the biggest hurdle. Most rubies need little or no 'fettling'.
I've got this working to the extent of mimicking your 'youTube' clip, plus the minimise button which took forever to get hold of.... It was only after I noticed it's missing from your demo....
Two big issues for me. why are you using 1999 XHTML? it's 2012...
#Note that XHTML 1.0 previously defined that documents adhering to the compatibility guidelines were allowed to be served as text/html, but HTML 5 now defines that such documents are HTML, not XHTML.
Safari was having troubles with this so I changed it to
%(#008040)[<!DOCTYPE html>
<head>
<meta charset=utf-8' />
<title>BIM-Tools - webdialog</title>
<link href='" + @pathname + "/bt_dialog.css' rel='stylesheet' type='text/css' />
</head>
<body>]
, which works for what you have so far...
Personally I think it should all be html 5 first, then add conditionals for older IE when it that all works.the other was you have two different image paths, niether was relative to the 'temp' html to I move it
@tm=(rand(9999).to_s.strip) @tmpPath=(@pathname + '/btDialog_' + @tm + '.html')
into the ui folder (which is as fast as '/tmp' to create, but harder to delete...), then I put a second copy of image folder in there as well. So I've got the background image, minus the js...
john
-
@driven said:
Two big issues for me. why are you using 1999 XHTML? it's 2012...
Two words: Internet Explorer
Only the very latest, IE9, support some HTML5. To support IE8 and IE7 will still some people use (heck, some even use IE6!!!) one need to use the good ol' fashioned HTML4 or XHTML1.0.
@driven said:
Personally I think it should all be html 5 first, then add conditionals for older IE when it that all works.
No point then, if the content is the same - if you're not using any of the HTML5 features.
Mind you, I'm very tempted in dropping support for IE older than version 9 in my future plugins. Damn-it people, the upgrade is free! <rant/>
-
IE 9 does not run on Windows XP, which is still the world's most-used OS; although Win 7 is catching up.
-
on mac SU uses,
<html> <head> <title>Generate Report</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script src="../js/dcbridge.js" type="text/javascript" language="JavaScript"></script>
for it's very dynamic 'Dynamic Components', and even 'Web Textures' has no historic XHTML
<html dir="ltr"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Pragma" content="no-cache"> <title>Get Texture</title> <script type="text/javascript" src="/3dwarehouse/resources/3140728709-main_base_module.js"></script> <link href="/3dwarehouse/resources/1561881125-sketchup-textures.css" rel="stylesheet" type="text/css"> <script src="http://www.google.com/jsapi?key=ABQIAAAA5El50zA4PeDTEMlv-sXFfRSsTL4WIgxhMZ0ZK_kHjwHeQuOD4xTdBhxbkZWuzyYTVeclkwYHpb17ZQ&hl=en" type="text/javascript"></script><script type="text/javascript" async="" src="http://www.google-analytics.com/ga.js"></script><script type="text/javascript" src="http://maps.google.com/maps?file=googleapi&key=ABQIAAAA5El50zA4PeDTEMlv-sXFfRSsTL4WIgxhMZ0ZK_kHjwHeQuOD4xTdBhxbkZWuzyYTVeclkwYHpb17ZQ&v=2.182&callback=google.loader.callbacks.maps&async=2&hl=en"></script><style type="text/css">@media print{.gmnoprint{display;none}}@media screen{.gmnoscreen{display;none}}</style><script type="text/javascript" charset="UTF-8" src="http://maps.gstatic.com/cat_js/intl/en_ALL/mapfiles/340c/maps2.api/%7Bmod_cb_api,mod_drag,mod_ctrapi,mod_scrwh,mod_zoom,mod_api_gc%7D.js"></script><script type="text/javascript" charset="UTF-8" src="http://maps.gstatic.com/intl/en_ALL/mapfiles/340c/maps2.api/mod_qdt.js"></script><style type="text/css" media="screen">#panoflash1 {visibility;hidden}</style><script type="text/javascript" charset="UTF-8" src="http://maps.gstatic.com/intl/en_ALL/mapfiles/340c/maps2.api/mod_dspmr.js"></script></head>
is it different on PC's...
john -
@driven said:
%(#008040)[<!DOCTYPE html>
<head>
<meta charset=utf-8' />
<title>BIM-Tools - webdialog</title>
<link href='" + @pathname + "/bt_dialog.css' rel='stylesheet' type='text/css' />
</head>
<body>]This is invalid. You have a doctype decleration, but no HTML tag.
HTML5 starts with:
<span class="syntaxdefault"><br /></span><span class="syntaxkeyword"><!</span><span class="syntaxdefault">DOCTYPE HTML</span><span class="syntaxkeyword">><br /><</span><span class="syntaxdefault">html</span><span class="syntaxkeyword">><br /><</span><span class="syntaxdefault">head</span><span class="syntaxkeyword">>...</</span><span class="syntaxdefault">head</span><span class="syntaxkeyword">><br /><</span><span class="syntaxdefault">body</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault"> </span>
@driven said:
on mac SU uses,
<span class="syntaxhtml"><span class="syntaxdefault"> </span><span class="syntaxkeyword"><</span><span class="syntaxdefault">html</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword"><</span><span class="syntaxdefault">head</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword"><</span><span class="syntaxdefault">title</span><span class="syntaxkeyword">></span><span class="syntaxdefault">Generate Report</span><span class="syntaxkeyword"></</span><span class="syntaxdefault">title</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword"><</span><span class="syntaxdefault">meta http</span><span class="syntaxkeyword">-</span><span class="syntaxdefault">equiv</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"Content-Type"</span><span class="syntaxdefault"> content</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"text/html; charset=utf-8"</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">/><br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword"><</span><span class="syntaxdefault">script src</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"../js/dcbridge.js"<br /></span><span class="syntaxdefault"> type</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"text/javascript"</span><span class="syntaxdefault"> language</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"JavaScript"</span><span class="syntaxkeyword">></span><span class="syntaxdefault"></script></span></span>
for it's very dynamic 'Dynamic Components', and even 'Web Textures' has no historic XHTML
That is even more historic than XHTML - it doesn't have a doctype deceleration, so its HTML3, 2 etc. It's HTML rendered in Quicks Mode.
-
@thomthom said:
This is invalid. You have a doctype decleration, but no HTML tag.
well spotted, I threw the baby out with the bath-water...
Safari, just adds it back in when it renders, so it runs fine with it missing... oops@unknownuser said:
That is even more historic than XHTML - it doesn't have a doctype deceleration, so its HTML3, 2 etc. It's HTML rendered in Quicks Mode.
The SU code is pulled directly from the rendered page in SU, so any PC specific code may be missing.
Most of Apple's html is missing the Doctype as well but renders as HTML5.
The problem on Safari is if the doctype is XHTML but the content='text/html;charset=utf-8' then any XHTML specific js will fail.
BTW. you got me rechecking html 5 meta tags and I just tested <meta http-equiv='refresh' content='30' /> and it works inside SU, so I'll try and see if the temp file can be avoided by using it instead.
john -
seemingly valid on mac
<!DOCTYPE html> <html> <head> <meta charset='UTF-8' /> <meta http-equiv='refresh' content='30' /> <title>BIM-Tools - webdialog</title> <link href='" + @pathname + "/bt_dialog.css' rel='stylesheet' type='text/css' /> </head> <body>
with this you only need the one temp file
@tmpPath=(@pathname + '/btDialog.html') @tmpFile=(File.open(@tmpPath, 'w+'))
with relative links for js, images and css, much cleaner.
I need to try this with some of my other scripts... john
-
-
@thomthom said:
In Safari?
To be more precise...
Apple WebKit + WebCore frameworks as used in Safari, Widgets and SU WebDialogs will render html 5 with or without the doctype specified.
Apple have only recently added '<!DOCTYPE html>' to the headers on their own sites [after complaints about compliance], but a lot of it's demo and pre-installed html files still have no doctype specified.If specified correctly other doctypes appear to function as intended. If the doctype is incorrect apple renders what it can as html.
I haven't fully got my head around all of this, but, it appears, that if a link, url, uri, src or href relies on having correct XHTML i.e. (application/xhtml+xml, application/xml, or text/xml), then (text/html) will produce a blank link or even a blank page.
Also XHTML as (text/html) blocks some css completely.
In the past with a few webDialogs that had failed either completely or partially, changing or omitting the doctype allowed them to work.
Although I don't fully understand it all, it's to do with there being two different DOM's that dhtml can address depending on the doctype.
Enlighten me... john
-
I find it very odd if WebKit render documents sans any doctype as HTML5. It would break old sites.
-
@thomthom said:
I find it very odd if WebKit render documents sans any doctype as HTML5. It would break old sites.
what I'm say is the opposite WebKit render documents as HTML5sans any doctype. if it has no html 5 content it won't add it...
-
@driven said:
I've got this working to the extent of mimicking your 'youTube' clip,
Great!
@driven said:
plus the minimise button which took forever to get hold of.... It was only after I noticed it's missing from your demo....
O how stupid of me, i didn't even notice... I made the video on linux(wine). The button is not working in the current version, i stripped out all the javascript. I was planning to recreate the full html on each action using
set_html
, to keep the webdialog simple. Maybe it's automatically fixed when it works on safari(I don't know if wine uses a version of IE, or the default linux browser).@driven said:
why are you using 1999 XHTML? it's 2012...
Didn't give that much thought(didn't even realize there would be differences between MAC and PC, when I started out).
I tried to keep it as common as possible. Having a DTD seemed very important, how else could a browser pick the correct way of rendering? But when i read a bit more about HTML5 it seems they left the DTD out ?! And xml-style(like <br />) is valid if you want to, but does not seem to be the preferred way...When I read a bit more about HTML5, this seems the cleanest:
<!DOCTYPE html> <html> ... </html>
I changed this in my code, no problems on IE9, I will also give it a try on IE8...
But declaring the additional<meta charset=utf-8'>
seems a good idea. And maybe a language identifier???
Would be great if google used a built-in chrome for SketchUp for PC, it beeing webkit-based would simplify things.
And then I could use the http://bimsurfer.org/ webGL IFC viewer from inside SketchUp to check the model in IFC format!@driven said:
the other was you have two different image paths
I will try your other trick for the temp files...
Thanks!
-
@driven said:
seemingly valid on mac
<meta http-equiv='refresh' content='30' />
Would this not mean that the webdialog is only refreshed every 30 seconds?
I'm planning to refresh the webdialog on every selection change in sketchup, I guess it will not work in that case, right?@driven said:
with this you only need the one temp file
@tmpPath=(@pathname + '/btDialog.html') > @tmpFile=(File.open(@tmpPath, 'w+'))
with relative links for js, images and css, much cleaner.
Is the
@pathname
in this case "/tmp" or the normal path to the SketchUp plugins folder?
Otherwise I don't really understand the "relative links". -
These is all the changes except a copy of the image file is also added to ui folder, there's a couple of puts that aren't needed...
I tried a 1second refresh, but you can't change anything that quick... also tried 3 + 3000
The 30 second refresh, allows enough time to make changes and submit, but time may be irrelevant (as long as it's enough), having this appears to allow resetting in general, which doesn't happen by default in WD's, does the ruby observer rewrite the html on selection changes? I have to re click the house to get the next elements info? The webdialog doesn't auto update that...# bt_dialog.rb # # Copyright (C) 2011 Jan Brouwer <jan@brewsky.nl> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. class Bt_dialog def initialize(project) @project = project bt_lib = @project.library # Create WebDialog instance @dialog = UI;;WebDialog.new("BIM-Tools menu", false, "bim", 243, 150, 150, 150, true) @dialog.min_width = 243 @dialog.min_height = 25 @dialog.max_width = 243 @dialog.max_height = 1200 @dialog.set_position(150,150) @pathname = File.expand_path( File.dirname(__FILE__) ) mainpath = @pathname.split('ui')[0] @imagepath = mainpath + "images" + File;;SEPARATOR @bt_lib = bt_lib @javascript = "" # create BIM-Tools selection object require 'bim-tools/lib/clsBtSelection.rb' @selection = ClsBtSelection.new(@project, self) @h_sections = Hash.new # define sections require 'bim-tools/ui/clsEntityInfo.rb' entityInfo = ClsEntityInfo.new(self) @h_sections["EntityInfo"] = entityInfo #@h_sections["ProjectData"] = ClsProjectData.new # PC Load paths will have a ';' after the drive letter. @is_mac = ($LOAD_PATH[0][1..1] != ";") puts 'mac' #@tm=(rand(9999).to_s.strip) @tmpPath=(@pathname + '/btDialog.html') @tmpFile=(File.open(@tmpPath, 'w+')) @tmpFile.rewind @tmpFile.puts html @tmpFile.rewind @dialog.show_modal @dialog.set_file(@tmpPath) if File.exists?(@tmpFile) @tmpFile.close puts 'closed' end # Attach the observer. Sketchup.active_model.selection.add_observer(MySelectionObserver.new(@project, self, entityInfo)) end def refresh @dialog.set_file( html ) end def html content = "" @h_sections.each_value do |section| content = content + section.html end return html_top + content + html_bottom end def html_top #Note that XHTML 1.0 previously defined that documents adhering to the compatibility guidelines were allowed to be served as text/html, but HTML 5 now defines that such documents are HTML, not XHTML. return " <!DOCTYPE html> <html> <head> <meta charset='UTF-8' /> <meta http-equiv='refresh' content='30' /> <title>BIM-Tools - webdialog</title> <link href='" + @pathname + "/bt_dialog.css' rel='stylesheet' type='text/css' /> </head> <body> " end def html_bottom return " </body> </html> " end def webdialog return @dialog end def close if @dialog.visible? @dialog.close end end def selection return @selection end def imagepath return @imagepath end def project return @project end # This is an example of an observer that watches the selection for changes. class MySelectionObserver < Sketchup;;SelectionObserver def initialize(project, bt_dialog, entityInfo) @project = project @bt_dialog = bt_dialog @entityInfo = entityInfo end def onSelectionBulkChange(selection) # open menu entity_info als de selectie wijzigt #js_command = "entity_info(1)" #@dialog.execute_script(js_command) #js_command = 'entity_info_width("' + width.to_s + '")' #@dialog.execute_script(js_command) @entityInfo.update(selection) #@bt_dialog.webdialog.set_html( @bt_dialog.html ) end def onSelectionCleared(selection) @entityInfo.update(selection) #@bt_dialog.webdialog.set_html( @bt_dialog.html ) end end end
-
Demo version, still contains bugs
Updated version:- Removed image path from css
- added webdialogpatch.rb(still contains the temp path)
- changed html type
John, I was just uploading this new version when i saw your post, I will compare it with the version you just posted and post another one. Thanks!
Advertisement