sketchucation logo sketchucation
    • Login
    1. Home
    2. MartinRinehart
    3. Posts
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download
    M
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 131
    • Posts 766
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Assigning Event Handlers in JS-Written UI, Painlessly

      @thomthom said:

      I always keep the links to JS in the HEAD.

      That risks being bitten by The Bug from Hell, which you definitely don't want. Also, see http://www.amazon.com/High-Performance-Web-Sites-Essential/dp/0596529309 . Formerly Yahoo's front-end guru, Souder is now with Google.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: [Request] Update to layer and scene manager

      Am working along those lines, but not exactly as you want. Look for VisMap, soon (I hope).

      posted in Plugins
      M
      MartinRinehart
    • RE: Cant flip

      @remus said:

      ... just use the scale tool to flip it.

      Start scaling by pushing a handle toward smaller. Type "-1" in the VCB.

      posted in SketchUp Discussions
      M
      MartinRinehart
    • RE: Not Caching Code

      @thomthom said:

      Meta tags only goes in the HEAD - as the very first tags.

      I agree, except:

      http://www.htmlgoodies.com/beyond/reference/article.php/3472881

      posted in Developers' Forum
      M
      MartinRinehart
    • Assigning Event Handlers in JS-Written UI, Painlessly

      If your WebDialog's UI is a function of the model's content, you will need to use JavaScript to create the UI. This is easy if you follow this model.

      
      <!-- a.html -->
      <html> <body onload=init()>
      	
      <script> 
          var giggle = function() { alert('That tickles!') }
      
          function init() {
          	var btn = document.createElement( 'button' );
          	btn.innerHTML = 'Click Me!';
          	document.body.appendChild( btn );
          	btn.onclick = giggle;
          }
      </script>
      
      </body> </html>
      
      

      You can't document.write() your UI and you can't assign event handlers before you attach the listeners to the DOM. Your script, or your link to a .js file, should be the last thing before </body> (never in the <head> section).

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Assigning Event Handlers in JS-written UI

      @martinrinehart said:

      The only problem is, nothing happens when you click the buttons. Presumably a browser bug (v8).

      Somebody help me out here. I hate being stupid in public.

      This code doesn't work:

      
      	var b2 = d.createElement( 'input' );
      	b2.type = 'checkbox';
      	b2.onclick = clicker2;
      	d.body.appendChild( b2 );
      
      

      If you reverse the last two lines, appending to body before assigning to onclick, the onclick handler starts to work. (This after many tries in Chrome, Firefox, Opera and that other browser. My Google search engine is starting to say, "Oh, please! Not again!")

      I now have a JS-generated checkbox that can call an onclick handler and I am going back to work on my Ruby. Anyone have an explanation for the above "gotcha"?

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Assigning Event Handlers in JS-written UI

      @martinrinehart said:

      but I'm skeptical

      This works:

      <!-- a.html -->
      <html> <body onload=init()>
      	
      <script src='a.js'> </script>
      
      </body> </html>
      

      Where the DOM is created this way:

      // a.js
      
      var clicker  = function() { alert('That tickles!'); }
      function clicker2() { alert('That tickles, too!'); }
      
      function init() {
      	var d = document;
      
      	var b1 = d.createElement( 'button' );
      	b1.innerHTML = 'Click me!';
      	b1.onClick = clicker;					
      	d.body.appendChild( b1 );
      
      	var b2 = d.createElement( 'button' );
      	b2.innerHTML = 'Me too!';
      	b2.onClick = clicker2;					
      	d.body.appendChild( b2 );
      
      alert( b1.onClick + '\n\n' + b2.onClick );
      }
      
      

      The only problem is, nothing happens when you click the buttons. Presumably a browser bug (v8). Workaround?

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Not Caching Code

      @thomthom said:

      Ctrl+F5 doesn't work?

      Thanks for your help, but Ctrl+F5 doesn't do it. Neither does the meta. Neither does the meta if you insert it before and after the body, per Joe Burns.

      However, one thing works! Do not load the HTML in the browser (tho that seems sensible if you want to test HTML). Use your model's Ruby code to load it in a WebDialog. Then your cycle is edit, load ruby, view changes.

      This works with script in the HTML or with script in a linked .js.

      In conclusion, Google (hello, Google? you there Google?) has chosen its browser without much wisdom. (That's more polite than my actual feelings.) The only better choice would be any other choice. PLEASE!

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Assigning Event Handlers in JS-written UI

      @thomthom said:

      From working with website before I never use document.write, but instead add elements using the DOM functions as that always works.

      Thank you.

      "... always works." I pray you are right, but I'm skeptical.

      Martin

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Direction of Pushpull Is ?

      @martinrinehart said:

      Result: two rectangular parallelepipeds (that's pretentious for "box"), both with their blue dimensions ranging from 0 to 10.

      Totally wrong! Went back and did it again, carefully, being sure to orbit around and under. Jim is right. Sorry, Jim.

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Calculate the angle of an ellipse in an ortho view

      Is that ellipse an ellipse, or is it a circle viewed at an angle?

      posted in Developers' Forum
      M
      MartinRinehart
    • Not Caching Code

      To test in a certain browser (whose name must not be mentioned) I am constantly frustrated by the fact that my JS is cached and the only way to test a change is to reload the browser. Is there a way to say "reload, even the JS"?

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Assigning Event Handlers in JS-written UI

      Could it be possible that I am the first one trying to make a UI that depends on the content of the model? Anyone?

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Direction of Pushpull Is ?

      @chris fullmer said:

      Well that's odd. I could have sworn that a face on the ground plane will always head upwards.

      Me too. I just rectangled twice on the ground plane, reversed one of the faces.

      This, from memory, was what I typed into the Ruby Console:

      
      ents = Sketchup.active_model.entities
      f = []
      ents.each { |e| f.push(e) if e.is_a? Sketchup;;Face }
      f.each { |f| f.pushpull(10) }
       
      

      Result: two rectangular parallelepipeds (that's pretentious for "box"), both with their blue dimensions ranging from 0 to 10.

      So now we've really screwed this one down: always toward the outside face, except on the ground plane, but the exception doesn't apply to Jim.

      Anyone happy with this?

      posted in Developers' Forum
      M
      MartinRinehart
    • Assigning Event Handlers in JS-written UI

      I'm trying to write what I thought would be an easy Ruby. It's beginning to feel otherwise. At present I'm stumped by the following.

      My Ruby depends on getting a list of scenes and layers from the model. It then draws the UI, which is at heart an array of checkboxes, one for each layer/scene intersection. Hence the UI cannot be built into the HTML, it has to be generated by JavaScript.

      I've distilled down to a simple HTML, .js combo. I've discovered that you can't "document.write" the same text that would work from HTML if you want to include an onclick handler. The workaround I've been fiddling with is to create the checkbox, getElementById it and attach a reference to its onclick property. The following code shows this with buttons. The problem is, this code runs fine in Opera, but not in the browser whose name must never be spoken.

      <!-- a.html -->
      <html>
      <body onload='init()'>
      	<script src='a.js'> </script>
      </body>
      </html>
      
      // a.js
      
      var clicker = function() {
      	alert( 'That tickles!' );
      }
      
      var clicker2 = function() {
      	alert( 'That tickles, too!' );
      }
      
      function init() {
      	document.write( '<button id=b1> Click </button>' );
      	document.getElementById( 'b1' ).onclick = clicker;
      
      	// this doesn't work;
      	document.write( 
      		'<button id=b2 onclick=clicker2()> Click me, too </button>' )
      
      	// unless you add;
      	document.getElementById( 'b2' ).onclick = clicker2;
      }
      
      

      I do not have enough hair left to continue pulling it out at the present rate. Help!

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Direction of Pushpull Is ?

      @jim said:

      I think it was trick question.

      No quite. I knew, before I asked, that the answer was "positive distance is often toward the outside of the face" and that a fresh rectangle in the rg plane was an exception. What I didn't know was if the latter was THE exception or one member of a class of exceptions.

      posted in Developers' Forum
      M
      MartinRinehart
    • Direction of Pushpull Is ?
      ents = Sketchup.active_model.entities
      f = ents.add_face ...
      f.pushpull x
      
      

      Which way does that pushpull?

      posted in Developers' Forum
      M
      MartinRinehart
    • RE: Brilliant-Cut Ruby

      @escapeartist said:

      I put the diamond inside a cylinder, and then shrank the cylinder until the diamond's edge protruded a little outside of it.

      I made a 32-sided polygon, 20' radius and Push/Pulled it up a foot. Deleted 30 sides. Turned the axes so one face was in the rg plane, laid guides and drew lines. Ditto the other face. Last, grouped and used a moving/copying rotate to finish the girdle. A neat, Sunday-afternoon modeling hack.

      I'll be using this to decorate my UI in the other kind of ruby if I can ever finish fighting through the bugs.

      http://www.MartinRinehart.com/models/graphics/sketchup_rubies_icon.gif

      Now I've got a ruby, 40' around reduced to an 88x64 px icon.

      posted in Gallery
      M
      MartinRinehart
    • RE: Brilliant-Cut Ruby

      @escapeartist said:

      I made a diamond a while back, copied the cut from a jeweler's website.

      That render is magnificent.

      Yes, it is brilliant cut.

      You've got me beat in too many ways! Your kite facets are real facets. I faked my not quite coplanar ones by hiding the line that divides each into two triangles. Ditto on the bottom. Your girdle's nicer than mine, too. (That's the wee edge that separates top from bottom.)

      Hat removed. Bowing in your direction.

      posted in Gallery
      M
      MartinRinehart
    • 1 / 1