ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • [Code] Change Axes of a Group

    4
    0 Votes
    4 Posts
    1k Views
    K
    OK, here is the solution for anyone who needs it in the future: # accepts either one or two arguments. The first is always the group or component where the axes needs to be corrected # the second can be a parent group or component (something that has a transformation). If nothing is passed in, the global # model x,y, and z axes will be used. The parent attribute should be used any time there is a nested component. def change_axes_to_parent(*args) if args.length == 1 g = args[0] p_t = Geom;;Transformation.new else g = args[0] p_t = args[1].transformation end t = g.transformation #p_t = parent.transformation if t.xaxis != p_t.xaxis || t.yaxis != p_t.yaxis || t.zaxis != p_t.zaxis o = t.origin # different axes, require that all components inside be rotated tran = Geom;;Transformation.axes o, t.xaxis,t.yaxis,t.zaxis t_o = Geom;;Transformation.new o if g.is_a? Sketchup;;Group ents = g.entities elsif g.is_a? Sketchup;;ComponentInstance ents = g.definition.entities end ents.transform_entities tran, ents.to_a ents.transform_entities t_o.inverse, ents.to_a g.transform! tran.inverse g.transform! o end end
  • Getting user home directory

    4
    0 Votes
    4 Posts
    224 Views
    Dan RathbunD
    As my code does: ENV['HOME']=ENV['USERPROFILE'] unless ENV['HOME'] ENV['USER']=ENV['USERNAME'] unless ENV['USER'] # now set a global; $HOME = ENV['HOME'] # .. or use the tilde shortcut within pathstrings. BTW.. the " ~*user*" feature does not work on Windows. Likely because of Security issues.
  • Plugin w/o script in Plugins folder???

    14
    0 Votes
    14 Posts
    763 Views
    Dan RathbunD
    The diagram (previous post,) was prompted by yet another argument over what was a Tool, and what was a Utility, whether they were Plugins or Extensions, or both. My argument is that everything loaded into Ruby (except the Core,) is an Extension. Then 3 main types: Plugin, Library and Service. Although I show 3 "kinds" of Plugins, in reality there is often overlap. A given plugin may have several, (if not all,) subtypes as features.
  • SketchUp Ruby Dos and Don'ts (Best Practices)

    7
    0 Votes
    7 Posts
    2k Views
    Dan RathbunD
    @morisdov said: @jim said: Please add your own "Do and Don't" recommendations for writing SketchUp Ruby code. DO wrap your plugin in a module (namespace) to avoid clashes. DON'T use another person's registry keys, namespaces, or attribute_dictionaries. The problem is you dont know who might have used what "name" , there are far too many other people out there for one to research their obvious common sence choices of keywords. NO .. it's actually easy. If you stay in YOUR namespace, you can have your Plugin module(s) be any name and they will not clash. Then.. use the namespace nesting to construct a unique registry key: module Author module Widget # Construct a registry key to save the plugin options under; # @@opt_key = "Plugin_#{Module.nesting[0].name.gsub(/(;+)/,"_")}" # Remove whitespace and non-word chars (just in case.) @@opt_key = @@opt_key.gsub(/\s+/,"_").gsub(/\W+/,"") # the key will be; "Plugin_Author_Widget" end end Then you can use the registry key also as a prefix for any AttributeDictionary objects that this plugin uses: module Author;;Widget @@dictFlags = "#{@@opt_key}_Flags" # create the dictionary @dict = ent1.attribute_dictionary( @@dictFlags , true ) # the dictionary will be; "Plugin_Author_Widget_Flags" end #module Obviously,.. you replace the word "Author" with your own namespace identifier, and choose the name of your own plugin sub-modules, and their dictionary names.
  • Google Code Now Supports git

    2
    0 Votes
    2 Posts
    141 Views
    thomthomT
  • Getting Started with SketchUp SDK

    3
    0 Votes
    3 Posts
    746 Views
    Dan RathbunD
    Look in dir: source\sketchup\skpwriter\sapi at file: ientity.h
  • SketchUp Orbit Tool

    3
    0 Votes
    3 Posts
    484 Views
    A
    Working on a viewing/walk though/demo plugin. It will allow to create a walk through path and several other options. One of the options is an orbit path. If the center of the orbit is not specified I want it to do whatever sketchUp does.
  • Ruby Script for coloring the selected objects

    4
    0 Votes
    4 Posts
    1k Views
    H
    Thank you very much. The code worked and will be uploading soon... And I am learning ruby for sketchup from basics now..
  • Inputbox with drop down list question

    10
    0 Votes
    10 Posts
    3k Views
    TIGT
    Dan, I stand corrected - clearly the skethcup.rb's 'inputbox' is to be preferred to the UI. version...
  • Determine the origin of a component in world space

    3
    0 Votes
    3 Posts
    175 Views
    S
    @tig said: Every group or component-instance has a complex transformation giving 3d location, rotation, scaling and so on... You can use that insertion_point = instance.transformation.origin I had a feeling you'd be the one to answer TIG, and Thank you, thank you, thank you. Works perfectly. I spent hours pulling hair on this. Don't know why I didn't think of that.
  • Which face is closest?

    7
    0 Votes
    7 Posts
    232 Views
    voljankoV
    @tig said: If you want to know the orientation of a face relative to its edge, then use this http://code.google.com/apis/sketchup/docs/ourdoc/edge.html#reversed_in? You can then compare the three faces sharing a common edge and if one is 'backwards' used face.reverse! OR use face.normal.reverse in the testing ??? This could be exactly what I need,have to test first. Thanks.
  • Double bounding box

    11
    0 Votes
    11 Posts
    400 Views
    Dan RathbunD
    @voljanko said: @dan rathbun said: group.local_bounds() Yes,it is working,I have test it....BUT,it is only available for groups,not components. This is because .definition() is exposed to ComponentInstance objects, so: def get_local_bounds(obj) case obj when Sketchup;;Group obj.local_bounds() when Sketchup;;ComponentInstance obj.definition.bounds() else obj.bounds() end end
  • Find middle edge in four way junction

    8
    0 Votes
    8 Posts
    198 Views
    TIGT
    If a vertex has four edges you trap that each edge only has one face [a taken]. If you get the vertex_normal and use a plane through the vertex.position to flatten [project] the vectors onto for the 4 edges being tested, can we ever get a zero length vector ? I think not, because the dot processing will never make a plane that's 'square' to a given vector - as there must always be some of the 4 edges spring off at angles...
  • Def help!

    6
    0 Votes
    6 Posts
    220 Views
    T
    @kyyu said: Try this: thanks I will give it a try!
  • Explode 1 level component

    8
    0 Votes
    8 Posts
    236 Views
    jolranJ
    So I was wrong in everything I said Yes it was part of some longer piece, I copy and pasted it wrong, sorry.
  • Reverse faces after pushpull??

    8
    0 Votes
    8 Posts
    446 Views
    TIGT
    My idea of using a temporary group means that the faces in the group are all that's needed to consider for reversing - so it very quick; if you are making lists of all entities before and after a pushpull then there might be thousands of them to sift through, twice! ... So why not make a group, add a circular face, pushpull it, reverse the faces in the group, re-add a circular face to the group and erase it, then add a circular face to the main-face and erase it to leave a hole over the grouped 'recess', and finally explode the group? It will be much quicker in most circumstances... and 'safer' too...
  • Problem when running Ruby Script from command line

    16
    0 Votes
    16 Posts
    4k Views
    TIGT
    @dan rathbun said: But I think his intention, is to do batch mode export to dae for a whole dir of skp files. So manual drag-n-drop is out of picture. He can use a shell script, no doubt,... ... but he could also do batch export, from within SU Ruby. You can drop multiple files onto a MAC command file or an 'applet', they are processed in turn, so the code could in turn make txt>>rb, open each SKP dropped; the rb file doing the SKP export, renaming itself txt and closing the SKP for each one. A much simpler way to export a folder of SKPs as .dae is to have a permanently loaded Ruby tool - I quickly wrote this as an example... http://forums.sketchucation.com/viewtopic.php?p=347277#p347277
  • Creating Components in Cab.rb

    26
    0 Votes
    26 Posts
    1k Views
    F
    I fixed a few things and realized I could call the instances I added to the global component by different names. It does run slow but I still haven't looked into optimising scripts so hopefully I can speed it up some though I don't mind it though, it's faster then creating a cabinet from scratch. Next on the to do/ to learn list is... Creating door and drawer fronts, creating drawers... shouldn't be a problem. Add a user defined number of shelves and insert them evenly spaced in the cabinet... I can do this manually/individually but the math involved in doing them automatically should be fun to figure out! Same thing for door and drawer fronts. And give a choice of creating an upper or lower cabinet since the building of these is different... I could use 2 different scripts like I did when moding the cab.rb script but I think it would be slick having it all-in-one. Add grain direction And eventually learning how to export the to a csv file so that I can populate an existing excel spreadsheet that I use... yes I know there are already some cut sheet/list scripts but this is more of a hobby/learning experience and I'd like to see what I can do. That should be it but I'm already happy with the progress I've made in just 3 or 4 days or learning this stuff. Again thanks for all the help I really appreciate your teach how to fish approach. Frank Test.rb
  • Some odd UV coordinates

    6
    0 Votes
    6 Posts
    195 Views
    thomthomT
    What are the UV coordinates you're getting that's so huge? I'm not sure if I've understood the issue. Is it with distorted textures?
  • Observers and undo question

    11
    0 Votes
    11 Posts
    238 Views
    thomthomT
    It's been a bit back and forth. I think it might be a combo - depending on what you do. Even they find the topic troublesome.

Advertisement