🏢 PlaceMaker | 25% off for February including new Google Earth data imports! Learn more
  • [Code] file_found?(path) and to_ascii+to_unicode.rb

    42
    0 Votes
    42 Posts
    6k Views
    Dan RathbunD
    Do not ignore Dan Berger's windows-pr package. It goes along with his win32-api package. Has the Windows "unicode.rb" In windows-apt-0.4.0 there's a complementary file "wide_string.rb"
  • Idea: show console on script error

    13
    0 Votes
    13 Posts
    683 Views
    thomthomT
    The docs should really be mentioning this.
  • Self intersect

    8
    0 Votes
    8 Posts
    254 Views
    voljankoV
    Grrr,I hate the "smart" pages. There are no comments on my API pages.I will try to change setting in my browser. @unknownuser said: But using the 'group.transformation' for both required transformations to ensure that the group's geometry intersects with itself, and it returns the intersection geometry in the same location should work ? Perhaps not if the group has been moved ?? I have tested it... and it is only ok, if both the transformations are "new".
  • Safely extend sketchup class

    9
    0 Votes
    9 Posts
    285 Views
    TIGT
    For your "point and plane test" it's easy enough to make your own tool's method without messing on with any base-classes... def point_test(point, plane, cond=false) ### 'point' is the point to test, ### 'plane' is the plane to test and ### 'cond' allows you to return true/false IF point is ON the plane. ### NOW add your code here that see if the 'point' is on, in front or behind the 'plane' ### returns 'behind' as 'true' or 'false', with a tweak for the 'cond' setting if behind return false else return true end#if end#def Then in other code within your toolset use self.point_test(point, plane, true) where 'point' is to be tested for its relationship with 'plane', and here the third argument 'true' says to take 'point' as being 'in front' even if it's ON the plane too... [you would use no third argument or 'false' if point ON plane is to be 'invalid']
  • Which side of the plane?

    2
    0 Votes
    2 Posts
    120 Views
    TIGT
    That's about it! If the plane is from a face the face.normal is easily found. You could also extract the plane's vector from it's 'array' ? Project the original_point onto the plane, then offset! that cloned_point along the plane's 'normal' vector by the distance between the original_point and its projected cloned_point... and then if cloned_point == original_point the original_point is in front of the plane, otherwise it's behind the plane; you should also check separately for the original_point being exactly on the plane... and decide whether that counts or not.
  • SelectorGadget - Bookmarklet for css and xpath selectors

    2
    0 Votes
    2 Posts
    882 Views
    thomthomT
  • Win32 Utils

    11
    0 Votes
    11 Posts
    401 Views
    thomthomT
    Sure, anyone can use the lib if they want. I've tried to document as much as possible.
  • Weirdest loading bug ever?

    16
    0 Votes
    16 Posts
    680 Views
    Dan RathbunD
    @lothcat said: Thank you so much! It's working now and I'm not having that weird loading bug! Excellent! @lothcat said: Also, thank you for being patient with me. This was a real learning experience. I would be very worried if you had not learned anything, here ....
  • Entities.add_group bug?

    17
    0 Votes
    17 Posts
    681 Views
    TIGT
    As I suspected then... Using ents.add_group(ent_array) only works safely if ents==model.active_entities So use my cloning tips...
  • How do i change length attributes in ruby

    8
    0 Votes
    8 Posts
    728 Views
    TIGT
    If 'lenx' is '=value' can't you change the contents of the 'value' attribute itself [or if that is itself set in some complex way then change the attribute[s] that it is using etc...], which on a redraw then changes the contents of the DC.
  • Understanding module wrapping?

    10
    0 Votes
    10 Posts
    237 Views
    Dan RathbunD
    Programming a Tool class is another topic. It's best to read the examples supplied by Google, in the "Plugins/Examples/linetool.rb" the instance var @state is used to store what 'step' the tool is at.
  • Topic review: Getting Information out of Sketchup

    2
    0 Votes
    2 Posts
    124 Views
    J
    You might have a look at this plugin - it seems similar to what you are describing.
  • WebDialog rendering late on Mac

    7
    0 Votes
    7 Posts
    159 Views
    D
    @thomthom said: Do you have any sample code to demonstrate? I will try to get sample code up here - just busy at the moment... Thanks guys.
  • Rotation Matrix problem

    2
    0 Votes
    2 Posts
    163 Views
    TIGT
    Rotation and Scaling are inexorably linked in a transformation - hence the weirdness... Can I suggest another approach... You are trying to align two objects they both have obj.transformation.axes and you can transform in steps... Therefore you can move the objects together using [ tm=Geom::Transformation.translation(vector_from_point_to_point)] and then rotate one to align with [ tr=Geom::Transformation.rotation(point, axis, angle)] you can 'combine' transformations thus t=tm*tr and then use obj.transform!(t) in one step... but note that the 'order' is important in a matrix * and the order of the transformations it will do is always taken as right-to-left... i.e. the move then the rotation - unlike normal numerical multiplication it's not commutative for matrices! Moving and then rotating will not necessarily give the same result as rotating and then moving - depending on the relativity of points etc... PS: Put your code inside a [ code ]...[ /code ] block as it's easier to read. You are using a $ variable - dangerous as it's exposed to all other tools and such a common name may well clash with other authors' unwrapped code too... Use @ or @@ variables that span methods within your own module/class only... Parenthesize your arguments as method(1, 2, 3) rather than method 1, 2, 3 - although both work upcoming versions of Ruby may well deprecate unparenthesized arguments and even the most recent update caused some problems - I know th API guidance and many example scripts do it the 'wrong way' but it's a good habit to get now, before your code gets out of date unnecessarily...
  • [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
    220 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
    755 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
    140 Views
    thomthomT
  • Getting Started with SketchUp SDK

    3
    0 Votes
    3 Posts
    741 Views
    Dan RathbunD
    Look in dir: source\sketchup\skpwriter\sapi at file: ientity.h

Advertisement