ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • [Talk] Qpik::SimpleRays Overhaul

    11
    0 Votes
    11 Posts
    6k Views
    Dan RathbunD
    v1.0.1 download Moved to Plugins forum. Old v1.0.0 deleted. THIS thread retitled as "[Talk] Qpik::SimpleRays Overhaul"
  • I want to write a ruby script : rotate an object

    11
    0 Votes
    11 Posts
    4k Views
    Dan RathbunD
    @unknownuser said: I want to learn if instead of having a text inputbox you can also have a dropdown menu list with existing layers on it so you can select from there aswell. Yes I have done that.. it is one one my files (somewhere) just guessing it's similar to this: def choose_layer(active=false) model = Sketchup.active_model layset = model.layers deflay =( active ? model.active_layer.name ; layset.first.name ) laylist = layset.map(){|l| l.name }.join('|') results = inputbox(["Layer ;...... "], [deflay], [laylist], " Choose Layer") results ? layset[results.first] ; nil end #
  • How to draw a cylinder by ruby?

    11
    0 Votes
    11 Posts
    3k Views
    D
    hi have a look at linetool.rb and class CylTool < LineTool in the Example scripts folder in ../SketchUp/Plugins/examples/linetool.rb, or download it if it's not...... john
  • Notepad++ SU8 Ruby API Autocomplete

    62
    0 Votes
    62 Posts
    14k Views
    B
    Thanks a lot!
  • Rotation transformation for a component instance

    10
    0 Votes
    10 Posts
    2k Views
    Dan RathbunD
    @honkinberry said: I want to be able to place a component like a bench, and then immediately rotate it about the Z axis. So both the placement and the rotation should be linked very smoothly to accurate cursor position. OH.. well that is extremely EASY. Because that functionality is built-into the native component placement tool, which is accessible from the Ruby API. So.. for example the bench's name is "Bench Wood HighBack" def place_bench() mdl = Sketchup.active_model compdef = mdl.definitions["Bench Wood HighBack"] if compdef mdl.place_component(compdef,false) return true else return false end end The trick is the 2nd argument to Model#place_component() must be false, so that you can use the rotate handles (they appear as little red crosses,) just after you choose the insert point. Insert the bench.. then move the cursor to the top of the comp's boundingbox, and you should see 4 red crosses appear. Hover over one of the cross handles, and the cursor will change to a rotate cursor. Hold & Drag (or Click Move Click,) to rotate about the Z axis.
  • Why creating dictionary triggers onSelectionBulkChange?

    15
    0 Votes
    15 Posts
    463 Views
    D
    @dan rathbun said: ... the engine triggers MISSPELLED dan, I truly thought you had misspelt that and had to Google it... best explanation I could find was this... @unknownuser said: British English shows a preference for retaining strong verb forms (burnt, learnt, spelt, dreamt, spoilt etc). American English shows a preference for ignora... I'm mean simplification (burned, learned etc). john
  • [Code] save Camera properties method

    4
    0 Votes
    4 Posts
    284 Views
    Dan RathbunD
    @greenskp said: all this code is to work in MAC and PC? Yes it will work on both Mac and PC. BUT it is meant for you to copy it INSIDE your plugin sub-module.
  • How to load the system lib of ruby for SU

    5
    0 Votes
    5 Posts
    217 Views
    Dan RathbunD
    SketchUp currently uses Ruby v1.8.6-p287 Ruby (v1.8.6-p287) Windows One-Click Installer Standard Ruby Library folders DO NOT belong in SketchUp's "Plugins" folder. They belong in the Standard Ruby Library folders. Once a user installs the full Ruby edition, SketchUp's Ruby can access it's library folders, by pushing library paths into SketchUp's **$LOAD_PATH** array. See: [ Code ] Ruby LOAD PATHs script (Win32)
  • Extract camera position

    11
    0 Votes
    11 Posts
    309 Views
    renderizaR
    @greenskp said: One more thing. Whit this code i can get camera target position? Dan Rathbun posted a ref link that have things like target, direction, ect example ptarget = @@model.active_view.camera.target ; @greenskp said: It´s possible that to each Scene created i have different coordinates? Not sure what you mean by this. If you click remember camera position in scene manager then yes you will change camera placement with scene. Cheers! Note: Thanks thomthom for explaining why that happened!
  • [code] Is there a way to know if cursor on top of shadow?

    12
    0 Votes
    12 Posts
    293 Views
    Dan RathbunD
    ... because in a boolean expression nil (and false,) eval falsely. Everything else including true, [] (an empty array), and 0 (the integer zero,) evaluate truthfully.
  • How to display Vertex and change color when selected?

    10
    0 Votes
    10 Posts
    452 Views
    Dan RathbunD
    Don't put spaces between method names and their argument lists when you surround the list with** ( )** Ruby generates a warning for every line that has the unneeded space.
  • [code] Sketchup Safe Shutdown method

    10
    0 Votes
    10 Posts
    5k Views
    D
    censored
  • TextureWriter filename - empty response

    5
    0 Votes
    5 Posts
    531 Views
    B
    There appears to be a software defect in the SketchUp API. Loading the textures into TextureWriter and then attempting to access their filenames using TextureWriter.filename(index) returns only empty strings. However, if you call TextureWriter.write_all beforehand: # Display texture names def display_tex_names $tw = Sketchup.create_texture_writer load_textures(Sketchup.active_model.entities) $tw.write_all("D;", false) tex_index = 1 while (tex_index <= $tw.count) UI.messagebox($tw.filename(tex_index)) tex_index += 1 end Sketchup.active_model.commit_operation end then the filenames are returned properly. Confusing matters further, the TextureWriterindices are one-based rather than the expected zero-based array.
  • How to select last entity selected?

    6
    0 Votes
    6 Posts
    209 Views
    renderizaR
    I have tried but seems I can't get it to work or understand correctly. Is there a sample code that can better illustrate this. Thanks!
  • Ruby method to calculate the area of an intersection?

    3
    0 Votes
    3 Posts
    539 Views
    Dan RathbunD
    Assuming f is the reference to the intersecting face object: a = f.area() See the API Face class.
  • [Code] intersect_with?() Group test method

    2
    0 Votes
    2 Posts
    1k Views
    B
    Hi, May I know after determining if the 2 groups/ components/ faces are intersected. How do I get the area of the intersection?
  • How to recognize cursor on top of texture?

    6
    0 Votes
    6 Posts
    225 Views
    thomthomT
    @unknownuser said: Add:: On Material - I am actually happy that the default material returns nil because it may pass as a mask feature But this line will cause an error: if flags == 1 && @@sel != nil && @@texture_addon == true && selected_face_mat.texture != nil If selected_face_mat is nil then you cannot call .texture on it.
  • Geom.intersect_line_line question

    15
    0 Votes
    15 Posts
    557 Views
    thomthomT
    Then it sounds like moving to an Ruby C Extension is what might give real performance improvements.
  • Shortcut key(s) for a plugin(s)

    9
    0 Votes
    9 Posts
    264 Views
    Wo3DanW
    @thomthom said: Gerrit, you mean like my Vertex Tools? Where it offers a set of Move, Rotate and Scale tools for vertex editing? ....... Thank you Thomas. No, I meant the most basic thing where, once a plugin is loaded at startup of SketchUp, the plugin is right available in the menu where you let it appear. And at the same time the plugin can (from thereof) also be reached if you assign a shortcut key to it. I wasn't sure whether "placing in the list" was done automaticaly or if you need to have some extra code in the plugin for the list. Example: I place plugin "AAA" in the folder. Looking at the code I see that "AAA" will show up in menu say "Draw". Looking at the shortcut list I can see that I can assign its use to a key. In my case I don't want to use my plugin through any menu but (say lazy as I am) by hitting a key. As it seems SU handles most of that for me. As long as I let it appear in a menu and than find it in the list of shortcuts for assigning it. Thank you Aerilius, for confirming TIG's answer. The idea I have (and have had for a long time) is simple and takes all you writers about two minutes to write. I just want to put this together myself, as simple as the idea is. Otherwise I'll never learn.
  • Exit plugin from within a function

    4
    0 Votes
    4 Posts
    196 Views
    Dan RathbunD
    @mattc said: def initialize() > sel=Sketchup.active_model.selection > SPP;;test_start > SPP;;check_selection(sel) > SPP;;test_end > end (4) The above is not correct. The initialize() method is only used in a class definition, where you wish to let the user create MANY instances of the object. Users will not need to create many copies of your plugin. Most plugins are code that needs only one copy, .. so it should be a module (inside your author module.) But a plugin module can have (and often does,) use custom class definitions and instances inside it's module. Later on, you will likely be creating a custom Tool class inside your plugin module.

Advertisement