ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • Extension creation code

    2
    0 Votes
    2 Posts
    433 Views
    TIGT
    You have omitted some code and added in other unneeded code. Try: ` # Load the normal support files. require 'sketchup.rb' require 'extensions.rb' Create the extension. ext = SketchupExtension.new('pluginName', File.join('pluginFolder', 'pluginLoader.rb')) # Optionally 'name' the Extension - it can differ from the registered name. ext.name = 'pluginName' Attach some nice info. ext.creator = 'xxxxx' ext.version = '1.0.0' ext.copyright = '2016, xxxxxxxx' ext.description = 'xxxxxxxxxxxxxxxxxxx' # This 'path' is NOT needed. ext.extension_path=File.join(File.dirname(FILE), "pluginFolder" ) Register and load the extension on startup. Sketchup.register_extension(ext, true)` Add in the bold code and remove the struck-through code...
  • Where to store Global Settings for Plugin

    9
    0 Votes
    9 Posts
    1k Views
    TIGT
    Both writing and reading with the registry with http://www.sketchup.com/intl/en/developer/docs/ourdoc/sketchup#write_default and http://www.sketchup.com/intl/en/developer/docs/ourdoc/sketchup#read_default is relatively straightforward and is applicable on an individual version and user basis, and can be construed to cover your own extension name and several key/value pairs as desired. However, the 'friendliness' I alluded to was relating to how it stores some of your data values. You can easily make some tests without attaching it to your main code. The newer versions of Sketchup do quite a good job of storing integers, floats, strings***, arrays*** and hashes and reading them back in successfully. See below for the *** caveats... *** There are some pitfalls to be avoided - e.g. including a double-quote " inside a string [e.g. even when properly escaped with a \]... so do NOT write "1'6\"" as a string, because you cannot read it back [the read back and now 'un-escaped' " produces an error], so you must use "1'6\\\"" to ensure that the enclosed " is properly escaped as \" when it's written, so it can be read back successfully... This sidestep applies to any plain string and also any string stored inside an array [where Ruby also encloses these inside double-quotes], but perversely hashes are OK with this because when a string is inside a hash that's written to the registry it is properly escaped 'doubly' [ "1'6\\\"" >> "1'6\""] so reads back in OK without any trapping here... These are just annoyances which can be got around... But watch out for them...
  • Icon Sizes

    2
    0 Votes
    2 Posts
    569 Views
    thomthomT
    Originally icons for SU where 24x24 and 16x16. However, when the toolbar system got updated for SU8 on Windows they technically changed to 32x32 and 24x24. When I say "technically" it's because the icons shipped in SU wasn't visually larger. They just got updated with extra white-space padding. The API layer automatically applied padding to smaller icons. Now, since then my history is a bit fuzzy. I don't recall if out icons now are actually larger. But you could, via the API make a small icon fill out a full 24x24 size. But you should check if the outer edge might overlap with some of the button borders. Verify that they look similar to the rest of the toolbar icons in SU. Also, I observed recently on OSX that different sizes will might look fuzzy on a low-res monitor. I think the larger icons looks better in the main OSX toolbar, but will look blurred in the floating toolbar.
  • Newbie Ruby Question

    6
    0 Votes
    6 Posts
    983 Views
    TIGT
    To find the face in its 'context' you need to use definition.instance[0].entities or group.entities rather than model.active_entities, or model.entities
  • Ruby API and Ruby classes

    2
    0 Votes
    2 Posts
    623 Views
    S
    It is entirely permissible and pretty common to devote one file to each class. However, if you do so you will need to put your files into your own subfolder of Plugins, because otherwise SketchUp will try to load all of the individual .rb files as it starts up, which is not what you need. Instead, you should have a master file that loads/requires the others as and when needed. Also, you should look into the SketchUpExtension class, as it provides a natural way to manage your code in SketchUp. And, above all, you should wrap all of your code inside your own personal module to prevent it from clashing with other plugins and extensions.
  • Re-apply texture / move UVs inside a component

    4
    0 Votes
    4 Posts
    776 Views
    E
    Here it is working by shoving texture opposite way. It breaks when doing any rotations, as the texture moves relative to component axis which is now rotated relative to red/green axis. There are manual workarounds, not very convenient though. The inbuilt sketchup eyedropper/bucket works perfectly because it ignores all that and just projects it on, just couldn't simulate it in ruby, so had to go the moving texture opposite direction to component. [image: JosV_texturemapping.gif]
  • Knowing that a face contains another face using Ruby API ?

    10
    0 Votes
    10 Posts
    920 Views
    M
    oh oky i understand now, thank you soo much this realy helped (y)
  • Help getting Parallel Projection in current view from Ruby

    3
    0 Votes
    3 Posts
    1k Views
    S
    Thanks thomthom, you never let me down.
  • Texture from url?

    39
    0 Votes
    39 Posts
    6k Views
    thomthomT
    For HTTPS connections you need to enable SSL when you create the HTTP connection. Note that there's a bug in Ruby that shipped with SU2014-2016 that might cause problems under Windows where the shipped SSL certificates might not work.
  • SU to VB6.0 (Or there and back again.) :)

    9
    0 Votes
    9 Posts
    7k Views
    Dan RathbunD
    @marthmatica said: So as an example I did a SkecthUp cafe creator, driven from Excel face point data per row. Maybe someone will find this useful, or a better way to do it, or improve my Ruby, since I am just starting on the Ruby end. Ruby improved. See new topic: [Code] Geometry Creation from Excel worksheet data
  • Dynamic Component Instances and File Size?

    15
    0 Votes
    15 Posts
    1k Views
    P
    this maybe solved by a simple trick via Dave http://forums.sketchup.com/t/components-with-attributes-creates-unique-copy-when-attributes-changed/21491/3
  • Checking Template Units

    3
    0 Votes
    3 Posts
    551 Views
    thomthomT
    You don't really check the templates - you just ask the current model the user is using. The current model might be of a different unit than their selected template. At my previous job we switched a lot between mm and m in our project files. You use model.options to inspect the current model's options: options_manager = Sketchup.active_model.options options_manager.keys.each { |options_provider_name| puts options_provider_name options_provider = options_manager[options_provider_name] options_provider.each { |key, value| puts "> #{key} - #{value}" } } Output from that snippet: PageOptions > ShowTransition - false > TransitionTime - 2.0 UnitsOptions > LengthPrecision - 0 > LengthFormat - 0 > LengthUnit - 2 > LengthSnapEnabled - false > LengthSnapLength - 0.03937007874015748 > AnglePrecision - 1 > AngleSnapEnabled - true > SnapAngle - 15.0 > SuppressUnitsDisplay - false > ForceInchDisplay - false SlideshowOptions > LoopSlideshow - true > SlideTime - 1.0 NamedOptions PrintOptions > PrintWidth - 8.5 > PrintHeight - 11.0 > ComputeSizeFromScale - false > SizeInPrint - 1.0 > SizeInModel - 1.0 > VectorMode - false > FitToPage - true > NumberOfPages - 1 > LineWeight - 0.5 > PixelsPerInch - 150.0 > SectionSlice - false > ModelExtents - true > PrintQuality - 0 > ScaleAdjustment - 1.0 > QualityAdjustment - 1.0 So in this case you want to inspect UnitOptions: model = Sketchup.active_model model.options["UnitsOptions"]["LengthUnit"] Note that you want to use the constants in the class Length against the values returned here. Length;;Decimal Length;;Architectural Length;;Engineering Length;;Fractional Length;;Inches Length;;Feet Length;;Millimeter Length;;Centimeter Length;;Meter So something like this: model = Sketchup.active_model unit_type = model.options["UnitsOptions"]["LengthUnit"] metric = case unit_type when Length;;Millimeter, Length;;Centimeter, Length;;Meter true else false end I'm doing this check because LengthFormat got options that can be used with both imperial and metric units.
  • Help hiding groups and components from Ruby prompt.

    5
    0 Votes
    5 Posts
    680 Views
    S
    Heh, I opened that can of worms and closed it real quick. I went to an array from a list of model names to hide. I am much happier this way. Thanks
  • Cross-platform hardware detection

    12
    0 Votes
    12 Posts
    831 Views
    D
    I know variations on ifconfig en0 ether.to_s.split('ether ')[1].strip have proven robust for a few authors... but my question to all of them is why? @bomastudio what is your licensing strategy? you may not need to be so invasive... john
  • Scrambler issue

    31
    0 Votes
    31 Posts
    4k Views
    WhyDiW
    Hi Driven Mac version has always been in the tube but at the very bottom of the stack. Each time we talk about we decrease its rank. what a shame! As you said the user number led us at first but you've just added an argument that might change our mind. On the other hand I would have liked to make you pleased. My thought also goes to slbaumgartner who helped me in the past (I think he also is Mac user). Mac users are so kind to help us and we haven't done much four you. So I'm ready to get even more involved although I know hardly anything about OSX. We meet next Friday evening and If you wish I may fight a bit so that Mac version raises at the top of the pile. Would you? I think I could achieve to persuade from these two arguments.
  • Geocoder for Sketchup Ruby API

    3
    0 Votes
    3 Posts
    644 Views
    M
    No it's not built inside google map. i'm creating a model of a house that exists in real life, ad i write it's address in an inputbox. now i want to creat a plugin that shows the location of that house on google map based on the address i wrote .
  • DLL callback to ruby

    41
    0 Votes
    41 Posts
    10k Views
    Dan RathbunD
    You will need to do some studying: Read and bookmark this post: [Info] C/C++ Ruby extensions & SketchUp plugins You will need to download the Ruby C source, as your DLL code must: %(#404080)[include "ruby.h"] Read the old "Pick-Axe" book's chapter on writing a Ruby extension. Programming Ruby: Extending Ruby Take note of the Ruby C-side functions: rb_eval_string( *string_to_eval* )* rb_funcall ... described in section "Evaluating Ruby Expressions in C" okay, a dedicated C side Ruby book is also now available: http://media.pragprog.com/titles/ruby3/ext_ruby.pdf
  • Level Import to UE4

    5
    0 Votes
    5 Posts
    1k Views
    Dan RathbunD
    @bentet said: Can anyone give me some pointers on where I can start? I can write a few simple things in ruby, but this kind of functionality is somewhat beyond my scope at the moment. A tutorial link and a few pointers from more experienced developers would go a long way. --> topic: SketchUp-Ruby Resources Before you can use the SketchUp API with Ruby, you need to learn the basics of Ruby, including how to look up methods for the Ruby Base classes.
  • Convert Layer Pointer to Layer Name, How?

    5
    0 Votes
    5 Posts
    608 Views
    TIGT
    As @Jim says, you need to access the layer by its ' .name' So you need something like: Sketchup.active_model.selection.each{|e|e.material="red" if e.layer**.name**=="Bozworth"}
  • Using Visual Basic 2008 Express dialog form in Ruby.

    15
    0 Votes
    15 Posts
    4k Views
    M
    Who just loads up some guys exes and dlls with no source? Geez, just load up the vb project.

Advertisement