[Plugin] bim-tools 0.13.4(june 22, 2015)

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby brewsky » Fri Feb 24, 2012 8:42 pm

driven wrote:I got half of your script working with a little aditional ruby to write a temp file and then use .set_file on mac.

Ha! good idea! a bit of a dirty hack, but sounds like a great solution while waiting for the sketchup team to fix the direct set_html method!

Thanks! when it works I'll gladly use it!
Cheers! Jan
0
User avatar
brewsky 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby driven » Fri Feb 24, 2012 9:12 pm

brewsky wrote:waiting for the sketchup team to fix the direct set_html method!


Well, I wouldn't hold my breath for that, because it's not actually broken... It's a security feature of webkit.

The server [in our case SU] creates the WebDialog headless when you use set_html.

By default WebKit blocks local file access, if there is no record of the 'user' is making or agreeing to the request.

When you use set_file the source is coming from a 'user/local' so WebKit allows that domain access to it's own resources.

If it's only the button images then encoding base64 is dead easy on mac.

Just downloaded the latest and there are path issues... john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby thomthom » Fri Feb 24, 2012 9:15 pm

Here is my workaround for the .set_html issue:
viewtopic.php?f=180&t=39842&p=352375#p352375

The discussion it came from is here: viewtopic.php?f=180&t=39842#p351886
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby driven » Fri Feb 24, 2012 9:24 pm

OK,
on the assumption your interested,
I added $: << '/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/bim-tools' for now, to make sure the basic path gets through. Then changed the backslashes in two require statements and
this is what SU produces from your .set_html.
Code: Select all
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" style="margin:0;padding:0;height:100%:position:relative"><head>
               <title>bt_window</title>
               <link rel="stylesheet" type="text/css" href="bim-tools.css">
               <meta http-equiv="content-type" content="text/html;charset=utf-8">
      
         <style type="text/css">
            html {
               margin: 0;
               padding: 0;
            }
            body {
               font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
               font-size: 0.7em;
               background-color: #f0f0f0;
               margin: 0;
               padding: 0;
            }
            h1 {
               font-weight: bold;
               font-size: 1em;
               margin: 0;
               padding: 0.5em 0px 0px 0.8em;
               width: auto;
               height: 1.5em;
               border-bottom: 1px solid #a0a0a0;
            }
            h2 {
               font-weight: bold;
               font-size: 1em;
               width: 100%;
               height: 1em;
               margin: 0;
               padding: 0.5em 2% 0.5em 0;
            }
            hr {
               margin: 0px 3px 0px 3px;
               padding: 0;
            }
            form {
               width: 100%;
               margin: 0;
               padding: 0;
            }
            input {
               font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
               font-size: 1em;
               width: 65%;
               height: 1.5em;
               float: left;
               margin: 0.2em 0;
               padding: 0;
            }
            .input {
               display: block;
               height: 1em;
               width: 25%;
               float: left;
               margin: 0;
               padding: 0;
            }
            .submit {
               font-size: 1em;
               height: 2em;
               width: 65%;
               float: left;
               margin: 0 0 0 25%;
               padding: 0;
            }
            .minmax {
               float: right;
               margin: 0px;
               padding: 0px;
               border: 0;
            }
            .section {
               border: 0;
            }
            .input-block {
               width: 100%;
               border: 0 solid #f0f0f0;
               border-width: 0em 0.5em 0em 1.6em;
               margin: 0 0 0.2em 0;
               padding: 0;
            }
         </style>
      
         <script type="text/javascript">
            function menu_visibility(IDS){
               var section = document.getElementById(IDS).getElementsByTagName('div');
               var expand = document.getElementById(IDS).getElementsByTagName('img');
               if(section[0].style.display == 'block') {
                  section[0].style.display = 'none'
                  expand[0].src = '/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/bim-tools/images/maximize.png'
               }
               else {
                  section[0].style.display = 'block'
                  expand[0].src = '/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/bim-tools/images/minimize.png'
               }
            }
            function submitData(key) {
               value = document.getElementById(key).value;
               query = 'skp:get_data@' + key +',' + value;
               window.location.href = query;
            }
            function getData(key, value) {
               document.getElementById(key).value = value;
            }
         </script>
      
         </head>
         <body style="margin:0;padding:0;height:100%:position:relative">
      
         <div id="1" class="section">
            <img src="/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/bim-tools/images/maximize.png" class="minmax" onclick="menu_visibility(&quot;1&quot;)">
            <h1>Create</h1>
            <div class="input-block" style="display:none;">
            
         <h2>Walls</h2>
         <form action="skp:walls_from_selection@true">
               <span class="input">Height:</span>
               <input type="text" name="height" value="2600"><br>
               <span class="input">Width:</span>
               <input type="text" name="width" value="100">
            <input class="submit" type="submit" name="submit" value="Walls from selection">
         </form>
      
            </div>
         </div>
      
         <div id="2" class="section">
            <img src="/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/bim-tools/images/maximize.png" class="minmax" onclick="menu_visibility(&quot;2&quot;)">
            <h1>Export</h1>
            <div class="input-block" style="display:none;">
            
         <h2>Export to IFC</h2>
         <form action="skp:ifcexporter@true">
            <input class="submit" type="submit" name="submit" value="Export to IFC">
         </form>
      
            </div>
         </div>
      
         <div id="3" class="section">
            <img src="/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/bim-tools/images/maximize.png" class="minmax" onclick="menu_visibility(&quot;3&quot;)">
            <h1>Project</h1>
            <div class="input-block" style="display:none;">
            
         <h2>Project details:</h2>
            <span class="input">Name:</span>
            <input type="text" onchange="submitData(&quot;project_name&quot;)" id="project_name" value="Default Project"><br>
            <span class="input">Description:</span>
            <input type="text" onchange="submitData(&quot;project_description&quot;)" id="project_description" value="Description of Default Project">
         <h2>Site details:</h2>
            <span class="input">Name:</span>
            <input type="text" onchange="submitData(&quot;site_name&quot;)" id="site_name" value="Default Site"><br>
            <span class="input">Description:</span>
            <input type="text" onchange="submitData(&quot;site_description&quot;)" id="site_description" value="Description of Default Site">
         <h2>Building details:</h2>
            <span class="input">Name:</span>
            <input type="text" name="building_name" onchange="submitData(&quot;building_name&quot;)" id="building_name" value="Default Building"><br>
            <span class="input">Description:</span>
            <input type="text" onchange="submitData(&quot;building_description&quot;)" id="building_description" value="Description of Default Building">
         <h2>Author information:</h2>
            <span class="input">Role:</span>
            <input type="text" name="author" onchange="submitData(&quot;author&quot;)" id="author" value="Architect"><br>
            <span class="input">Name:</span>
            <input type="text" name="organisation_name" onchange="submitData(&quot;organisation_name&quot;)" id="o_name" value="Company"><br>
            <span class="input">Description:</span>
            <input type="text" name="organisation_description" onchange="submitData(&quot;organisation_description&quot;)" id="organisation_description" value="Company description">
      
            </div>
         </div>
      
            
         
      </body></html>

if I run this outside of sketchup it works, so I'll try my 'trick'...
john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby driven » Fri Feb 24, 2012 9:38 pm

2012-02-24 08.33.47 pm.png


the changed code so far is just this, from line 31 in bt_dialog.rb
Code: Select all
      
      # PC Load paths will have a ':' after the drive letter.
      @is_mac = ($LOAD_PATH[0][1..1] != ":")
      `rm /tmp/btDialog.html`
      @tmpPath=('/tmp/btDialog.html')
      @tmpFile=(File.open(@tmpPath, 'w+'))
      @tmpFile.rewind
      @tmpFile.puts html
      @tmpFile.rewind   
      
      
      self.walls()
      self.project_data()
      self.export()
      
      
    if  @is_mac
      @dialog.show_modal
      @dialog.set_file(@tmpPath)
   else
      @dialog.set_html( html )
      @dialog.show
      
   end
   #@tmpFile.close
   #File.delete(@tmpPath)
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby brewsky » Fri Feb 24, 2012 9:57 pm

Thanks John! It's getting somewhere!

For the new version I simplified the layout(less css), so that might already improve the looks...
I'll try to implement your trick in the new version.
And if it's a security feature... would it not be best to use the same temp file on windows? It might be marginally slower but would be a more "universal" solution...

For everyone interested... I have put another small video on youtube showing the progress on the new 0.10 version. http://youtu.be/J59EgH7LICs
bim-tools-120224.png

The video is bad quality without comments or audio and the plugin is still buggy, but as you can see in the video that it's quite easy to convert existing sketchup faces to "BIM" elements, and these already move and stretch with the source faces!
0
User avatar
brewsky 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby brewsky » Fri Feb 24, 2012 10:20 pm

For the temp file, would it be a good idea to only check the OS using something like:

Code: Select all
if ENV["TEMP"] != nil
  tempdir = ENV["TEMP"] # PC
else
  tempdir = ENV["TMPDIR"] # MAC
end
0
User avatar
brewsky 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby brewsky » Fri Feb 24, 2012 10:26 pm

thomthom wrote:Here is my workaround for the .set_html issue

Ah! I see your workaround uses something like that!
0
User avatar
brewsky 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby thomthom » Fri Feb 24, 2012 10:49 pm

This is what I use:

Code: Select all
module TT::System
  TEMP_PATH 
File.expand_pathENV['TMPDIR'] || ENV['TMP'] || ENV['TEMP'] ).freeze
end


Note the pattern that you don't need if else structure to pick between a set of variables that might be nil.

path = ENV['TMPDIR'] || ENV['TMP'] || ENV['TEMP']
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby driven » Fri Feb 24, 2012 10:56 pm

brewsky wrote:For the temp file, would it be a good idea to only check the OS using something like:
tempdir = ENV["TMPDIR"] # MAC
[/code]

I know a lot of PC coders think this is the best and easiest place to write temp file to, but it returns
/var/folders/lN/lNON23AjHxezeYON7yETPU+++TI/-Tmp-/ and is only cleared on a after a FULL shutdown and StartUp.
the other is "/tmp", which clears after a restart [i.e. all most mac users ever do, and with a lack of crashes...]

It's actually one of OSX's shortcut's to "./private/tmp" and you often see ENV["TMPDIR"] || "/tmp" used outside of SU.

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby brewsky » Fri Feb 24, 2012 10:57 pm

thomthom wrote:Note the pattern that you don't need if else structure to pick between a set of variables that might be nil.

Yeah I figured that out from your example webdialogpatch file! There still is a lot of smooth looking rubyishness to learn :)
0
User avatar
brewsky 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby brewsky » Fri Feb 24, 2012 11:03 pm

driven wrote:I know a lot of PC coders think this is the best and easiest place to write temp file to

so would you suggest something like this? (don't know how to shorten this)
Code: Select all
if ENV["TMPDIR"] != nil
  tempdir = "/tmp" # MAC
else
  tempdir = ENV["TEMP"] # PC
end


btw /tmp sounds very logical, I would use that on linux too...
0
User avatar
brewsky 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby brewsky » Fri Feb 24, 2012 11:44 pm

This is what I have now, seems to work OK on windows. Do you see any problems for mac?
Code: Select all
def initialize(bt_lib)
   
   # Create WebDialog instance
   @dialog = UI::WebDialog.new
   
   pathname = File.expand_path( File.dirname(__FILE__) )
   @walls = File.dirname(__FILE__) + "/parts/wall.rb"
   @exporter = File.join( pathname, 'IFCexporter.rb' )
   @imagepath = File.dirname(__FILE__) + "/images/"
   @bt_lib = bt_lib
   
   # replacement of set_html by a temporary html-file because of security restrictions in safari
   tmpDir = File.expand_path( ENV['TMP'] || ENV['TEMP'] || ENV['TMPDIR'] || "/tmp" )
   tmpPath = tmpDir + 'btDialog.html'
   tmpFile=(File.open(tmpPath, 'w+'))
   tmpFile.rewind
   tmpFile.puts html
   tmpFile.rewind   
      
   self.walls()
   self.project_data()
   self.export()
      
   @dialog.show
   @dialog.set_file(tmpPath)
   
end

0
User avatar
brewsky 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby thomthom » Sat Feb 25, 2012 12:35 am

You're not closing the temp file. Use a block to open it so it automatically closes.

Is the rewind really needed?
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby driven » Sat Feb 25, 2012 12:48 am

I'll try it...

to go into the Dir you need a [ / ] tmpPath = tmpDir + '/btDialog.html'
otherwise it just joins the names, is created beside the directory and won't get cleared.

It take twos clicks to create and open, i.e. click in plugins once shows nothing, click again and WD opens, just using "/tmp" is instantaneous.

you really need .show_modal on a mac... unless you write some visibility observer. [some scripts have that]

I had also added a tm=`echo $RANDOM` to create a unique name.
Can be done with ruby and Time.now variant. [TT does that]
but you also lost the file deletion at the start, so not sure if refreshing will work.

@TT I found, with other tests that the rewind was needed unless you close and use IO to read the content.
the file was being read from EOF which of course is empty.
The first one is probably redundant on a new file, but for over-writing I read it was quicker.

At the moment, I'm just looking at the basic WebDialog, but if I select a shape and click Create I get
Code: Select all
Error: #<ArgumentError: Duplicate points in array>
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/bim-tools/parts/wall.rb:165:in `add_face'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/bim-tools/parts/wall.rb:165:in `geometry'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/bim-tools/parts/wall.rb:49:in `initialize'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/bim-tools/parts/wall.rb:28:in `new'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/bim-tools/parts/wall.rb:28:in `walls_from_selection'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/bim-tools/parts/wall.rb:26:in `each'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/bim-tools/parts/wall.rb:26:in `walls_from_selection'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/bim-tools/bt_dialog.rb:107:in `walls'

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby Pixero » Sat Feb 25, 2012 9:48 am

Just found some time to test it. :thumb:
I like the workflow.
Here are some questions:
I found that copying a BIM tools entity or even the source geometry doesn't copy its BIM features. Will this work in the future?
Is there a way of setting defaults to the BIM tools like for example a offset of zero?

Looking forward to see things like windows/door openings.
I also hope that we soon will be able to have (at least a basic) export to Revit to start testing how it works in a real project. As it is now it's just something to play with.
Please don't wait with the exporter until all features are done.
0
User avatar
Pixero 
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby brewsky » Sat Feb 25, 2012 3:12 pm

driven wrote:otherwise it just joins the names, is created beside the directory and won't get cleared.

Hmmm, I have been too quick in thinking it worked, I also stripped out all parts(like the delete temp file) that gave an error on my pc...

What I have done now is just use TT's patched webdiaog class and changed a single line so it might use the /tmp folder as you suggested. Line 27 now reads:
tempdir = File.expand_path( ENV['TMP'] || ENV['TEMP'] || ENV['TMPDIR'] || "/tmp" )

And this is the current bt_dialog code:
Code: Select all
def initialize(bt_lib)
   
   # Create WebDialog instance, patched for OSX
   require 'bim-tools/lib/WebdialogPatch.rb'
   @dialog = WebDialogPatch.new
   
   pathname = File.expand_path( File.dirname(__FILE__) )
   @walls = File.dirname(__FILE__) + "/parts/wall.rb"
   @exporter = File.join( pathname, 'IFCexporter.rb' )
   @imagepath = File.dirname(__FILE__) + "/images/"
   @bt_lib = bt_lib
   @dialog.set_html( html )
   
   self.walls()
   self.project_data()
   self.export()
   
   @dialog.show
   
end



driven wrote:At the moment, I'm just looking at the basic WebDialog

I don't understand where all these geometry errors come from, nothing like that here :?

When the webdialog is fixed, I would really appreciate it if you could also try the new 0.10a version on your MAC. I think it's best to fix these kind of errors in the latest version because everything geometry-related has changed drastically.

Thanks again for all the help!
0
User avatar
brewsky 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby brewsky » Sat Feb 25, 2012 3:39 pm

Pixero wrote:Just found some time to test it.

Thanks for trying it! :)

Pixero wrote:I like the workflow.

Thanks! I try to stay as close as possible to the normal SketchUp workflow(that i like so much :) )

Pixero wrote:Here are some questions:
I found that copying a BIM tools entity or even the source geometry doesn't copy its BIM features. Will this work in the future?

Yes, surely! What i have now is a basic framework, and when I get rid of some more bugs i think it's ready for expanding functionality!
Pixero wrote:Is there a way of setting defaults to the BIM tools like for example a offset of zero?

For the "old" 0.9 version I had a config file for setting default values, I will also add this to the new version.
Pixero wrote:Looking forward to see things like windows/door openings.

Me too! :D That will be the next step, after upgrading the IFC-exporter. Openings also worked pretty well in the 0.9 version, based on standard "cutting components".

Pixero wrote:I also hope that we soon will be able to have (at least a basic) export to Revit to start testing how it works in a real project. As it is now it's just something to play with.
Please don't wait with the exporter until all features are done.

That's also what I'm trying to do to get the best results. I don't want to make too many features at the same time. Just small steps, and every new function first needs IFC export before starting on the next...
0
User avatar
brewsky 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby driven » Sat Feb 25, 2012 4:46 pm

brewsky wrote: I would really appreciate it if you could also try the new 0.10a version on your MAC.

where, exactly [i.e. a direct link] do I get 0.10a, I've been to your site a few times and keep getting the other??

probably just being dim...

Also, I want to explain the basic difference between .show an .show_modal on mac.

with .show when you click off the dialog it disappears behind the active window. The only way to retrieve it is to have code that brings it back after an action ends [only works if your still in the same tool] or move the window out of the way to click it back to 'front'.

with .show_modal the window stays in front [while in 'SU' context], so you can see it while you do other things in the tool or even if you change tools. The 'downside is it requires a click to 'bring to focus' and a second click to 'do', unless you 'Cmd Click' which bypasses the focus requirement.

If a tool 'highjacks' SU and blocks changing tools etc. [as this does currently, but I hope will be fixed], it is possible to to use !visable? then .show after each action, but show_modal is easier.

The main point I'd like to make is there is no problem having platform conditional methods in a cross platform script.

SU does it all the time, after all mac SU is Cocoa, a different version of Ruby, and different browser engine, so using specific mac code is the right way to do mac things... maybe, my code wasn't wrapped properly to hide the system calls from PC's but that shouldn't be to hard [says the ruby nuubee]

post a link and I'll try and do some more testing later
john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby brewsky » Sat Feb 25, 2012 11:46 pm

driven wrote:where, exactly [i.e. a direct link] do I get 0.10a

I'm sorry! I could have known it would get lost in the thread... I posted it somewhere halfway the discussion because it's only a bit of an unstable preview. This is the link to the post:
[url]http://forums.sketchucation.com/viewtopic.php?
f=323&t=34007&sid=a1cea85c17015237152249205e1c68d2&start=45#p387104[/url]

driven wrote:The main point I'd like to make is there is no problem having platform conditional methods in a cross platform script.
I think I had the wrong idea about the SketchUp API, it's documented as a single cross-platform API, but in reality the same method seems to have a different result calling it on PC or MAC. If the result differs, it might be better to also name them differently?
I guess, when this is the case for more API calls, then conditional methods is indeed the way to go, especially
for this show / show_modal case(I got an empty window using modal on PC)

driven wrote:maybe, my code wasn't wrapped properly to hide the system calls from PC's but that shouldn't be to hard [says the ruby nuubee]
I really appreciate your help fixing the code for Mac. The reason I picked TT's custom web dialog class is because I can easily copy that to the other version of my plugin.
I want it to work as good as possible for Mac and PC. Wouldn't it be best to further optimise TT's class together so everyone can use it for their projects? Like add the /tmp folder and maybe the rewind option you used?
0
User avatar
brewsky 
PluginStore Author
PluginStore Author
 

Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

Postby Dan Rathbun » Sun Feb 26, 2012 5:39 am

You cannot get away from platform specific quirks (oddities, etc.) As John said, Mac uses the obsolete Ruby v1.8.5-p0, and Safari for webdialogs. PC uses Ruby v1.8.6-p287, and MSIE WebBrowser.

The first step is to be sure these global boolean constants are defined:
Code: Select all
MAC = ( Object::RUBY_PLATFORM =~ /(darwin)/i ? true : false )
OSX = MAC unless defined?(OSX)
WIN = ( not MAC ) unless defined?(WIN)
PC = WIN unless defined?(PC)
Using boolean constants is MUCH faster that using string platform name constants !!

On the Mac, "modal" translates to "always on top", but does NOT cause App blocking, like it does on PC.
Then in your code:
Code: Select all
MAC ? dlg.show_modal() : dlg.show()
or
Code: Select all
if WIN
  show()
else
  show_modal()
end


Also.. Ruby is a dynamic language. It can be defined and configured at runtime. Some coders prefer to have Mac definitions and PC definitions in separate files. (A SINGLE module or class definition, can span MULTIPLE files. They do NOT need to be in ONE file.)
Code: Select all
module BIMTOOLS

  require('bimtools/lib/mac_methods.rb') if MAC
  require('bimtools/lib/win_methods.rb') if WIN

  # ... more code here that relys upon methods loaded
  # into THIS module by one of the two files above.

end

... BUT some prefer to DYNAMICALLY define platform specific methods in the same file (they think it may be easier to maintain.) Ex:
Code: Select all
module BIMTOOLS

  # define a "info" module function here:
  #
  if MAC
    def self.info()
      #
      # ... code specific the Mac/OSX platform
      #
    end
  elsif WIN
    def self.info()
      #
      # ... code specific the Windows platform
      #
    end
  else
    # perhaps raise an exception here ?
  end

    # ... more code here that relys upon
    #  methods defined per platform above.

end


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.)
0
    I'm not here much anymore. But a PM will fire email notifications.
    User avatar
    Dan Rathbun 
    PluginStore Author
    PluginStore Author
     

    Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

    Postby Dan Rathbun » Sun Feb 26, 2012 5:46 am

      Also in the [ Code Snippets ] sticky thread, I am endevouring to collect links on Platform Specific Quirks and Issues.

      see: [Info] Platform Issues / Differences / Specifics
      0
        I'm not here much anymore. But a PM will fire email notifications.
        User avatar
        Dan Rathbun 
        PluginStore Author
        PluginStore Author
         

        Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

        Postby thomthom » Sun Feb 26, 2012 12:33 pm

        Some notes on WebDialog and the differences between platforms: viewtopic.php?f=180&t=23445
        0
        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund
        User avatar
        thomthom 
        PluginStore Author
        PluginStore Author
         

        Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

        Postby Pixero » Mon Feb 27, 2012 9:00 am

        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/Bimtest ... eport.html
        0
        User avatar
        Pixero 
         

        Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

        Postby brewsky » Mon Feb 27, 2012 8:56 pm

        Pixero wrote: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/Bimtest ... eport.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?
        0
        User avatar
        brewsky 
        PluginStore Author
        PluginStore Author
         

        Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

        Postby brewsky » Mon Feb 27, 2012 9:28 pm

        Dan Rathbun wrote:You cannot get away from platform specific quirks (oddities, etc.)

        Dan Rathbun wrote: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.
        Code: Select all
        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 ;)
        0
        User avatar
        brewsky 
        PluginStore Author
        PluginStore Author
         

        Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

        Postby driven » Mon Feb 27, 2012 11:53 pm

        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
        <!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
        Code: Select all
        @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
        0
        learn from the mistakes of others, you may not live long enough to make them all yourself...

        driven 
        PluginStore Author
        PluginStore Author
         

        Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

        Postby thomthom » Tue Feb 28, 2012 12:18 am

        driven wrote: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 wrote: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/>
        0
        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund
        User avatar
        thomthom 
        PluginStore Author
        PluginStore Author
         

        Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

        Postby Jim » Tue Feb 28, 2012 12:27 am

        IE 9 does not run on Windows XP, which is still the world's most-used OS; although Win 7 is catching up.
        0
        Hi

        Jim 
        Global Moderator
         

        Re: [Plugin] bim-tools 0.9.2 (14 Dec 2011)

        Postby driven » Tue Feb 28, 2012 12:31 am

        on mac SU uses,
        Code: Select all
        <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
        Code: Select all
        <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&amp;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&amp;key=ABQIAAAA5El50zA4PeDTEMlv-sXFfRSsTL4WIgxhMZ0ZK_kHjwHeQuOD4xTdBhxbkZWuzyYTVeclkwYHpb17ZQ&amp;v=2.182&amp;callback=google.loader.callbacks.maps&amp;async=2&amp;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
        0
        learn from the mistakes of others, you may not live long enough to make them all yourself...

        driven 
        PluginStore Author
        PluginStore Author
         

        SketchUcation One-Liner Adverts

        by Ad Machine » 5 minutes ago



        Ad Machine 
        Robot
         

        PreviousNext


         

        Return to Plugins

        Who is online

        Users browsing this forum: b4g14n4, bils, Google Bot, m2b3, paulasalles1, resyybw and 15 guests

        Visit our sponsors: