sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

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

    Scheduled Pinned Locked Moved Plugins
    206 Posts 37 Posters 218.9k Views 37 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • thomthomT Offline
      thomthom
      last edited by

      @brewsky said:

      Too bad I can't test it myself, the dialog is a webdialog, only tested on internet explorer.
      I can however download safari for PC to test the javascript/html, I'll look into that.

      I had a quick look at the code - see it uses .set_html - which is bugged under OSX after Safari 5.0.6 update.
      Made inline-comment in the Google repository for file: bt_dialog.rb

      also made a couple of other notes.

      Thomas Thomassen β€” SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • brewskyB Offline
        brewsky
        last edited by

        @thomthom said:

        I had a quick look at the code - see it uses .set_html - which is bugged under OSX after Safari 5.0.6 update.

        Too bad .set_html is bugged, I rather liked this method for updating my webdialog. Do you have any suggestions on how to replace it? The only thing I can think of is a whole lot of javascript...

        @thomthom said:

        Made inline-comment in the Google repository for file: bt_dialog.rb
        also made a couple of other notes.

        Thanks for looking into it, unfortunately I can't seem to find your comments in the google-code project. πŸ˜• I don't have any experience yet with the code review functionality. Can you point me in the right direction? Any comments are most welcome!

        Sketchup BIM-Tools - http://sketchucation.com/forums/viewtopic.php?p=299107

        1 Reply Last reply Reply Quote 0
        • D Offline
          driven
          last edited by

          @brewsky said:

          Too bad .set_html is bugged, I rather liked this method for updating my webdialog. Do you have any suggestions on how to replace it? The only thing I can think of is a whole lot of javascript...

          I got half of your script working with a little aditional ruby to write a temp file and then use .set_file on mac.
          I just realised it was with the oldest version, so if I try again with the latest it may all work...
          L'll let you know.
          john

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

          1 Reply Last reply Reply Quote 0
          • brewskyB Offline
            brewsky
            last edited by

            @driven said:

            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

            Sketchup BIM-Tools - http://sketchucation.com/forums/viewtopic.php?p=299107

            1 Reply Last reply Reply Quote 0
            • D Offline
              driven
              last edited by

              @brewsky said:

              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

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

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

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

                The discussion it came from is here: http://forums.sketchucation.com/viewtopic.php?f=180&t=39842#p351886

                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • D Offline
                  driven
                  last edited by

                  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.

                  <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

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

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    driven
                    last edited by

                    I'll look at the css...

                    the changed code so far is just this, from line 31 in bt_dialog.rb

                    		
                    		# 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)
                    

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

                    1 Reply Last reply Reply Quote 0
                    • brewskyB Offline
                      brewsky
                      last edited by

                      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!

                      Sketchup BIM-Tools - http://sketchucation.com/forums/viewtopic.php?p=299107

                      1 Reply Last reply Reply Quote 0
                      • brewskyB Offline
                        brewsky
                        last edited by

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

                        
                        if ENV["TEMP"] != nil
                          tempdir = ENV["TEMP"] # PC
                        else
                          tempdir = ENV["TMPDIR"] # MAC
                        end
                        
                        

                        Sketchup BIM-Tools - http://sketchucation.com/forums/viewtopic.php?p=299107

                        1 Reply Last reply Reply Quote 0
                        • brewskyB Offline
                          brewsky
                          last edited by

                          @thomthom said:

                          Here is my workaround for the .set_html issue

                          Ah! I see your workaround uses something like that!

                          Sketchup BIM-Tools - http://sketchucation.com/forums/viewtopic.php?p=299107

                          1 Reply Last reply Reply Quote 0
                          • thomthomT Offline
                            thomthom
                            last edited by

                            This is what I use:

                            <span class="syntaxdefault">module&nbsp;TT</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">System<br />&nbsp;&nbsp;TEMP_PATH&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">expand_path</span><span class="syntaxkeyword">(&nbsp;</span><span class="syntaxdefault">ENV</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'TMPDIR'</span><span class="syntaxkeyword">]&nbsp;||&nbsp;</span><span class="syntaxdefault">ENV</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'TMP'</span><span class="syntaxkeyword">]&nbsp;||&nbsp;</span><span class="syntaxdefault">ENV</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'TEMP'</span><span class="syntaxkeyword">]&nbsp;).</span><span class="syntaxdefault">freeze<br />end</span>
                            

                            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']

                            Thomas Thomassen β€” SketchUp Monkey & Coding addict
                            List of my plugins and link to the CookieWare fund

                            1 Reply Last reply Reply Quote 0
                            • D Offline
                              driven
                              last edited by

                              @brewsky said:

                              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

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

                              1 Reply Last reply Reply Quote 0
                              • brewskyB Offline
                                brewsky
                                last edited by

                                @thomthom said:

                                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 πŸ˜„

                                Sketchup BIM-Tools - http://sketchucation.com/forums/viewtopic.php?p=299107

                                1 Reply Last reply Reply Quote 0
                                • brewskyB Offline
                                  brewsky
                                  last edited by

                                  @driven said:

                                  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)

                                  
                                  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...

                                  Sketchup BIM-Tools - http://sketchucation.com/forums/viewtopic.php?p=299107

                                  1 Reply Last reply Reply Quote 0
                                  • brewskyB Offline
                                    brewsky
                                    last edited by

                                    This is what I have now, seems to work OK on windows. Do you see any problems for mac?

                                    
                                    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
                                    
                                    
                                    

                                    Sketchup BIM-Tools - http://sketchucation.com/forums/viewtopic.php?p=299107

                                    1 Reply Last reply Reply Quote 0
                                    • thomthomT Offline
                                      thomthom
                                      last edited by

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

                                      Is the rewind really needed?

                                      Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                      List of my plugins and link to the CookieWare fund

                                      1 Reply Last reply Reply Quote 0
                                      • D Offline
                                        driven
                                        last edited by

                                        I'll try it...

                                        to go into the Dir you need a [ / ] tmpPath = tmpDir + '**%(#BF0000)[/]**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

                                        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

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

                                        1 Reply Last reply Reply Quote 0
                                        • PixeroP Offline
                                          Pixero
                                          last edited by

                                          Just found some time to test it. πŸ‘
                                          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.

                                          1 Reply Last reply Reply Quote 0
                                          • brewskyB Offline
                                            brewsky
                                            last edited by

                                            @driven said:

                                            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:

                                            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 said:

                                            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!

                                            Sketchup BIM-Tools - http://sketchucation.com/forums/viewtopic.php?p=299107

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 6
                                            • 10
                                            • 11
                                            • 4 / 11
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement