🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download
  • Model.raytest broken in SU8!

    58
    0 Votes
    58 Posts
    6k Views
    thomthomT
    hmm - would be nice with a C++ Hello world of a Ruby Extension.
  • Boolean: how do I 'outershell' multiple groups/components?

    12
    0 Votes
    12 Posts
    1k Views
    Dan RathbunD
    @liquid98 said: good guess! that's the plan indeed. I did not guess ... I can read your mind (scary music: [Oooo ooOOooo ooooo]) No actually, I read your sample code in the post of 17 MAR ... the first two lines you are opening a skp file, within the code. In that post, you wrote: @liquid98 said: But the script I'm writing is for internal use. Is this to be used within a commercial setting (for commercial work.) ??
  • Create Texture via Ruby or/and win32-api

    3
    0 Votes
    3 Posts
    317 Views
    A
    @dan rathbun said: FYI... SketchUp uses PaintLib internally. It's openSource... see: http://www.paintlib.de/paintlib/ and the source here: http://sourceforge.net/projects/paintlib/ Thanks, converting textures to the other formats, sounds good. Is there is a reference on how to create a bmp(a simple file mode) file, set the width/height of the image and set the color of the each pixel?
  • New URL for SketchUp's API documentation

    21
    0 Votes
    21 Posts
    5k Views
    P
    For me it's simple: For registered users give the opportunity to comment on incorrect information/give more explanation and give possibility to add code examples. I always like the way PHP does it: http://php.net/manual/en/function.include.php If you give us the tools, we help you with the content...
  • Rubber Duck Debugging

    2
    0 Votes
    2 Posts
    303 Views
    P
    'explains code to an inanimate object' I'd prefer this: [image: beer.jpg] Downside is that after a while you'll need to debug what you are saying
  • Material names changed by SketchUp

    4
    0 Votes
    4 Posts
    558 Views
    TIGT
    Recent versions of the API allow you to change a material's name in code. If you have a tool that's using a file of data that is material-name specific then clearly you need to know which of the possible materials with similar names it is to be applied to. There are several possibilities. You manually add a material from a library with the name 'Stonewall', there is NO preexisting material with that name, and therefore the new material gets called 'Stonewall'. You have a material already in the model named 'Stonewall' and you manually add a material from a library with the same name, and therefore the new material gets called 'Stonewall1'. You have a material already in the model named 'Stonewall' and you manually add a material from a library with the same name, and therefore because there's also a material in the model named 'Stonewall1' the new material gets called 'Stonewall2' [this will go on until 'Stonewall999' and beyond!]. You have a material already in the model named 'Stonewall1' and you manually add one from a library with the name 'Stonewall', and because there's NO material in the model named exactly 'Stonewall' so the new material gets called 'Stonewall'. So how do you decide which is the real 'Stonewall' material you want? It's likely that the model.materials collection is in the order they are created [at least in a session]. Therefore to find the 'true' 'Stonewall' material try this: name='Stonewall' ### or any other material name to be found... mat=Sketchup.active_model.materials.to_a.find_all{|m|m.name=~/^#{name}/}[-1] Thus the last match in the matches list is the material last added, so logically is the one you want? To get that material's name use mat.name...
  • [observer issue] onEraseEntities not working?

    4
    0 Votes
    4 Posts
    277 Views
    Dan RathbunD
    That's interesting.. I did not realize we could make code blocks have smaller text.
  • [Question]how to load a tool from an external .rb file

    4
    0 Votes
    4 Posts
    132 Views
    R
    Thank you Dan. It worked I have started to go through the Ruby Resource as you suggested. And I also found the answer for my own question in there.
  • Combining 2 groups of entities?

    2
    0 Votes
    2 Posts
    99 Views
    Dan RathbunD
    begin # model.start_operation('Add nested group') ### OPERATION # editents = model.active_entities() topgrp = editents.add_group() topents = topgrp.entities() group1 = topents.add_group() r_entities = group1.entities() #(add entities to group1 here) group2 = topents.add_group() rr_entities = group2.entities() #(add entities to group2 here) # ### model.commit_operation() # rescue Exception => e model.abort_operation() puts(e.message) puts(e.backtrace) end
  • Auto create an given item at a calculated location? See insi

    2
    0 Votes
    2 Posts
    92 Views
    TIGT
    I suggest you read the API... https://developers.google.com/sketchup/docs/ The entities.add_...() methods do want you want... You'll also need to understand Transformations [simple will do!] used to locate some things like 'instances'... and how to create objects like Point3d and maybe Vector3d... There many freely available snippets and full-scripts, that already do what you seek, so there's no need to reinvent the wheel from scratch - just understand what you are doing... I might move this into the Developers' Forum... [EDIT: done.]
  • Component definition list from Ruby vs SU window

    5
    0 Votes
    5 Posts
    434 Views
    P
    great, thank you both for the information!
  • Rotating a board into XY plane

    2
    0 Votes
    2 Posts
    147 Views
    Dan RathbunD
    John.. I checked the [ Code Snippets ] Index ... ... and I did find this from TIG: [ Code ] Transformation_Extensions
  • Will NOT scramble ??

    44
    0 Votes
    44 Posts
    2k Views
    K
    @dan rathbun said: OH wait !! I'll fix the example. Sheesh that was a dumb one. (I had actually tested it with the "load on start" parameter, set to false. So this error did not happen for me in testing.) DONE Now I see the contours of a TEMPLATE for future plugins made in THE RIGHT WAY in a HURRY - that's good practice I think ! Still I have some claims and I'll try figure it out myself before I seek you help
  • Download Plug-In

    7
    0 Votes
    7 Posts
    244 Views
    Dan RathbunD
    Since he is using the extended Ruby libraries, with a full Ruby install... @tig said: Instead of trying to deflate the compressed file as it arrives ... why not download the compressed files into a temporary folder ... Net::FTP @tig said: ... then extract their contents ... Zlib @tig said: ... finally move the extracted files to their final destination, and tidy up by erasing the unneeded compressed files and their temporary folder... FileUtils
  • How toget a Settings Menu to communicate with a Main Menu?

    18
    0 Votes
    18 Posts
    1k Views
    Dan RathbunD
    @tomot said: ..., I realize that Goto can easily be satisfied using if. No it cannot. @tomot said: My current Ruby already contains some 20 if statements, which are goto's. No they are not branching statements, they are conditional statements. But you CAN make them branch off to some other part of your code, by making method calls, in response to the boolean evaluation of the conditional expressions. if condition_is_true then call_method_one() else call_method_two(); @tomot said: I should be able link via another if statement the sharing of the stored registry value of the @stylewidth in Dialog 1 and Dialog 2.. Again... in a procedural language, a method call (aka procedure call,) takes the place of the old goto from the old sequential linear languages like Fortran and GW-BASIC. Whenever you identify a particular place in your code, that you need to "goto" (usually repeatedly,)... then THAT is the spot where you need to begin a method.
  • Storing last values used in the registry?

    13
    0 Votes
    13 Posts
    1k Views
    TIGT
    The Sketchup.read_defaults and Sketchup.write_defaults use each PC's Sketchup 'Registry' entries OR a MAC's Sketchup 'plist' file entries... so they should work cross-platform. The main issue with using the Registry is storing data restructured into a format that can be recovered and then converted back into the required 'class' later - e.g. a string/float/integer/length/boolean/array/hash etc will need some 'manipulation' before writing - but if you have been using a 'file' to store such things then you've been writing them as strings already - when you reread the file you presumably convert the strings back with say string.to_f to make the value a number etc... [like an 'ini' file]. The Registry data exists across sessions globally for Sketchup on each PC, not just the current SKP. So if you want SKP specific data saving then it's best to use model-attributes to save things with the SKP [you can save attributes as most common data types directly - except a hash] - the data is thereby accessible to all uses on the network when you script reads the attributes as it runs, and later updates the attributes as it closes, this can all be done independent of each PC's Registry entries. Horses for courses...
  • Create new instance of a Ruby object in C?

    12
    0 Votes
    12 Posts
    2k Views
    thomthomT
    After snooping around the Ruby source and looking how it's done there, it looks like this is the way to go: <span class="syntaxdefault">struct Color<br /></span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">  unsigned char red</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> green</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> blue</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> alpha</span><span class="syntaxkeyword">;<br />};<br /><br /></span><span class="syntaxdefault">static VALUE<br />color_to_sketchup</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> Color color </span><span class="syntaxkeyword">)<br />{<br /></span><span class="syntaxdefault">  VALUE mSketchup</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> cColor</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">  VALUE skp_color</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> args</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">4</span><span class="syntaxkeyword">];<br /></span><span class="syntaxdefault">  <br />  mSketchup </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> rb_const_get</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> rb_cObject</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> rb_intern</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxstring">"Sketchup"</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">  cColor </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> rb_const_get_at</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> mSketchup</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> rb_intern</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Color"</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">  <br />  args</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> rb_float_new</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> color</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">red </span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">  args</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">]</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> rb_float_new</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> color</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">green </span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">  args</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">]</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> rb_float_new</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> color</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">blue </span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">  args</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">3</span><span class="syntaxkeyword">]</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> rb_float_new</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> color</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">alpha </span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">  <br />  skp_color </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> rb_class_new_instance</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> 4</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> args</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> cColor </span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">  <br />  return skp_color</span><span class="syntaxkeyword">;<br />}</span><span class="syntaxdefault"> </span>
  • Can Sketchup Ruby find the path of a SKM file?

    5
    0 Votes
    5 Posts
    631 Views
    TIGT
    As said... there are currently no access to SKMs in the API [only materials and textures], but my SKMtools do add extra methods to allow you to import a SKM file as anew material, export a material as a SKM file, and do several other things - like extract a SKM's image and thumbnail etc... Search the Plugins Index and get it...
  • Changing cursor insertion point on bounding box

    11
    0 Votes
    11 Posts
    959 Views
    F
    Thanks TIG, I haven't gotten around to trying what you suggested but I will soon enough.
  • Add item to SU main menu

    7
    0 Votes
    7 Posts
    233 Views
    Z
    @unknownuser said: ...add a 'BIM' submenu to the 'Tools' menu and put everything inside that... this way is good ,I hope add "BIM" menu at the SU main menu yet,thanks TIG; and driven's way is very nice! how can do for it ?

Advertisement