ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • Selected entity question

    8
    0 Votes
    8 Posts
    7k Views
    PixeroP
    They are just for two small snippets that I will need some advise from Thomasz (Thea settings) to make them properly. I'm just preparing for when he will have some time to look into it...
  • HTMLDialog - Change source on the fly? Possible?

    2
    0 Votes
    2 Posts
    6k Views
    placidfuryP
    Did more searching, and found one spot that said the source couldn't be changed (at least not in the way I was meaning). I guess to do what I really want to do, I'd have to dive deep into this, and I just don't have the time since my development work is a "side" project at work. I DO however have time to use TT's SKUI, so that's what I'm going with, since I have already used it for a couple dialogs already in this project.
  • Ruby Component Insertion and Attributes - Not Updating

    7
    0 Votes
    7 Posts
    8k Views
    placidfuryP
    Just now saw this - I have been unable to get a batch redraw of DC's to not take significant time. It seems the more DC's you redraw in the same operation, the longer each successive one takes to redraw. Eventually, I found a way around this by simply scrapping my usage of DC's and switching to groups. Operations on groups are essentially instantaneous. I'd use DC's if it's one or few objects at a time, or something I want the user to be able to interact with via the DC interface, but most of my plugin's objects are not that - I'm manipulating them with my code. Since I'm doing Engineered Wood Products layouts on very large multifamily buildings, I end up with thousands of objects to manipulate, and DC's simply didn't work well enough, as they were too slow. And the fact that even changing one property - even one that doesn't affect geometry - forces you to have to redraw them each, that time involved was a deal-breaker.
  • Modify highest face

    2
    0 Votes
    2 Posts
    7k Views
    V
    Ok I find the way, it works with local_bounds model = Sketchup.active_model sel = model.selection bbox = Geom::BoundingBox.new sel.each {|grp| bbox=grp.local_bounds get_entities(grp).find_all{|e| is_kind(e,"Face") }.each{|fc2| pl2 = fc2.plane if fc2.normal.parallel?( vec3d(0,0,1) ) and ( bbox.max.on_plane?(pl2)) fc2.layer = "K-Masque" edges = fc2.edges edges.each {|edg| edg.layer = "K-Masque"} end } }
  • Two different colors to the same shape

    2
    0 Votes
    2 Posts
    13k Views
    TIGT
    Please use 'code' blocks to format long Ruby extracts. I've fixed your post for you this time... You need to find all 'vertical' faces in the group named 'Top'. After the last part of the code add this... vfaces = entities.grep(Sketchup;;Face).find_all{|f| f.normal.z == 0 } vfaces.each{|f| f.material = clr }
  • Messagebox within a callback fails

    5
    0 Votes
    5 Posts
    6k Views
    Didier BurD
    @TIG Thanks for the hint, unfortunately it doesn't help, I'm getting the correct values for face and dist outputs. BUT, I tried to call message box in others callbacks, it worked in every case. So what was wrong with this particular callback ? Guess what, one CANNOT call a UI.messagebox after a webdialog (or html dialog) closes, modal or non-modal. There's some kind of logic here... This doesn't work: # callback cancel @web_dialog.add_action_callback("dlg_cancel_settings") { |d, p| @web_dialog.close() r=UI.messagebox("Are you sure ?",MB_YESNO) } This works: # callback cancel @web_dialog.add_action_callback("dlg_cancel_settings") { |d, p| r=UI.messagebox("Are you sure ?",MB_YESNO) @web_dialog.close() }
  • [Plugin] Slender - Baking textures in Sketchup with Blender

    29
    0 Votes
    29 Posts
    14k Views
    N
    I should have also included I am using win 10, blender 2.79c, sketchup 17
  • Reading numbers from external text file

    18
    0 Votes
    18 Posts
    8k Views
    PixeroP
    I use Notepad++ as well but use the ruby code editor when testing out snippets without having to restart SketchUp. Now I’ll continue with the main work.
  • Ruby scripted Dynamic Attributes reporting Issues

    2
    0 Votes
    2 Posts
    6k Views
    Dan RathbunD
    @jh said: ... I dont get it why I cannot get the lenx, leny and leny to report in any Ruby- driven Report-Script I tried, until some User-Interaction with the Component-Options has been made, ... The default values are stored in the DC definition's "dynamic_attributes" dictionary and the DC instance just uses the defaults until the user changes them. When they are different than the default, the DC code will create instance specific attributes in the instance's "dynamic_attributes" dictionary. So the "rule of thumb" for Ruby coding DCs is to always first check the instance's "dynamic_attributes" dictionary, then check the definition's "dynamic_attributes" dictionary for dynamic attribute values.
  • Send action for DC Components options window?

    2
    0 Votes
    2 Posts
    6k Views
    Dan RathbunD
    @pixero said: Is there a way of activating the Dynamic Component Options window through ruby? Yes and sample code is given here ... https://forums.sketchup.com/t/close-component-option-component-attribute-windows-using-ruby-script/83784/6
  • Iterate through nested groups/components to get edges

    8
    0 Votes
    8 Posts
    6k Views
    PixeroP
    Thank you. That works as I wanted.
  • Inputbox issues

    9
    0 Votes
    9 Posts
    7k Views
    PixeroP
    Solved it this way so I never have to pass the @@depth value to the DC. @@depth_inch = @@depth*0.0393700787
  • [SOLVED]Reloading Component via DefinitionsList.load Problem

    14
    0 Votes
    14 Posts
    8k Views
    M
    Thanks for the quick reply! I think I've done everything right, but I only get a new definition (loaded) when I use the write-to-dev-null trick (but it's painfully slow!). When I use the add_cpoint() or add_group() trick my SKP file is ignored and I get the same GUID back. Here's my full script, if you don't mind taking a look: require "sketchup.rb" module RefreshComponent def self.force_reload_component_definition!(model, definition) definition_path = definition.path definition_name = definition.name definition.name = definition.name + rand.to_s ## definition.entities.add_cpoint(ORIGIN) ## <== this causes GUIDs to match (fail) definition.save_as("/dev/null") ## <== this causes new definition load (success) reloaded_definition = model.definitions.load(definition_path) puts "Old GUID; " + definition.guid puts "New GUID; " + reloaded_definition.guid reloaded_definition end def self.reconnect_component_instances!(model, old_definition, new_definition) model.start_operation("Remap instances") old_definition.instances.each { |instance| instance.definition = new_definition } model.commit_operation end def self.delete_component_definition!(model, definition) model.start_operation("Delete Definition") definition.entities.erase_entities(definition.entities.to_a) model.commit_operation end def self.refresh_component(model, definition) model.start_operation("Reload current component definition", true) reloaded_definition = force_reload_component_definition!(model, definition) reconnect_component_instances!(model, definition, reloaded_definition) delete_component_definition!(model, definition) model.commit_operation end def self.start model = Sketchup.active_model model.start_operation("Reload component definitions from file", true) model .selection .select { |entity| entity.is_a?(Sketchup;;ComponentInstance) } .map { |instance| instance.definition } .uniq .each { |definition| refresh_component(model, definition) } model.commit_operation end end unless file_loaded?("refresh_component.rb") UI.add_context_menu_handler do |context_menu| context_menu.add_item("Reload Current Component Definition") { RefreshComponent.start } end file_loaded("refresh_component.rb") end
  • Trouble with commit operation

    10
    0 Votes
    10 Posts
    7k Views
    V
    En fait le guide point sert à modifier l'ancien composant a cause d'un bug sur model.definitions.load(path) qui refuse de lire un composant dans le même répertoire qu'un composant enregistrer si celui ci n'est pas modifier. Je suis donc obliger de mettre la partie guide point avant model.définitions.load(path). cf : https://sketchucation.com/forums/viewtopic.php?f=180&t=60568
  • Straight Skeleton Algorithm

    4
    0 Votes
    4 Posts
    7k Views
    H
    I have been looking for this algorithm too! it's so useful in design. Is there any follow up on this thread? The problem with ruby is that for all the available ruby geometry libraries I could find online are simple algorithms, I can write them myself. but for the hardcore ones such as straight skeleton... it does take some expertise to translate from other languages. looking forward to any ruby implementations for this.
  • Issues with set_attributes Method and Components

    4
    0 Votes
    4 Posts
    6k Views
    TIGT
    How do you 'know' for sure that setting the definition's attribute fails ? You give insufficient detail. If you use get_attribute() on the exact same definition [or instance.definition] you used set_attribute() on, then it should work. Make sure the attribute-dictionary-name and the key are exactly the same in both cases, and that you have a default value set up too - like result = t_def.get_attribute(lib, 'trussfamily', 'WTF!'). If result == @Trussfamily it's working, but if result == 'WTF!' it's not ! Make sure you have presets for the 'value' set/get @Trussfamily, and of course the ' lib' - which should be the string-name of the dictionary, e.g. lib = 'medeek_truss_eng'. It a dictionary of that exact name doesn't exist it's made, if it exists then it's reused... Personally I'd use dictionary name starting with an uppercase letter, and all keys in lowercase. There's less confusion that way... To check what's dictionaries and keys/values are attached to a definition use something like this. if t_def.attribute_dictionaries t_def.attribute_dictionaries.each{|d| puts "DICTIONARY == #{d.name}" d.each_pair{|k, v| puts "#{k} = #{v}" } } else puts "NO DICTS !" end
  • Selecting all edges in selection cycling through groups

    3
    0 Votes
    3 Posts
    6k Views
    TNTDAVIDT
    Hellobaldaman, Here is an example code that will allow you to select all the edges: def select_all_edges(ents, edges) ents.grep(Sketchup;;ComponentInstance).each do |e| e.definition.entities.grep(Sketchup;;Edge).each do |e| edges << e end select_all_edges(e.definition.entities, edges) end end edges = [] mod = Sketchup.active_model sel = mod.selection select_all_edges(sel, edges) sel.clear sel.add(edges) Note that you do not have to select the edges to apply a ruby transformation on the edges. Cordially David
  • Find the position of a specific vertex on a face.

    4
    0 Votes
    4 Posts
    6k Views
    TNTDAVIDT
    Hello, Try this: mod = Sketchup.active_model sel = mod.selection sommet = [] sel.grep(Sketchup;;Face).each do |f| @pt = f.bounds.min f.edges.each do |e| e.vertices.each do |v| sommet << v.position end end end p "VERTICES POSITIONS = #{vertices_posy}" p "POINT POSITION = #{@pt}" Then follow the instructions of TIG.
  • Adding a new group issues

    2
    0 Votes
    2 Posts
    6k Views
    S
    Your snippet is missing some key contextual info from the surrounding code: where was edg created and what does it refer to? Lacking that, it is impossible to guess what face=edg.faces[0] returns, hence what pushpull is acting on.
  • Clearing the model.selection programmatically

    3
    0 Votes
    3 Posts
    9k Views
    S
    Actually, #close_active exits the current edit context, aka active_entities, (belonging to a group or component) and returns to its parent (an enclosing group, component, or the model). Since the selection can contain entities from only one context at a time, all of the currently selected entities have to be in the active context and have to be cleared when you close it.

Advertisement