sketchucation logo sketchucation
    • Login
    1. Home
    2. pratikthaker
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    P
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 7
    • Groups 1

    pratikthaker

    @pratikthaker

    10
    Reputation
    1
    Profile views
    7
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    pratikthaker Unfollow Follow
    registered-users

    Latest posts made by pratikthaker

    • RE: Error in 'require' when running via Sketchup Bridge

      You're not going to believe me, but the puts wasn't working in the Ruby console for the past 2 days, but it just started working right now. Ghost in the machine I guess.

      I'm still getting a crash when I run the motion_sample.rb script I mentioned above. I think it might have to do with not being able to access the gems, although there is no error message. I'm investigating it and will get back with any questions.

      Thanks again!

      posted in Developers' Forum
      P
      pratikthaker
    • RE: Error in 'require' when running via Sketchup Bridge

      Hi Dan, you're a trove of information. Thank you!

      Regarding the 'unshift ../lib' issue, I'll go ahead and save the path to a basedir var like you mention. For the time being though I've gotten through the issue by copying the leap-motio-ws.rb file into the Skethcup plugins directory.

      And as far as the gems, I'll go ahead and move them directly to the plugins folder like you suggested. I was under the impression that installing a Ruby gem actually 'installed' it the way programs get installed. But if it just copies the files to the gems folder, then I can do the same in the Sketchup plugins folder.

      However, the the question I now have is regarding the Ruby dll. I checked my 'set' variables, and you are right - the "C:\Ruby187\bin" string is set in my PATH. So does this mean that by default the dll file in my Ruby187\bin folder is being used? In this case it doesn't matter if I copy the dll into the Sketchup folder right?

      Let me tell you my main aim right now - what I am trying to do is get some sort of printed output to show up,preferably by having puts to output to my commandline when I run my script using the Sketchup Bridge executable. I assume using the full ruby dll will let me do this - am I correct? If not, please let me know the best way to do this.

      And the reason this is important for me is that the script I am running works fine when I run it on normal Ruby, but it doesn't work in Sketchup (it causes sub.exe to return a 'server timeout' and directly loading the script in Sketchup causes it to crash). Without the puts output, it's impossible to know whats going wrong.

      P.S. The script I am trying to run is 'motion_sample.rb' in the 'samples' folder in the following github repository: https://github.com/glejeune/ruby-leap-motion-ws. Esentially it is an event listener that listens for data coming through a websocket connection. If anyone can identify a potential problem with running a script like this in Sketchup please let me know.

      posted in Developers' Forum
      P
      pratikthaker
    • RE: Error in 'require' when running via Sketchup Bridge

      Here's a little update: After my last post, I went ahead and pasted the leap-motion-ws.rb directly into the plugins folder, and voila, I started getting error messages about the requires in it! So I went ahead and moved all the folders into the plugin directory and got to a point where I was getting a require error on 'rubygems'.

      At this point, my first observation is that the

      $;.unshift "../lib"
      

      command did NOT add the '../' path to the load paths. Any idea why?

      So continuing on, I checked the location of my rubygems file, and realized it was in the 'site_ruby' folder. I therefore went ahead and uncommented that line from the load path script. I also made sure the path to the ruby folder was correct and case-sensitive.

      Now, something strange happens:
      On restarting Sketchup, I get the following message in the 'Load Errors' dialog:

      @unknownuser said:

      Error Loading File leap-motion-ws.rb
      no such file to load -- rubygems

      BUT, when I run the motion_sample.rb script using sub.exe, I get NO such error. What I do get though is a server timeout, but I think that might be due to this script being an event listener and sub.exe timing out somehow (I don't really know how the guts of it works).

      In any case, I'd be interested to know why:

      1. The 'unshift' command didn't seem to work
      2. SketchUp was still able to execute ruby scripts despite not having anyversion of msvcrt-ruby18.dll in the SketchUp folder (and whether this could be related to why I'm still not seeing any puts output on the console)
      3. Why Sketchup gives me an error in loading --rubygems when starting up, yet is able to run a script that references rubygems through the same file succesfully.
      4. Why I am getting a server timeout from Sketchup Bridge (although this might be worthy of putting in a different topic)

      By the way, if anyone here thinks this discussion is not specific enough or is rambling, please let me know and I can take it down. I respect the sanctity of this forum and don't wish to be a nuisance in any respect.

      posted in Developers' Forum
      P
      pratikthaker
    • RE: Error in 'require' when running via Sketchup Bridge

      OK, so like a good, enthusiastic little programmer, I went ahead and installed an older version of Ruby and copied the dll, but I am still having the same issue. Here are the steps I took:

      1. I uninstalled Ruby version 2.0.0 from my system and installed the latest version 1.8.7-p374 from here: http://rubyinstaller.org/downloads/ (Note that I did not install version 1.8.6 because I needed to install the DevKit for my gem and I was having issues doing that for the 1.8.6 version)
      2. I went ahead and installed DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe from the same site.
      3. I installed my gem, and tested it from the command line.
      4. I copied the LOAD PATH script from http://sketchucation.com/forums/viewtopic.php?f=180&t=29412, and put it in the Plugins folder. I restarted Sketchup and I confirmed that the paths tot he ruby directory were added.
      5. I moved the existing msvcrt-ruby18.dll in the Sketchup folder to a "Backup" folder and copied the msvcrt-ruby18.dll in my ruby187/bin directory to the Sketchup directory, as mentioned in http://sketchucation.com/forums/viewtopic.php?f=180&t=25233&hilit=+interpreter+dll#p217030.

      I restarted Sketchup and ran the script using sub.exe, but I still get the same error. The error is

      @unknownuser said:

      <eval>:2:in 'require' : no such file to load -- leap-motion-ws

      The file I am running is called 'motion_sample.rb', and here are the first few lines:

      $;.unshift "../lib"
      
      require 'leap-motion-ws'
      

      The directory structure is of the key files is as such:

      @unknownuser said:

      C:\Users\Pratik\Development\SketchupLeap\LeapFiles\ruby-leap-motion-ws-master\samples\motion_sample.rb

      @unknownuser said:

      C:\Users\Pratik\Development\SketchupLeap\LeapFiles\ruby-leap-motion-ws-master\samples\sub.exe

      @unknownuser said:

      C:\Users\Pratik\Development\SketchupLeap\LeapFiles\ruby-leap-motion-ws-master\lib\leap-motion-ws.rb

      Note that the leap-motion-ws gem is already installed, and the same folder as 'leap-motion-ws-master' exists in
      @unknownuser said:

      C:\Ruby187\lib\ruby\gems\1.8\gems\leap-motion-ws-0.0.2

      My windows version is Windows 7, and my Sketchup is he Pro Version 8.0.4811.

      What am I missing here?

      (P.S. I noticed something strange - to test if it would work, I removed the existing msvcrt-ruby18.dll from the Sketchup folder, and opened Sketchup without copying the new DLL (ie. there was NO version of msvcrt-ruby18.dll in the Sketchup folder). Despite this, Sketchup opened correctly AND ran the load path script I copied above. Does this mean my Sketchup is using some other DLL as the interpreter?)

      posted in Developers' Forum
      P
      pratikthaker
    • Error in 'require' when running via Sketchup Bridge

      OK, parts of this question have been posted in various forms across these forums, but for a Ruby newbie like me, it's a little bit confusing. So I hope you guys will bear with me and help me through this.

      What I am trying to do is to run a script via the Sketchup Bridge executable on Windows 7. I am able to run it successfully with with my normal Ruby install, but when I try to run it using sub.exe, I get an error that it could not find a file that exists in the '../lib' folder from where I am running the script and the exe (i have put them both in the same folder).

      (Note that this required file is part of some gem, but as far as I can tell, the error is occurring at the level of requiring this file, and it hasn't yet gotten to the point where it is trying to use a gem)

      Now first thing I did was to try and append the path of my Ruby directory to the load path (as mentioned in http://sketchucation.com/forums/viewtopic.php?f=180&t=18712). I even outputted the new load path via the messagebox, and confirmed it was correct. But that did not seem to work, and I got the same error.

      The next thing I did was to move the folder to the Sketchup Plugins folder, and I moved the file I needed from the ../lib address to the folder where the script is. However, that too did not seem to work.

      At this point, according to whatever I read on the forums, I think it might have to do something with my Ruby version. My normal ruby.exe resides in a 'Ruby200-x64', so I guess that means I have version 2.0.0 for my 64 bit system installed. As per http://sketchucation.com/forums/viewtopic.php?f=180&t=29412 and http://sketchucation.com/forums/viewtopic.php?f=180&t=29544, it seems like Sketchup uses Ruby version 1.8.X, and that I need to install that version of ruby and then copy the msvcrt-ruby18.dll from my Ruby install directory to my Sketchup directory.

      However, before I do carry out this operation, I would like to know - is this really the problem? Because to me it makes no sense why a script, once given the correct load paths, is not able to run on 'any' interpreter. I'd appreciate if someone could show me what I'm missing.

      (As an aside, if I go ahead and install Ruby version 1.8.X, and copy the msvcrt-ruby18.dll into the Sketchup folder, will I then be able to see puts output on the command line, and be able to access installed gems as long as I have the load path right?)

      posted in Developers' Forum
      P
      pratikthaker
    • RE: Passing arguments on command line using Sketchup Bridge

      Hi Dan,

      Thanks a lot for the reply!

      Having the Java program write to a file and then having the Sketchup script read it in is a good idea. I'm going to try that. Can I use the 'File' object to accomplish this in a Sketchup script?

      Having said that, for me latency is an issue, and I don't know if the time for writing and reading from the disk will slow me down - but I guess I'll only know after I try.

      Actually what I am trying to accomplish is have a controller control the camera in the Sketchup model. The controller has APIs in a bunch of languages (Java, C++, Javascript), but none in Ruby. There is one interface created by a third party that uses SWIG to wrap the C++ functions and make it accessible in Ruby, but those are 'listeners', and I don't know if they would work within Sketchup Ruby.

      Do you know if it is possible to have the a .rb script, run via the Sketchup Bridge from within an IDE, that acts as a listener? (Sorry if this is a bit vague - I'm don't have much experience integrating a scripting language like Ruby with something like Java or C++. Let me know if I can clarify this further).

      posted in Developers' Forum
      P
      pratikthaker
    • Passing arguments on command line using Sketchup Bridge

      Hi Guys,

      I am new to this whole Sketchup programming (and Ruby in general as a matter of fact). I had a question on passing arguments into a Sketchup script.

      You see, what I am trying to do is control Sketchup scripts from within an IDE (Eclipse) where I have other code in Java calling Sketchup scripts when required. Now to do this, I have downloaded the 'Sketchup Bridge' and am calling my scripts from my code like so:

      "SUB.exe sketchupscript.rb"

      Now, what I want to do is to pass some arguments to the Sketchup script depending on conditions in my Java program.

      For example, I would like to control the zoom factor in a simple Sketchup Ruby script that just zooms. However, I cannot seem to make it work. Here is what I am doing:

      Here is my simplified script:

      zoominargs.rb:

      zoomfactor = ARGV[0]
      Sketchup.active_model.active_view.zoom(zoomfactor)

      I am then testing it by typing the following on the command line:

      SUB.exe zoominargs.rb 1.03

      However, on doing so, nothing happens, although I do sometimes get the error "wrong argument type (expected Sketchup::Entity)"

      (Note that when I hardcode the value in the script, ie. "Sketchup.active_model.active_view.zoom(1.03)", it works perfectly fine)

      Any ideas on how I can make this work?

      posted in Developers' Forum
      P
      pratikthaker