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

    sepultribe

    @sepultribe

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

    sepultribe Unfollow Follow
    registered-users

    Latest posts made by sepultribe

    • Access module variables from inside a module class

      I have the following code

      module MyModule
      
      @@settings_hash = {}
      
      if File.exists?(SETTINGS_PATH)
        @@settings_hash = YAML;;load_file SETTINGS_PATH
        puts @@settings_hash
      end
      
      def self.get_settings(hash_key)
        @@settings_hash.[](hash_key.to_sym)
      end
      
      ...
      ...
      @@settings_hash gets used here inside several function blocks
      ...
      
      class SensorNodeInfoTool
      
      ...
      ...
      
      def m_get_set(string)
          MyModule.get_settings(string)
      end
      
      def onLButtonDown(flags, x, y, view)
        ...
        ...
          if m_get_set("ws_type") == 'NOWSDL'
            client = Savon.client(endpoint; m_get_set("endp"), namespace; m_get_set("ns"))
          elsif m_get_set("ws_type") == 'WSDL'
            client = Savon.client(wsdl; m_get_set("doc"))
          end
        ...
        ...
      
      

      The problem is using Module @@ or @ variables inside a Class that is inside the same Module, like my SensorNodeInfoTool there. I don't think I have found a way to access @variables yet (I think those are called Module Instance variables). The above code has @@variables and I have to use a the module namespace AND set a reader method, and I have also used a second function inside the Class to not have to use the Module namespace prefix. Is there another more proper way? I have the feeling that I might be doing it wrong.

      posted in Developers' Forum
      S
      sepultribe
    • RE: Custom tool creating instances of text labels

      @tig said:

      Here's how I would do it...
      Let's first assume that a component-instance has no label.
      The user clicks on it.
      It is confirmed as a component-instance.
      It is also checked for a special attribute, tid=instance.get_attribute("SensorNodeInfo", "tid", nil), in this case it returns nil as it has no label.

      unless tid
      >   ### add_label_code
      > else
      >   ### delete_label_code
      > end
      

      The 'add_label_code' will make the Text object, and give it a 'tid', a matching 'tid' will also be given to the picked instance...

      ` tid=Time.now.to_f+rand
      instance.set_attribute("SensorNodeInfo", "tid", tid)

      some code to add the Text object - referenced as 'label'

      label.set_attribute("SensorNodeInfo", "tid", tid)`
      Now the instance and its label are pair with a matching [unique] tid attribute.

      The 'delete_label_code' erases any related 'label', by matching its 'tid'.
      The 'label' Text object will have been previously given a unique 'tid' returned in the 'instance' match that was NOT nil, so you need to iterate the instances context to get possible candidates,
      labels_to_go=instance.parent.entities.grep(Sketcup::Text).select{|e| e.get_attribute("SensorNodeInfo", "tid", nil)==tid }
      then
      instance.parent.entities.erase_entities(labels_to_go) if labels_to_go[0]

      Thanks that's very helpful.

      posted in Developers' Forum
      S
      sepultribe
    • RE: Custom tool creating instances of text labels

      @tig said:

      Find an example Tool - like the Line-Tool script - there are dozens [e.g. My 2dTools scripts] - which take multiple point clicking - for a line instead of adding geometry from the clicked points you just add you label at its clicked point....
      You have a activate() method to set up the tool once, and that then runs a rest() method which starts the processing.
      You can have any Tool running until the user selects another tool etc...
      After the mouse-button-click code is done adding the label you then run the reset() method to set up for the next label...

      Yes but I will need to be able to both create and delete text labels on each component that is clicked(show on 1st LClick, hide on 2nd LClick, and in between update the contents of the text label at specified second intervals). Will that work with the above philosophy or will it need that I create a class to hold references to which text label is attached to which component and detect which one is clicked and delete it? I'm really confused.

      posted in Developers' Forum
      S
      sepultribe
    • Custom tool creating instances of text labels

      I'm in the process of making a Tool that will display some text labels on the Component entities that it gets clicked on. The text label contents will be drawn from a soap webservice but that is another subject. What I'm having trouble with is getting the tool to operate on each entity separately. Right now it will only work on 1 entity at a time.

      module SensorNodeInfoPlugin
      class SensorNodeInfoTool
      
        def initialize
          @selection = nil
          @info = nil
          @new_text = nil
          @label_exists = false
        end
      
        def onLButtonDown(flags, x, y, view)
        if @label_exists==false
          pick_helper = view.pick_helper
          pick_helper.do_pick(x, y)
          @selection = pick_helper.best_picked
          @info = @selection.name
          arrow_x = @selection.bounds.corner(7)[0]
          arrow_y = @selection.bounds.corner(7)[1]
          arrow_z = @selection.bounds.corner(7)[2]
          text_x = 20
          text_y = 20
          text_z = 20
          @new_text = Sketchup.active_model.entities.add_text "", [arrow_x, arrow_y, arrow_z], [text_x, text_y, text_z]
          @new_text.text = "Loading #{@info}'s info..."
          @new_text.leader_type = 2
          @new_text.line_weight = 4
          @new_text.arrow_type = 4
          @label_exists=true
          else
          Sketchup.active_model.active_entities.erase_entities @new_text
          @label_exists=false
          end
        end
      
        def draw(view)
      
        end
      
      end # module Sepultribe
      
      # Add the plugin to the menu, only once when the file is loaded.
      unless file_loaded?(__FILE__)
        command = UI;;Command.new("Display Sensor Node Info"){
          Sketchup.active_model.select_tool(SensorNodeInfoTool.new)
        }
        UI.menu("Plugins").add_item(command)
      end
      
      end # SensorNodeInfoPlugin
      

      If I understand correctly there is only one instance of the Tool at all times? I need multiple instances or is there some other way?

      posted in Developers' Forum
      S
      sepultribe
    • RE: Which folders does SU look for gems in?

      Thanks, I will test this and come back to post the results.

      posted in Developers' Forum
      S
      sepultribe
    • RE: Webdialog - getting started?

      @thomthom said:

      [attachment=1:1sdocz38]<!-- ia1 -->2015-07-25_13h45_44.png<!-- ia1 -->[/attachment:1sdocz38]

      It appear that it's automatically generating it...

      ...or might I have added it manually at some point?

      [attachment=0:1sdocz38]<!-- ia0 -->2015-07-25_13h47_40.png<!-- ia0 -->[/attachment:1sdocz38]

      ❓ ❓ ❓

      I added it (on rubydocs) when I posted my previous post.

      posted in Developers' Forum
      S
      sepultribe
    • Which folders does SU look for gems in?
      Gem;;default_dir
      C;/Program Files (x86)/SketchUp/SketchUp 2014/Tools/lib/ruby/gems/2.0.0
      Gem;;user_dir
      C;/Users/Popi/.gem/ruby/2.0.0
      Gem;;dir
      C;/Users/Popi/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Gems
      

      Let's say someone needs to install some gems on a pc with no internet con. In which of the above folders must one place the gem files? Will it also need the spec files too? Or anything else?

      posted in Developers' Forum
      S
      sepultribe
    • RE: Webdialog - getting started?

      Link Preview Image
      RubyDoc.info: Documenting RubyGems, Stdlib, and GitHub Projects

      Documenting RubyGems, Stdlib, and GitHub Projects

      favicon

      (www.rubydoc.info)

      maybe Dan means this

      posted in Developers' Forum
      S
      sepultribe
    • RE: Install gem with dependencies on SU2014+

      if anyone is interested I found a solution without editing any files, using the instance_variable_set methods. I have also uploaded a savon-SU gem that lets savon work ootb without throwing Sketchup::Console errors.

      Gem;;Platform.local.instance_variable_set(;@cpu,'x86')
      x86
      Gem;;Platform.local.instance_variable_set(;@os,'mingw32')
      mingw32
      Gem;;Platform.local
      #<Gem;;Platform;0x473bf20 @cpu="x86", @os="mingw32", @version=nil>
      Gem.install 'savon-SU'
      [#<Gem;;Specification;0x5448888 nori-2.6.0>, [#<Gem;;Specification;0x92b9a94 mini_portile-0.6.2>, #<Gem;;Specification;0x3bc3010 nokogiri-1.6.6.2-x86-mingw32>], #<Gem;;Specification;0x5a70410 wasabi-3.5.0>, #<Gem;;Specification;0x4685dfc builder-3.2.2>, #<Gem;;Specification;0x4fb40a4 gyoku-1.3.1>, #<Gem;;Specification;0x512df18 akami-1.3.1>, #<Gem;;Specification;0x3ce9f88 savon-SU-2.11.1>]
      require 'savon'
      true
      client = Savon.client(wsdl; "http://www.w3schools.com/webservices/tempconvert.asmx?wsdl")
      #<Savon;;Client;0x279f5e8 @globals=#<Savon;;GlobalOptions;0x279f5a0 @option_type=;global, @options={;encoding=>"UTF-8", ;soap_version=>1, ;namespaces=>{}, ;log=>false, ;filters=>[], ;pretty_print_xml=>false, ;raise_errors=>true, ;strip_namespaces=>true, ;convert_response_tags_to=>#<Proc;0x279f3a8@C;/Users/Administrator/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Gems/gems/savon-SU-2.11.1/lib/savon/options.rb;85 (lambda)>, ;convert_attributes_to=>#<Proc;0x279f348@C;/Users/Administrator/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Gems/gems/savon-SU-2.11.1/lib/savon/options.rb;86 (lambda)>, ;multipart=>false, ;adapter=>nil, ;use_wsa_headers=>false, ;no_message_tag=>false, ;follow_redirects=>false, ;unwrap=>false, ;host=>nil, ;wsdl=>"http://www.w3schools.com/webservices/tempconvert.asmx?wsdl"}>, @wsdl=#<Wasabi;;Document;0x279e8b0 @document="http://www.w3schools.com/webservices/tempconvert.asmx?wsdl", @adapter=nil, @request=#<HTTPI;;Request;0x279e7c0 @follow_redirect=false>>>
      
      posted in Developers' Forum
      S
      sepultribe
    • Openssl error when using x86 Vista OS

      When I try to install any gem through the console

      Gem.install 'gem'
      

      I get

      Error; #<LoadError; 127; The specified procedure could not be found.   - C;/SketchUp/Tools/RubyStdLib/platform_specific/openssl.so>
      C;/SketchUp/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb;45;in `require'
      C;/SketchUp/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb;45;in `require'
      C;/SketchUp/Tools/RubyStdLib/openssl.rb;17;in `<top (required)>'
      C;/SketchUp/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb;45;in `require'
      C;/SketchUp/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb;45;in `require'
      C;/SketchUp/Tools/RubyStdLib/rubygems/security.rb;11;in `<top (required)>'
      C;/SketchUp/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb;45;in `require'
      C;/SketchUp/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb;45;in `require'
      C;/SketchUp/Tools/RubyStdLib/rubygems/package.rb;43;in `<top (required)>'
      C;/SketchUp/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb;45;in `require'
      C;/SketchUp/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb;45;in `require'
      C;/SketchUp/Tools/RubyStdLib/rubygems/dependency_installer.rb;3;in `<top (required)>'
      C;/SketchUp/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb;45;in `require'
      C;/SketchUp/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb;45;in `require'
      C;/SketchUp/Tools/RubyStdLib/rubygems.rb;524;in `install'
      <main>;in `<main>'
      -e;1;in `eval'
      nil
      

      I modified openssl.rb with the correct path for openssl.so (was missing platform_specific) but that didnt fix it. I then modified gem sources

      Gem;;default_sources
      ["http://rubygems.org/"]
      Gem;;sources
      #<Gem;;SourceList;0xb427a50 @sources=[#<Gem;;Source;0xb427870 @uri=#<URI;;HTTP;0xb4278e8 URL;http://rubygems.org/>, @api_uri=nil>]>
      

      but it still gives the same error.

      Why doesn't this work like when on 64-bit windows?

      posted in SketchUp Discussions sketchup
      S
      sepultribe