sketchucation logo sketchucation
    • Login
    1. Home
    2. sepultribe
    3. Posts
    ⚠️ Attention | Having issues with Sketchucation Tools 5? Report Here
    S
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 9
    • Posts 26
    • Groups 1

    Posts

    Recent Best Controversial
    • SU ruby questions part2

      Hello once again. I'm confused about how to load ruby gems like savon or yaml from an external ruby 2.0 installation in sketchup 2014 M1. Is the $LOAD_PATH method and interpreter dll copying still needed like in older SU with ruby 1.8.7?

      Also, I saw a recommended template for ruby scripts wrapping the plugin inside a module and a singleton class. I understand the module creating a unique namespace so as not to clash with anything else, but what is the use of the singleton class?

      thanks

      posted in Developers' Forum
      S
      sepultribe
    • Manipulate text label attached to entity

      Hello all. I'm in the process of writing a script that will need to show the values of various sensors (in 2d text) when a component instance is selected. The component instance represents a sensor node. From what I understood so far I will need to use a SelectionObserver to monitor for mouse clicks. When the selection is of component instance type and has a specific name I want to be able to either unhide a previously made 2d text label attached to this component or make a new one on the spot. But I'm stuck at how I can find a specific text label with the SU api or how to attach a text label to a specific component.

      posted in Developers' Forum
      S
      sepultribe
    • RE: Webdialog scripting issues

      will do ty.

      may i ask your opinion on a matter?

      i will need to change ruby variables via the WD's javascript and vice versa, thus making a single function in each that accepts two arguments, the variable's name and value, handy. i know that ruby and js dont pass variables in arguments by reference, and that it would need some complicated code in each to achieve that.

      would the messy way of creating a separate method for each variable i need to modify in ruby and/or javascript be more sensible?

      regards

      posted in Developers' Forum
      S
      sepultribe
    • RE: Webdialog scripting issues

      Dan thanks a lot for this great post. I will study the code and read more on ruby proxy classes and i will come back here to post back.

      i see you also check the underlying os, that is very nice. i hadn't thought of that. this way the plugin can be made cross platform.

      you are all very helpful, i am in debt. i will also read your sigs info

      posted in Developers' Forum
      S
      sepultribe
    • RE: Webdialog scripting issues

      thank you for taking the time to answer. yes the above code works generally, but i haven't understood some things about how sketchup handles each webdialog instance.

      how can i interact with each webdialog issued from main_wd for instance? how can i access each webdialog's methods,variables,etc. from outside it? eg. the ruby console

      posted in Developers' Forum
      S
      sepultribe
    • Webdialog scripting issues

      Hello. I have a problem that i can't solve atm and i could use some help.

      I have a sketchup model that contains some component instances that represent sensors. I made a context menu entry that executes a command for a webdialog to be created. This webdialog will retrieve information for the sensor that is attached to it.

      How can i create a separate webdialog instance that i can manipulate without interfering with another webdialog from the same command?

      here is the code

      require "sketchup.rb"
      module XXX
      
      model = Sketchup.active_model	# point to the active model
      
      selected = model.selection	# get the selected entities
      
      cmd_settings = UI;;Command.new("Settings") {
      settings_wd = UI;;WebDialog.new( "Main Settings", false, '', 200, 200, 500, 500, true )
      settings_html_path = Sketchup.find_support_file "settings.html", "Plugins/xxx_plugin/"
      settings_wd.set_file( settings_html_path )
      settings_wd.set_position(640,480)
      settings_wd.set_size(500,300)
      
      settings_wd.show
      }
      
      cmd_main = UI;;Command.new("Get Sensor Data") {
      if selected[1]==nil and selected[0].class==Sketchup;;ComponentInstance and selected[0].name.include?'Sensor'
      main_wd = UI;;WebDialog.new( "#{selected[0].name}'s Info", false, '', 200, 200, 500, 500, true )
      main_html_path = Sketchup.find_support_file "main.html", "Plugins/xxx_plugin/"
      main_wd.set_file( main_html_path )
      main_wd.set_position(800,600)
      main_wd.set_size(250,250)
      main_wd.add_action_callback("get_info") { |js_cb, params|
      	main_wd.execute_script("show_selected('#{selected[0].name}', '#{selected[0].class}')")
      }
      main_wd.show
      else
      UI.messagebox('Selected entity is not a Sensor Component or you have selected more than one entities.')
      end
      }
      
      
      unless file_loaded?(__FILE__)
      
      # Access SketchUp's Edit menu
      edit_menu = UI.menu "Plugins"
      sub_menu = edit_menu.add_submenu("xxx Plugin")
      item = sub_menu.add_item cmd_settings
      
      # Access SketchUp's context menu
      UI.add_context_menu_handler do |menu|
      menu.add_separator
      item = menu.add_item cmd_main
      end
      
      file_loaded(__FILE__)
      end
      
      end
      

      thank you

      posted in Developers' Forum
      S
      sepultribe
    • 1
    • 2
    • 2 / 2