sketchucation logo sketchucation
    • Login
    1. Home
    2. tt_su
    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!
    ⚠️ Important | Libfredo 15.8b introduces important bugfixes for Fredo's Extensions Update
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1,034
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: C++ using swig

      @garry k said:

      Additionally I am experiencing a link error when trying to build SUEX_HelloWorld and SUEX_UsingSWIG
      I'm guessing that the compiler can't find the SDK.

      You don't need SWIG to make a Ruby C/C++ Extensions. If you just want to use the C API licensing features you just need the basics of what SUEX_HelloWorld demonstrate and then add the C API headers and libs to the project.

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Retrieving bounding box corners Point3d

      I wrote an extension a few years ago that will draw the bounding box as edges: https://bitbucket.org/thomthom/draw-boundingbox/src/f08e7f6efba7712b56a535e4dae4ade3f9bde7af/src/tt_draw_bb/core.rb?at=master

      You can rip that code if you want.

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: [Plugin] 3D Text Editor

      @tig said:

      I had a sneaking suspicion that his Douglas-Peucker was for curve-simplification...

      That's correct - I used it with the intent to simplify contour data from imported CAD drawings.

      posted in Plugins
      tt_suT
      tt_su
    • RE: [Plugin] TT_Lib²

      How are you installing the extension?
      Are you using a User or Administrator account?

      posted in Plugins
      tt_suT
      tt_su
    • RE: SU2015 gives NoMethodError for Length class #abs method

      @archidave said:

      but in SU 2015;
      > 2.m.abs
      gives the NoMethodError

      This is pretty bad (it has broken my plugin for SU 2015) and means I now need to go hunting through the code for all occurrences of <Length>.abs replacing them with <Length>.to_f.abs and building-in extra validation where the class is not intrinsically known, just in case there could be a Length instead of a Float.

      The Length class used to be a subclass of Float. However this isn't really possible in Ruby, but from the Ruby C API this was hacked together a way to do so.
      When we added 64bit support in SU2015 this broke because the data structures where different. So we had to re-implement Length by forwarding the methods to Float. Initially this used the Ruby Standard Library, but due to another bug in Ruby where the StdLib would not always load if there was unicode characters in the user's username the StdLib would fail and the Length class would not properly initialize. There was also a bug in SU at some point where the StdLib would fail to load if the user started SketchUp by double clicking an SKP file.
      We later corrected the new Length implementation to not use StdLib so it would not fail if the StdLib failed to load. And we also fixed the bug regarding starting SU via SKP files.

      But those fixes should be in SU2015M2 - so I don't understand why you'd experience such problems. I am not able to reproduce your error.

      Can you try without any extensions enabled - just so we can eliminate that possibility?

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Distance between two points / optimization

      So - I did this for Vertex Tools. Any implementation is Ruby was slow. I then wrote a tiny Ruby C extension and the performance was 100+ times faster than the fastest Ruby implementation I had.
      There is simply so much overhead by Ruby itself that this kind of stuff is better passed off to C - Even with the overhead of converting the point set to C structures and back to Ruby at the end it just blows away pure Ruby computation.

      And as it's been mentioned, you want to avoid square root. Since you want to filter point by a given distance, convert the distance to the power of it self and do the distance calculation without square root. Gives your calculation an extra boost.

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Escaping out of editing a component

      Note that if only close the currently open instance. If you are deeply nested you need to loop until you are back in the root - (if that's what you desire). And before SU2014 the method was bugged and could mess up geometry if the close was undone. (The method actually creates an undo item)

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Fixing the Undo-stack (and others!)

      @joclo said:

      I changed the condition from if @face_array[0] && @face_array[0].material == nil and got a Error: #<SystemStackError: stack level too deep>.. Ouch. I believe this is because of excessive recursion, the model comes back with smoothed surfaces half finished so I don't think there's an infinite loop in there. I presume this means I need to rewrite the code algorithmically?

      Recursive methods to traverse geometry is likely to cause stack overflow as you'll be recursing thousands of times. Geometry walkers need to "unroll" their loop to avoid this.

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Plugins Locations

      Hmm... the error actually complains about a file not found...

      Could not find included file 'sketchupConnector'

      And an undefined method...

      Hard to tell without knowing anything about the extension. But I'd trace down the missing method and file.

      Have you tried the Ruby Debugger - letting you step through Ruby code?
      https://github.com/SketchUp/sketchup-ruby-debugger

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: C++ using swig

      I'm not familiar with SWIG I'm afraid. Bugra set up the SWIG example - I can ping him if it needs be.

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Plugins Locations

      SketchUp changed from Ruby 1.8 to Ruby 2.0 in version 2014. So you need to make sure all binaries are compatible with the updated Ruby interpreter.

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Odd behavior of Draw

      My bad. What TIG said.

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Odd behavior of Draw

      View.invalidate marks the view for redraw but it might not be updated immediately. It'll be throttled.
      View.redraw force a redraw immediately.

      View.invalidate should be the first choice - View.redraw should be used when you know you really need it.

      I've had to use view.redraw in cases where I make mesh updates in the mouse events (for live mesh preview). There I had to force a redraw otherwise things would appear choppy. But even then I'd try to manually throttle view.redraw.

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: &lt;canvas&gt;

      @msp_greg said:

      e, do you (or Thom, or anyone on a mac) have any idea why this happens? FWIW, the main feature of my plugin is exporting and importing files with other software. Those software packages only run on a pc. Hence, I've never felt a need to make my plugin run on a mac...

      I think I've seen this when you hook into the load event. Though hooking into the DOMContentLoaded appear to not suffer from this. Hooking into this might differ from browser to browser (glares at IE). (This is where frameworks like jQuery comes to it's good nature.)

      @driven said:

      I agree about jQuery as it's hard to debug in SU...

      I've been meaning to write an article on this topic. With the web console under OSX (thanks to you) and using Visual Studio's JS debugger under Windows debugging is actually quite nice.

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: [SOLVED]Reloading Component via DefinitionsList.load Problem

      @jim said:

      Hmm, if you add an empty Group instead of a CPoint it also works; and then you may need to worry less about cleaning up since the empty group will get swept away.

      Good point. (No pun intended)

      I'll file up the issue internally so we'll look into it.

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Catch Load Errors

      One thing to beware of is that Sketchup::require/load annoyingly doesn't raise ruby errors - but instead just output the error text. So you might want to hook into $stdout and $strerr to catch that as well. (This is something I suggest only because you mention it was for a personal tool.)

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: [SOLVED]Reloading Component via DefinitionsList.load Problem

      Have you tried to "touch" the old definition first by making a small change like entities.add_cpoint(ORIGIN) then trying to load the new?

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Ruby code to retrive sketchup version of a model

      unpack("m*").pack("m") gobbles up some characters. Here's an old snippet I used in the past to sniff out the version number: (Works for Ruby 1.8 and 2.0)

      <span class="syntaxdefault"><br />module&nbsp;Example<br /><br />&nbsp;&nbsp;def&nbsp;self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">read_skp_version</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">file</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;Get&nbsp;the&nbsp;size&nbsp;of&nbsp;the&nbsp;file&nbsp;ID&nbsp;block;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">id_size&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">IO</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">read</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">file</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">3</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">unpack</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'C'</span><span class="syntaxkeyword">)[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]&nbsp;*&nbsp;</span><span class="syntaxdefault">2<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;=>&nbsp;28<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Get&nbsp;the&nbsp;size&nbsp;of&nbsp;the&nbsp;file&nbsp;version&nbsp;block;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">version_size&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">IO</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">read</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">file</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">4&nbsp;</span><span class="syntaxkeyword">+&nbsp;</span><span class="syntaxdefault">id_size&nbsp;</span><span class="syntaxkeyword">+&nbsp;</span><span class="syntaxdefault">3</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">unpack</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'C'</span><span class="syntaxkeyword">)[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]&nbsp;*&nbsp;</span><span class="syntaxdefault">2<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;=>&nbsp;20<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Get&nbsp;the&nbsp;version&nbsp;block&nbsp;data.&nbsp;This&nbsp;will&nbsp;be&nbsp;UTF-16LE&nbsp;encoded.&nbsp;Since&nbsp;Ruby&nbsp;1.8<br />&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;doesn't&nbsp;have&nbsp;the&nbsp;encoding&nbsp;methods&nbsp;we&nbsp;hack&nbsp;it&nbsp;by&nbsp;zapping&nbsp;out&nbsp;all&nbsp;the&nbsp;zero&nbsp;bytes<br />&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;in&nbsp;the&nbsp;data&nbsp;string&nbsp;which&nbsp;will&nbsp;give&nbsp;us&nbsp;a&nbsp;regular&nbsp;ASCII&nbsp;string.&nbsp;This&nbsp;works<br />&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;because&nbsp;we&nbsp;know&nbsp;the&nbsp;version&nbsp;string&nbsp;is&nbsp;within&nbsp;the&nbsp;ASCII&nbsp;range.<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">version&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">IO</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">read</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">file</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">version_size</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">4&nbsp;</span><span class="syntaxkeyword">+&nbsp;</span><span class="syntaxdefault">id_size&nbsp;</span><span class="syntaxkeyword">+&nbsp;</span><span class="syntaxdefault">4</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">gsub</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"\x00"</span><span class="syntaxkeyword">,</span><span class="syntaxstring">""</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;=>&nbsp;{15.1.106}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Extract&nbsp;the&nbsp;version&nbsp;components.<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">version</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">match</span><span class="syntaxkeyword">(/\{(\</span><span class="syntaxdefault">d</span><span class="syntaxkeyword">+)\.(\</span><span class="syntaxdefault">d</span><span class="syntaxkeyword">+)\.(\</span><span class="syntaxdefault">d</span><span class="syntaxkeyword">+)\}/).</span><span class="syntaxdefault">captures</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">map&nbsp;</span><span class="syntaxkeyword">{&nbsp;|</span><span class="syntaxdefault">x</span><span class="syntaxkeyword">|&nbsp;</span><span class="syntaxdefault">x</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_i&nbsp;</span><span class="syntaxkeyword">}<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;=>&nbsp;[15,&nbsp;1,&nbsp;106]<br />&nbsp;&nbsp;</span><span class="syntaxdefault">end<br /><br />end&nbsp;</span><span class="syntaxcomment">#&nbsp;module<br /><br />#&nbsp;Example&nbsp;usage;<br /></span><span class="syntaxdefault">major</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">minor</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">revision&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">Example</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">read_skp_version</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">)<br />&nbsp;</span><span class="syntaxdefault"></span>
      
      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Arrange component names

      @siim11s said:

      I then have a component_list ordered as "last modified", right?

      The order is in no guarantied order. It doesn't change when definitions are modified.

      @siim11s said:

      I hope you understand what I'm trying to do

      I'm afraid it's a bit unclear to me.
      Are you trying to rename all definitions?
      What is the expected result?

      @siim11s said:

      Now when I need to make a new component and place it as number "052" for example - I'd need to rename all the components that follow.

      Why do you need to rename all the other components to place a new component?

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: SketchUp RUBY API Wishlist [way of coding wishes, please]

      @tommyk said:

      I did NOT think of that! For my purposes, this may do the trick. Thanks!

      Beware that users might not like that extensions arbitrary change the settings of the style they have set up.

      posted in Developers' Forum
      tt_suT
      tt_su
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 51
    • 52
    • 4 / 52