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

    Ying

    @Ying

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

    Ying Unfollow Follow
    registered-users

    Latest posts made by Ying

    • RE: Problem when running Ruby Script from command line

      @tig said:

      You are trying to fix a problem that doesn't have to exist...
      A simple command-file to rename the .txt 'ruby' file as .rb AND then open the SKP [you should be able to code the command-file to accept dropped-files as its argument[s], so you simply drop the SKPs you want to 'export' onto its icon].
      Before the 'ruby' file says 'terminate' it has an extra line to simply rename itself as .txt.
      OR make a .rb script that 'exports' all of the SKP files in a particular selected folder. It opens them in turn and exports them, returning to the original SKP ??

      Please excuse me that I still don't get it. Why do I need to name the script file as .txt. Why can't I just use .rb? I am quite new for Sketchup and Ruby API. Maybe I just made a stupid mistake but I didn't know. I am pretty sure that my Ruby scripts are correct. It is just that the Sketchup doesn't get the window focus to run it.

      posted in Developers' Forum
      Y
      Ying
    • RE: Problem when running Ruby Script from command line

      @dan rathbun said:

      What about:

      command & /path/to/Sketchup/sketchup -rubyStartup myfile.rb

      Isn't the & supposed to replace the current process ??

      I did exactly the same but unfortunately it still didn't do what I want. Maybe the attached screenshot can explain my trouble better.

      My ruby script file is quite simple:

      open the sketchup file

      show_summary = true
      Sketchup.open_file ".../test.skp"

      export the model

      model = Sketchup.active_model
      status = model.export '.../test.dae', show_summary

      close the Sketchup window

      Sketchup.send_action('terminate:')

      From the screenshot you can see that the Sketchup window is under the Terminal window when I run "command & /path/to/Sketchup/sketchup -rubyStartup myrubyscript.rb" command. Although the Sketchup was launched, the ruby script file was not be executed unless I click on the Sketchup window. Haven't you ever met this problem before?


      sketchup.png

      posted in Developers' Forum
      Y
      Ying
    • RE: Problem when running Ruby Script from command line

      Thank you guys for your helping. My problem is solve.
      I wrote a c++ program to run the command line ".../sketchup -RubyStartup myrubyscript.rb" using system() method. However, the Sketchup UI window is still covered by Mac OS Terminal and myrubyscript.rb can't be executed. (I probably have to run my c++ program through the Terminal.) Then, the solution is that I fork a new process and let this process to run a program call cliclick to mimic the mouse action to click the Sketchup UI window in order to bring the window to the top of the desktop. Eventually, the myrubyscript.rb gets executed.

      posted in Developers' Forum
      Y
      Ying
    • RE: Problem when running Ruby Script from command line

      I am using Mac OS 10.5.8
      Actually I'd like to write a c++ program to run the command instead of directly running from the Terminal. Now I just want to test this command line beforehand to make sure it is a possible solution.

      @dan rathbun said:

      TIG his problem is running from a shell script (batch mode.)

      It seem to be an OS blocking issue.

      Ying, what version OSX are you running ?

      Try using a symbolic link, or shell script instead of typing the command into Terminal.

      posted in Developers' Forum
      Y
      Ying
    • Problem when running Ruby Script from command line

      This might be a simple question but I searched for the solution for a couple of days and got nothing.

      I want to run Skechup from command line using a Ruby Script to open a sketchup model and then export it as a dae model, on may MacBook Pro with Mac OS. However, everytime I run the command ".../sketchup -RubyStartup myrubyscript.rb" from the Terminal, it launches the sketchup but stops running the Ruby scripts. I think that it is because that the Terminal is the current active process and the Sketchup is not. (The Terminal window is on the top of the desktop.) As long as I manually click on the Sketchup UI to bring it to the the current active process (now the Sketchup UI window is on the top), the Ruby scripts will continue. I really don't want to involve human interaction in this whole process. I want them to be automatically. Can anyone tell me how can I solve this problem?

      Thank you very much!

      posted in Developers' Forum
      Y
      Ying