sketchucation logo sketchucation
    • Login
    1. Home
    2. Myhand
    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.6a introduces important bugfixes for Fredo's Extensions Update
    M
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 89
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: [Plugin] Material_Maintenance v2.2 - 2013-01-13

      @cmd said:

      Myhand,

      Sorry.. I replaced the wrong file. Here is what I get in the Ruby console with your debug script after I launch the tool.

      @unknownuser said:

      calling function >>refreshMaterialsÂ<<
      !!!!! - IN refreshMaterials !!!!!
      String Time = 3.0e-06
      Total Entities = 0

      I hope this helps

      CMD

      Excellent this helps a lot. It tells us that somewhere the function name gets corrupted between where it is hardcoded in the javascript to where it enters the Ruby environment.

      Was that the whole output? Were there no other lines following the below patterns? I would have expected at least one more set, probably before the above lines.

      calling function >>xxxx<<
      !!!!! - IN xxxx !!!!!

      Where xxxx is any name.

      I suspect driven might be correct. Let me give this some thought.

      posted in Plugins
      M
      Myhand
    • RE: [Plugin] Material_Maintenance v2.2 - 2013-01-13

      @cmd said:

      Here is the output from the ruby console after replacing with your posted Material_Maintenance.rb and launching the tool.

      CMD

      Thanks CMD.

      Unfortunately the attached output implies that the debug version of the Material_Maintenance.rb script did not run but rather the old version.

      the error says:

      
      Error; #<NoMethodError; undefined method `refreshMaterials' for #<MH_KeepingMyHandIn;;MaterialMaintenance;0x1383e920>>
      /Library/Application Support/Google SketchUp 8/SketchUp/Plugins/Material_Maintenance/Material_Maintenance.rb;106;in `send'
      
      

      and indicates the send method call is on line 106, while it is actually on line 122 in the debug version.

      Have you restarted Sketchup after copying the new file in?

      A few ways to check that the debug script is running are:

      • You should see this message in the console: "calling function >>refreshMaterials<<"; There might also be the same message but with other function names
      • The the above error appears again, it should be on line 122 not line 106.

      Cheers,

      myhand

      posted in Plugins
      M
      Myhand
    • RE: JSON in Ruby

      @oricatmos said:

      @myhand said:

      Where did you get the library from?

      I don't remember where I got the Windows binaries from. Perhaps I still have a bookmark in my web browser at work, but right now I'm at home and can't have a look. But since I have access to our project repository from home I can offer you this:

      Link Preview Image
      Dropbox - 404

      favicon

      (dl.dropbox.com)

      Thanks OricAtmos! Will give it a try.

      posted in Developers' Forum
      M
      Myhand
    • RE: [Plugin] Material_Maintenance v2.2 - 2013-01-13

      @cmd said:

      @myhand said:

      ... CMD, if I add some debug code to the script would you mind running it and sending me the output?

      No problem 😄

      CMD

      Hi CMD,

      here is the file

      Debug version

      You can replace the Material_Maintenance.rb file in your ../Plugins/Material_Maintenance folder, restart sketchup, open the console window and launch the plugin. The script will output some debug to the console. Can you send me the whole console output please.

      Cheers,

      myhand

      posted in Plugins
      M
      Myhand
    • RE: JSON in Ruby

      @oricatmos said:

      @myhand said:

      There is a a subdirectory called yajl, but no files named "yajl.rb", "yajl.so" or "yajl.dll" anywhere else in the yajl library distribution... So cannot see how adding the "c:/temp" path to $LOAD_PATH will find the file as it does not appear to exist.

      Sounds like you don't have the complete library.
      This is a list of files I have in my Yajl folder:

      Yes OricAtmos, I think you are right. I took my version from here

      https://rubygems.org/gems/yajl-ruby.

      As I cannot install the gem in Sketchup I unzipped the gem file and took the files from the lib directory. This gives me the following files which is clearly not complete.

      
      C;\Temp\lib\yajl
      C;\Temp\lib\yajl.rb
      C;\Temp\lib\yajl\bzip2
      C;\Temp\lib\yajl\bzip2.rb
      C;\Temp\lib\yajl\deflate
      C;\Temp\lib\yajl\deflate.rb
      C;\Temp\lib\yajl\gzip
      C;\Temp\lib\yajl\gzip.rb
      C;\Temp\lib\yajl\http_stream.rb
      C;\Temp\lib\yajl\json_gem
      C;\Temp\lib\yajl\json_gem.rb
      C;\Temp\lib\yajl\version.rb
      C;\Temp\lib\yajl\bzip2\stream_reader.rb
      C;\Temp\lib\yajl\bzip2\stream_writer.rb
      C;\Temp\lib\yajl\deflate\stream_reader.rb
      C;\Temp\lib\yajl\deflate\stream_writer.rb
      C;\Temp\lib\yajl\gzip\stream_reader.rb
      C;\Temp\lib\yajl\gzip\stream_writer.rb
      C;\Temp\lib\yajl\json_gem\encoding.rb
      C;\Temp\lib\yajl\json_gem\parsing.rb
      
      

      Where did you get the library from?

      Cheers,

      myhand

      posted in Developers' Forum
      M
      Myhand
    • RE: JSON in Ruby

      @dan rathbun said:

      @myhand said:

      I tried to get this to work but keep getting errors when trying to include the library:
      require 'yajl'
      If you do not specify some kind of filepath, then the file must be in one of the directories listed in the $LOAD_PATH array.

      Ruby's require() first checks to see if the argument resolves to an absolute path, and if so, checks to see if the file exists, and if true, attempts to load it.

      Secondly, it checks to see if the argument is a relative path (incl. no path at all,) and if so, require() then iterates the $LOAD_PATH array prepending the base paths in front of your relative path. If it finds match, it loads the file, IF such a path is NOT ALREADY present in the $LOADED_FEATURES (aka $") array.

      Thank you Dan for the detailed explanation and links to starter guides. I will review and try this when I get home tonight. One interesting point in this case though is that the only file called yajl.* is c:/temp/yajl.rb which is also the file that contains the

      require 'yajl/yajl'
      

      line. There is a a subdirectory called yajl, but no files named "yajl.rb", "yajl.so" or "yajl.dll" anywhere else in the yajl library distribution... So cannot see how adding the "c:/temp" path to $LOAD_PATH will find the file as it does not appear to exist.

      Will let you know.

      posted in Developers' Forum
      M
      Myhand
    • RE: [Plugin] Material_Maintenance v2.2 - 2013-01-13

      @rv1974 said:

      Myhand, let me shake your hand!
      this is a real helper (especially for those who render outside SU and care about mats order).
      Thank you!

      😄 Glad you like it!

      posted in Plugins
      M
      Myhand
    • RE: JSON in Ruby

      @oricatmos said:

      Is there a reason to avoid libraries like Yajl, because that's what I'm using. I should note that our plugin isn't distributed in any way and only used internally so far and I just put all necessary Yajl files in a sub folder inside our plugin folder. So that's not too pretty I guess, but it works fine.

      Hi OricAtmos, I tried to get this to work but keep getting errors when trying to include the library:

      require 'yajl'

      fails with the following error:

      load "c:/temp/yajl_test.rb"
      Error: #<LoadError: c:/temp/yajl.rb:1:in require': no such file to load -- yajl/yajl> c:/temp/yajl_test.rb:1 c:/temp/yajl.rb:1 c:/temp/yajl_test.rb:1:in require'
      c:/temp/yajl_test.rb:1
      (eval):1:in `load'
      (eval):1

      How did you install the library?

      posted in Developers' Forum
      M
      Myhand
    • RE: JSON in Ruby

      @dan rathbun said:

      Thanx for sharing.

      However it has one major drawback. You defined your class at the toplevel. This should be reserved for Ruby Core basclasses.

      In fact the way you wrote it, the methods never the ref to the self instance, so basically you wrote class (ie, singleton) methods, so it really IS a library module, but you mis-defined it as a class.

      Thanks Dan, this class is actually part of a module in my code, I just cut and pasted it out to show how it works. Thank you for the tips about libraries though, I have not explored this side of Ruby yet.

      You say that my methods are class methods. But I have done some tests and they seem to behave as object methods. i.e. each has access to the object's local state variables. I can also not call them as you would call a static method, i.e. JSON.escape().

      Why do you think my methods are static?

      Cheers

      posted in Developers' Forum
      M
      Myhand
    • RE: JSON in Ruby

      @oricatmos said:

      Is there a reason to avoid libraries like Yajl, because that's what I'm using. I should note that our plugin isn't distributed in any way and only used internally so far and I just put all necessary Yajl files in a sub folder inside our plugin folder. So that's not too pretty I guess, but it works fine.

      Thanks! I have not seen Yajl. Will give it a try. I tried

      http://flori.github.com/json/doc/index.html

      before but could not get it to work within Sketchup hence me writing my own class.

      posted in Developers' Forum
      M
      Myhand
    • RE: [Plugin] Material_Maintenance v2.2 - 2013-01-13

      @cmd said:

      @myhand said:

      Thanks CMD, that will be very useful. I hate not being able to debug it myself!

      Myhand,

      I installed the script on my windows version and all worked fine.

      I also removed and reinstalled it on my Mac but I am getting the same error on launch of the script 😞

      @unknownuser said:

      Error: #<NoMethodError: undefined method `refreshMaterials' for #<MH_KeepingMyHandIn::MaterialMaintenance:0x15306b40>>

      CMD

      Thanks CMD, sounds like my hunch might have been right and that it is something to do with the MAC.

      Can anyone that has used the script on a MAC (successfully or otherwise) please let me know?

      Else we might have to do this the hard way... CMD, if I add some debug code to the script would you mind running it and sending me the output?

      Cheers,

      myhand

      posted in Plugins
      M
      Myhand
    • RE: JSON in Ruby

      You can also try this class wrote. It can serialise Ruby objects, including nested arrays and object graphs and escapes strings to produce valid valid Ruby. I did not need de-serialisation so have not added that yet.

      http://www.keepingmyhandin.com/Downhome/Sketchup/simplejsonserializerrubyimplementation

      posted in Developers' Forum
      M
      Myhand
    • RE: [Plugin] Material_Maintenance v2.2 - 2013-01-13

      For anyone interested here is a link to the JSON formatter class I created. I am now using this for the next version of this plugin, which will allow you to pick a component and find its parent hierarchy. i.e. components containing nested instances of the specified component.

      http://www.keepingmyhandin.com/Downhome/Sketchup/simplejsonserializerrubyimplementation

      posted in Plugins
      M
      Myhand
    • RE: [Plugin] Material_Maintenance v2.2 - 2013-01-13

      @thomthom said:

      I've got a bridge in development in my TT_Lib2 library: http://www.thomthom.net/software/sketchup/tt_lib2/doc/
      A JSON sub-class of a Hash and a bridge where I can call JS functions just with their name from Ruby and it will convert many types of objects to JS object and the return value of the JS function will be converted back into Ruby objects. Got most of the basic data types working and some of SU's custom classes, such as Vector3d and Point3d.
      https://bitbucket.org/thomthom/tt-library-2/

      Parallel to that there's a WebDialog bridge developed in SketchUp's Developer Tools they released as Open Source at last Basecamp: https://github.com/SketchUp/sketchup-developer-tools

      You could have a look at either repos if it could help you.

      It would have been interesting to create a standalone bridge as an open source project, avoiding each developer to create their own version.

      Thank you thomthom, very impressive library! 👍 A shame I did not know about it before I started.

      Unfortunately I already developed a basic bridge so changing it now would be more work than just adding a JSON marshal class. I wrote a basic one in ruby (so probably not the most efficient but works fine for the size of objects I want to pass). Does all objects, and escapes special characters etc. and does the trick for now. I will publish the code a bit later if anyone is interested. As all of my complex objects go from ruby to JS I have not written a parser (yet).

      You have some experience with the C++ API. Does that give access to more attributes than the Ruby API. Specifically I want to change the material assigned to layers.

      posted in Plugins
      M
      Myhand
    • RE: [Plugin] Material_Maintenance v2.2 - 2013-01-13

      @cmd said:

      I have looked into the file and I have found the required "refreshMaterials" definition.

      Regardless, I will test it out on my windows system through parallels and let you know what I find.

      CMD

      Thanks CMD, that will be very useful. I hate not being able to debug it myself!

      posted in Plugins
      M
      Myhand
    • RE: [Plugin] Material_Maintenance v2.2 - 2013-01-13

      cmd, I have done some experiments and suspect you may have a corrupt installation.

      You can either:

      • fully delete the plugin. The whole ..\Plugins\Material_Maintenance folder. And the reinstall and see if you still get the problem

      • open your ..\Plugins\Material_Maintenance\Material_Maintenance.rb file in a text editor and see if on line 150 you have the following method definition:

        def refreshMaterials(selectionOnly, wholeModel, components)

      • send me the ..\Plugins\Material_Maintenance\Material_Maintenance.rb file

      posted in Plugins
      M
      Myhand
    • RE: [Plugin] Material_Maintenance v2.2 - 2013-01-13

      @thomthom said:

      hm... the error is a missing refreshMaterial method - how can that be OSX specific?

      I pass the method name in from javascript... the method certainly is there, and this code works on Windows... So somehow it does not resolve in this case.

      So as far as I can see: either the method name coming in from JS (I assume the webdialog run in Safari on OSX) is somehow corrupted - how I do not know or I am not using the robust RUBY syntax in defining the method, and Ruby on OSX cannot find it.

      For instance should I pre-pend it with "self". I do not know and cannot debug as I do not have OSX.

      Has anyone else had this problem in windows, or got it working in OSX?

      posted in Plugins
      M
      Myhand
    • RE: [Plugin] Material_Maintenance v2.2 - 2013-01-13

      @tig said:

      @cmd

      Do you have a Selection made before this Tool is launched ?
      It's not obvious from your screenshot.
      You have its 'Materials' option set to 'Select from List' and its 'Scope' option set to list for 'Selection Only'...
      This might then invoke an untrapped error ?
      This obviously shouldn't happen... BUT it might explain things...
      Try using it with a selection and/or some different option settings...

      Good thought TIG, but from what I can see this should not cause the problem. I have specifically tested for no selection, and the error is also not a null pointer error. I think it has to do with it running on a MAC...

      posted in Plugins
      M
      Myhand
    • RE: [Plugin] Material_Maintenance v2.2 - 2013-01-13

      @cmd said:

      When I launch the plugin, the materials list area is empty and when I select "Re-Load Materials", I receive the following error:

      "Error: #<NoMethodError: undefined method `refreshMaterials' for #MH_KeepingMyHandIn::MaterialMaintenance:0x24571cb8>>"
      CMD

      Hi CMD,

      I see you are running on a MAC which unfortunately I cannot test against. It appears not to be able to find the refreshMaterials method, which is definitely there and working on windows. Only thing I can think of is that either:

      • ruby behaves differently on a MAC (I am not a Ruby expert so might well not have the method syntax exactly right when you add modules etc, and maybe the MAC implementation is stricter that the windows)
      • or JavaScript behaves marshals the string containing the method name differently.

      Few questions:

      • Do you have a windows machine you can test this on?
      • Is this happening with all models? I suspect it is as not finding the method should not be model dependent.
      • have you tried remove the plugin manually (all files) and reinstalling
      posted in Plugins
      M
      Myhand
    • RE: [Plugin] Material_Maintenance v2.2 - 2013-01-13

      @thomthom said:

      I've had to set myself into C in order to make C extensions - so I get to use my curly brackets.

      Curly braces is what I miss most in Ruby 😄. And of course a good IDE would have been nice... I am generally surprised with the lack of tools and libraries. e.g. no JSON support was a unfortunate surprise, and would have made the GUI much easier.

      For this add-in I have written a simple protocol, which supports strings and arrays, but no complex objects or matrixes. Was going to show a tree of the model, but need to pass more complex data structures then, and JSON would have been perfect.

      Does the C API give you better access to the model? I would love to be able to change the layer materials (transparency and colour) as this currently requires manual setup in my plugin.

      posted in Plugins
      M
      Myhand
    • 1
    • 2
    • 3
    • 4
    • 5
    • 4 / 5