sketchucation logo sketchucation
    • Login
    1. Home
    2. sepultribe
    3. Topics
    ℹ️ 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

    Topics

    • S

      Access module variables from inside a module class

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      2
      0 Votes
      2 Posts
      307 Views
      Dan RathbunD
      "Programming Ruby - The Pragmatic Programmer's Guide" explains it all.
    • S

      Custom tool creating instances of text labels

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      5
      0 Votes
      5 Posts
      399 Views
      S
      @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.
    • S

      Which folders does SU look for gems in?

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      3
      0 Votes
      3 Posts
      620 Views
      S
      Thanks, I will test this and come back to post the results.
    • S

      Openssl error when using x86 Vista OS

      Watching Ignoring Scheduled Pinned Locked Moved SketchUp Discussions sketchup
      1
      0 Votes
      1 Posts
      149 Views
      No one has replied
    • S

      Install gem with dependencies on SU2014+

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      5
      0 Votes
      5 Posts
      661 Views
      S
      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>>>
    • S

      Plugin recommended practices

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      3
      0 Votes
      3 Posts
      331 Views
      S
      very much appreciated, thanks for the detailed response
    • S

      SU ruby questions part2

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      8
      0 Votes
      8 Posts
      969 Views
      Dan RathbunD
      The last error is the result of the quirky implementation of Sketchup::Console class. (It is not a subclass of IO, but should have been.) Try some other way of testing your results. UI.messagebox or a webdialog.
    • S

      Manipulate text label attached to entity

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      6
      0 Votes
      6 Posts
      612 Views
      A
      Approach with SelectionObserver: See the documentation: http://www.sketchup.com/intl/en/developer/docs/ourdoc/entities#add_text http://www.sketchup.com/intl/en/developer/docs/ourdoc/text component # be a reference to your component instance position = ORIGIN # or any other point in the component coordinate system direction = Geom;;Vector3d.new(0,0,1) component.entities.add_text(position, "The label text", direction) To find the text again, under the assumption the component contains no other texts: in a Selection Observer def onSelectionBulkChange(selection) return unless selection.count == 1 return unless selection.first.is_a?(Sketchup;;ComponentInstance) component = selection.first return unless component.name == "Specific name" text = component.entities.grep(Sketchup;;Text) # Do something with the text end As I understand your request, you just want to display information to the user, but you do not want to modify/edit the model file. I strongly suggest not to use the native selection tool and observers for this, because it would run always when the user uses the native Select Tool (with a different intention in mind), and observers run always if not properly attached and removed. Plugins should use observers as little as possible (in terms of time), namely only when the user explicitely launches the plugin. Approach with a SketchUp Tool: You could write your own tool instead, which allows you to draw your information to the screen, instead of "modeling" text by adding entities to the model. It is also much cleaner because the user can unselect your tool and use the native Select Tool without confusion. See for reference: http://www.sketchup.com/intl/en/developer/docs/ourdoc/tool http://www.sketchup.com/intl/en/developer/docs/ourdoc/view#draw_text http://www.sketchup.com/intl/en/developer/docs/ourdoc/pickhelper#best_picked linetool.rb example Create a class: module Sepultribe module SensorNodeInfoPlugin class SensorNodeInfoTool SPECIFIC_NAME = "Specific Name" def initialize @selection = nil @info = nil end def onLButtonDown(flags, x, y, view) pick_helper = view.pick_helper pick_helper.do_pick(x, y) item = pick_helper.best_picked return unless item.is_a?(Sketchup;;ComponentInstance) return unless item.name == SPECIFIC_NAME # Now you have the right component, store it in an instance variable. @selection = item # Fetch the info that you want to display (assuming you have it stored as attribute) @info = @selection.get_attribute("dictionary_name", "attribute_name", "") end def draw(view) return if @selection.nil? position3d = @selection.transformation.origin # or @selection.bounds.center position2d = view.screen_coords(position3d) # (You could also draw the bounding box of the selected component.) # Draw an arrow. vector = Geom;;Vector3d.new(20,-20,0) view.draw2d(GL_LINES, position2d, position2d+vector) # Draw the info. view.draw_text(position2d+vector, @info) 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 end # module Sepultribe
    • S

      Webdialog scripting issues

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      9
      0 Votes
      9 Posts
      1k Views
      Dan RathbunD
      require('sketchup.rb') module SepulTribe module Sensor # RUN ONCE unless file_loaded?(__FILE__) MAC =( RUBY_PLATFORM =~ /(darwin)/i ? true ; false ) WIN = !MAC @@dialogs = {} # Hash to hold sensor dialog refs @@cmd_main = nil @@cmd_settings = nil @@dlg_settings = nil end # RUN ONCE class << self # proxy class def clear_dialogs() @@dialogs.each {|k,v| if v.is_a?(UI;;WebDialog) v.close if v.visible? end } @@dialogs.keys.each {|k| @@dialogs[k]=nil } GC.start # garbage collection end def create_sensor_dialog(obj) wd = UI;;WebDialog.new( "#{obj.name}'s Info", false, '', 200, 200, 500, 500, true ) main_html_path = File.join( File.dirname(__FILE__), "main.html" ) wd.set_file( main_html_path ) wd.set_position(800,600) wd.set_size(250,250) wd.add_action_callback("get_info") { |dlg, params| dlg.execute_script("show_selected('#{obj.name}', '#{obj.class}')") } return wd end # create_sensor_dialog() def create_settings_dialog() wd = UI;;WebDialog.new( "Main Settings", false, '', 200, 200, 500, 500, true ) settings_html_path = File.join( File.dirname(__FILE__), "settings.html" ) wd.set_file( settings_html_path ) wd.set_position(640,480) wd.set_size(500,300) return wd end # create_settings_dialog() def show_sensor_dialog(obj) # dlg = @@dialogs[obj.object_id] if dlg.nil? dlg = create_sensor_dialog(obj) @@dialogs[obj.object_id]= dlg MAC ? dlg.show_modal ; dlg.show else unless dlg.visible? MAC ? dlg.show_modal ; dlg.show end dlg.bring_to_front end # end # show_sensor_dialog() end # proxy class @@cmd_main = UI;;Command.new("Get Sensor Data") { selected = Sketchup.active_model.selection unless selected.empty? if selected.single_object? if selected[0].is_a?(Sketchup;;ComponentInstance) and selected[0].name.include?('Sensor') show_sensor_dialog( selected[0] ) else UI.messagebox('Selected entity is not a Sensor Component. ') end else UI.messagebox('You have selected multiple entities. ') end end # unless } @@cmd_settings = UI;;Command.new("Settings") { if @@dlg_settings.nil? @@dlg_settings = create_settings_dialog() end unless @@dlg_settings.visible? MAC ? @@dlg_settings.show_modal ; @@dlg_settings.show end @@dlg_settings.bring_to_front } # RUN ONCE 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| selected = Sketchup.active_model.selection unless selected.empty? menu.add_separator menu.add_item @@cmd_main end end file_loaded(__FILE__) end # RUN ONCE end # close module Sensor end # close module SepulTribe FIXED lines : %(#000000)[**34**, **35**, **41** & **59**]
    • 1 / 1