🔌 Smart Spline | Fluid way to handle splines for furniture design and complex structures. Download
  • Webdialog scripting issues

    9
    0 評價
    9 貼文
    1k 瀏覽
    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**]
  • Find a component definition in a list

    4
    0 評價
    4 貼文
    290 瀏覽
    thomthomT
    A less verbose version:. <span class="syntaxdefault">result&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">references</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">find&nbsp;</span><span class="syntaxkeyword">{&nbsp;|</span><span class="syntaxdefault">string</span><span class="syntaxkeyword">|&nbsp;</span><span class="syntaxdefault">string</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">rstrip&nbsp;</span><span class="syntaxkeyword">==&nbsp;</span><span class="syntaxdefault">ref&nbsp;</span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">puts&nbsp;</span><span class="syntaxstring">'Hello'&nbsp;</span><span class="syntaxkeyword">if&nbsp;</span><span class="syntaxdefault">result</span>
  • Modifying Reporting Area Script

    2
    0 評價
    2 貼文
    195 瀏覽
    JQLJ
    Have you tried report label areas plugin by Fredo? http://sketchucation.com/forums/viewtopic.php?f=323&t=40025&p=471921&hilit=area#p376837
  • OnKeyDown not working when Web dlg is focuse...why?

    6
    0 評價
    6 貼文
    468 瀏覽
    D
    some reading http://unixpapa.com/js/key.html it's title JavaScript Madness: Keyboard Events trying to get my head around it at the moment...
  • How to distinguish face size

    11
    0 評價
    11 貼文
    872 瀏覽
    pingpinkP
    Thank you very much ! Actually , I refer "round_to" in a class Fixnum below my main codes. I don't see any error. It's my new knowledge about sprintf("%.2f", 1.23456) [ruby]class Fixnum def abs rx = self if rx < 0 rx = -rx end return rx end def to_meter ufactor = 1.m rx = (self) / ufactor return rx end def round_to(x) (self * 10**x).round.to_f / 10**x end def ceil_to(x) (self * 10**x).ceil.to_f / 10**x end def floor_to(x) (self * 10**x).floor.to_f / 10**x end def rad_to_deg (self / Math;;PI) * 180.0 end def deg_to_rad (self * Math;;PI) / 180.0 end def comma_format s = self.to_s if s.include? ?. pre, post = s.split '.' "#{pre.reverse.gsub( /\d{3}(?=\d)/, '\&,' ).reverse}.#{post}" else s.reverse.gsub( /\d{3}(?=\d)/, '\&,' ).reverse end end end [/ruby][/code]
  • Can't draw subclasses of Sketchup::Edge

    25
    0 評價
    25 貼文
    1k 瀏覽
    thomthomT
    I hope we get to see your creation one day. It sounds interesting!
  • Sorting algorithm

    9
    0 評價
    9 貼文
    480 瀏覽
    bomastudioB
    Ok TIG I understand.....I just said "group" because I don't use neither the SUpro import nor external plugin, I'm using mine importer: it return to me a group with all the dxf drawing. I used your technique (sustituting the group to the componenet.definition) and it works fine..
  • Grey Out Issue is back

    30
    0 評價
    30 貼文
    887 瀏覽
    Rich O BrienR
    I'm also noticing that box select is not selecting or click select. If i right click something it selects but the menu is greyed
  • How to create donation button for your plugins?

    6
    0 評價
    6 貼文
    633 瀏覽
    renderizaR
    Thank you very much TIG!
  • Custom importer preview?

    5
    0 評價
    5 貼文
    246 瀏覽
    bomastudioB
    @dan rathbun said: @voltaicsca said: If so, how does one access this functionality? This is an operating system feature. Previews will display if a thumbnail image has been saved INSIDE the file. (Which SketchUp can do with models.) But this works only if a picture is available.... so thinking about SU only if I'm writing an exporter (in the case I've got the SU model and its thumbnail). But what about the opposite situation (an importer, say a DWG/DXF/OBJ etc)?
  • Followme &amp; Pushpull Commands

    4
    0 評價
    4 貼文
    728 瀏覽
    pilouP
    You have also a French section here where few ruby developpers can help you (Fredo6, Didier Bur, Matt666... (when they make a little visite User Control Panel / UserGroups/ Français
  • Ruby to open a sequence of files - run ruby

    8
    0 評價
    8 貼文
    553 瀏覽
    T
    Thanks Dan, this worked great! Sketchup.undo() while Sketchup.active_model.modified? Stuart
  • Can a script fire another?

    23
    0 評價
    23 貼文
    1k 瀏覽
    CadFatherC
    @aerilius said: Sorry for being late that's quite alright.. i was taking my time anyway..
  • Modifying geometry in freshly copied Groups (not unique)

    8
    0 評價
    8 貼文
    740 瀏覽
    Dan RathbunD
    @jolran said: However I was thinking more as a benefit to others, keeping this info visible. I added this topic to my manual list of Snippets. See Groups: [Code Snippets] by Subject
  • [Plugin] ToolbarBuilderDemo

    13
    0 評價
    13 貼文
    633 瀏覽
    BoxB
    I think a three or four button save in the free version will get you many more Pro buyers.
  • Ruby script to detect OS

    5
    0 評價
    5 貼文
    2k 瀏覽
    A
    That (edit: scott's) is already almost ruby code. This should do it: module TDxSkp WIN = ( (Object;;RUBY_PLATFORM =~ /mswin/i || Object;;RUBY_PLATFORM =~ /mingw/i) unless defined?(WIN) OSX = ( Object;;RUBY_PLATFORM =~ /(darwin)/i ? true ; false ) unless defined?(OSX) if WIN require 'sketchup.rb' require '3DxSketchUp/3DxSketchUp.dll' file_loaded("3DxSketchUp.rb") elsif OSX require 'sketchup.rb' require '3DxSketchUp.bundle.plugin/Contents/MacOS/3DxSketchUp.bundle' file_loaded("3DxSketchUp.rb") end end # module http://sketchucation.com/forums/viewtopic.php?f=180&t=34631&p=305368 We use proper operating system names because we are not detecting hardware. I'm not sure if that's the namespace ( TDxSkp) that they use, but our constants should better not float in top level namespace. However note that 3DConnexion is a binary plugin and adds content to the Ruby environment that we can not check for errors (or we can find but not fix them).
  • How to get transformation.origin of a internal component

    2
    0 評價
    2 貼文
    490 瀏覽
    TIGT
    First find the insertion point of the Redbox instance in its current context. Next find the transformation of the Bigbox container instance. You need to get a handle on the 'Redbox'. Let's assume there is only one instance and that's inside Bigbox. redbox = model.definitions['Redbox'].instances[0] Now get its insertion point pt = redbox.transformation.origin Now let's assume there's only one instance of 'Bigbox'. bigbox = model.definitions['Bigbox'].instances[0] Get its transformation tr = bigbox.transformation Apply that to the point 'pt' pt.transform!(tr) The point 'pt' is now relative to the model's origin, NOT the Bigbox's internal origin...
  • File Path with backslashes

    6
    0 評價
    6 貼文
    409 瀏覽
    TIGT
    @dan rathbun said: TIG's example: .tr("\"","/") means replace all double quotes with a slash. It probably should be: **.tr("\\","/")** Dan thanks for spotting my typo. I've corrected the original... By coincidence I was doing some changes between double and single quotes and it got stuck in my muscle memory !
  • Reference to entities(id)

    7
    0 評價
    7 貼文
    602 瀏覽
    jolranJ
    Yep, solid tip. Thank you Dan.
  • How to unhide single entity in a hidden hirarchy of entities

    3
    0 評價
    3 貼文
    862 瀏覽
    B
    Thanks for a quick reply! @tig said: If you use nested objects [groups or component-instances] and give them different layers, you can use layer-visibility to control what you see... My target plugin requires to use nested objects 'inside each other' to identify entity parents and their IDs in a complex scene Is there a way to 'unnest' an object?

Advertisement