⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update
  • [plugin/code] get global coordinates, the brute force way

    4
    0 Votes
    4 Posts
    1k Views
    A
    Here's a piece of code I've written for the new project to get stuff from groups/components. Maybe you'll find it useful: # ------------------------------------------------------------------------------ # # Anton Synytsia # anton.synytsia@gmail.com # # ------------------------------------------------------------------------------ module MSPhysics module Group # @!visibility private VALID_TYPES = [Sketchup;;Group, Sketchup;;ComponentInstance].freeze # @!visibility private INVALID_TYPE = 'The specified entity is not a group or a component!'.freeze module_function # Get entities of a group/component/definition. # @param [Sketchup;;Group, Sketchup;;ComponentInstance, Sketchup;;ComponentDefinition] ent # @return [Sketchup;;Entities, NilClass] # @since 1.0.0 def get_entities(ent) case ent when Sketchup;;Group, Sketchup;;ComponentDefinition ent.entities when Sketchup;;ComponentInstance ent.definition.entities else nil end end # Get all edges of a group/component. # @param [Sketchup;;Group, Sketchup;;ComponentInstance] ent # @param [Boolean] recursive Whether to include all the child groups and # components. # @param [Boolean] transform Whether to give points in global coordinates. # @return [Array<Array<Geom;;Point3d>>] An array of edges. Each edge # represents an array of two points. # @since 1.0.0 def get_edges(ent, recursive = true, transform = true) unless VALID_TYPES.include?(ent.class) raise INVALID_TYPE end edges = [] get_entities(ent).each { |e| if VALID_TYPES.include?(e.class) and (recursive == true) edges.push *get_edges(e, true, true) next end next unless e.is_a?(Sketchup;;Edge) edge = [] e.vertices.each { |v| edge.push v.position } edges.push edge } if transform == true edges.each { |edge| edge.each { |pt| pt.transform!(ent.transformation) } } end edges end # Get vertices from all edges of a group/component. # @param [Sketchup;;Group, Sketchup;;ComponentInstance] ent # @param [Boolean] recursive Whether to include all the child groups and # components. # @param [Boolean] transform Whether to give points in global coordinates. # @return [Array<Geom;;Point3d>] An array of points. # @since 1.0.0 def get_vertices_from_edges(ent, recursive = true, transform = true) unless VALID_TYPES.include?(ent.class) raise INVALID_TYPE end pts = [] verts = [] get_entities(ent).each { |e| if VALID_TYPES.include?(e.class) and (recursive == true) pts.push *get_vertices_from_edges(e, true, true) next end next unless e.is_a?(Sketchup;;Edge) e.vertices.each { |v| verts.push(v) unless verts.include?(v) } } verts.each { |v| pts.push v.position } if transform == true pts.each { |pt| pt.transform!(ent.transformation) } end pts end # Get all faces of a group/component. # @param [Sketchup;;Group, Sketchup;;ComponentInstance] ent # @param [Boolean] recursive Whether to include all the child groups and # components. # @param [Boolean] transform Whether to give points in global coordinates. # @return [Array<Array<Geom;;Point3d>>] An array of faces. Each face # represents an array of points. # @since 1.0.0 def get_faces(ent, recursive = true, transform = true) unless VALID_TYPES.include?(ent.class) raise INVALID_TYPE end faces = [] get_entities(ent).each { |e| if VALID_TYPES.include?(e.class) and (recursive == true) faces.push *get_faces(e, true, true) next end next unless e.is_a?(Sketchup;;Face) face = [] e.vertices.each { |v| face.push v.position } faces.push face } if transform == true faces.each { |face| face.each { |pt| pt.transform!(ent.transformation) } } end faces end # Get vertices from all faces of a group/component. # @param [Sketchup;;Group, Sketchup;;ComponentInstance] ent # @param [Boolean] recursive Whether to include all the child groups and # components. # @param [Boolean] transform Whether to give points in global coordinates. # @return [Array<Geom;;Point3d>] An array of points. # @since 1.0.0 def get_vertices_from_faces(ent, recursive = true, transform = true) unless VALID_TYPES.include?(ent.class) raise INVALID_TYPE end pts = [] verts = [] get_entities(ent).each { |e| if VALID_TYPES.include?(e.class) and (recursive == true) pts.push *get_vertices_from_faces(e, true, true) next end next unless e.is_a?(Sketchup;;Face) e.vertices.each { |v| verts.push(v) unless verts.include?(v) } } verts.each { |v| pts.push v.position } if transform == true pts.each { |pt| pt.transform!(ent.transformation) } end pts end # Get all construction points and lines of a group/component. # @param [Sketchup;;Group, Sketchup;;ComponentInstance] ent # @param [Boolean] recursive Whether to include all the child groups and # components. # @param [Boolean] transform Whether to give points in global coordinates. # @return [Array<Geom;;Point3d>] An array of points. # @since 1.0.0 def get_construction(ent, recursive = true, transform = true) unless VALID_TYPES.include?(ent.class) raise INVALID_TYPE end pts = [] get_entities(ent).each { |e| if VALID_TYPES.include?(e.class) and (recursive == true) pts.push *get_construction(e, true, true) next end if e.is_a?(Sketchup;;ConstructionPoint) pts.push e.position elsif e.is_a?(Sketchup;;ConstructionLine) pts.push(e.start) unless e.start.nil? pts.push(e.end) unless e.end.nil? end } if transform == true pts.each { |pt| pt.transform!(ent.transformation) } end pts end end # module Group end # module MSPhysics
  • Trial Version

    5
    0 Votes
    5 Posts
    347 Views
    TIGT
    But for a low cost script decrypting an rbs to see how it is licensed hardly seems worth the effort. In contrast simply reading a plain rb is much easier to do and more likely to lead to a license breach. Encrypting data/licenses is never going to be 100% 'hacker-proof' - but neither is your front-door lock - but you'll have one and use it anyway - just to stop a casual intruder walking in and stealing your laptop - but a determined thief will know how to open most locks - or just enter another way...
  • Web dialog on a Mac

    69
    0 Votes
    69 Posts
    8k Views
    G
    This issue has been resolved. I am now substituting single quote ' for back tick ` and then back again. This allows us to see the single quote in the web dialog controls.
  • Exposing Ruby Code?

    4
    0 Votes
    4 Posts
    287 Views
    M
    @dan rathbun said: The SketchUp engine that performs normal tasks, is written in C/C++, and compiled. I was unaware of that, Dan, thanks for letting me know. Ah well, back to feebly trying to wrap my brain around Ruby
  • To create script I need to add GEM to Sketchup's Ruby

    4
    0 Votes
    4 Posts
    501 Views
    TIGT
    Yes I have also looked at 'packaging' other Ruby methods with mine to give extended functions in distributed scripts [I gave up!]. The real complexity is that as soon as you look to import one new moved over method, then you'll almost certainly find that it includes 'requires' for several other files, these files in turn require other files and so on. You'll end up with a massive tangle of files/subfolders 'requiring' other files ad nauseam, and one mistype/misplaced line of code breaks everything - makings untangling it all very very hard...
  • Guidelines for adding a method to existing classes?

    12
    0 Votes
    12 Posts
    612 Views
    danielbowringD
    @tt_su said: Note that extending Entity instances would not be allowed by EW because the instances are global to everyone using the SketchUp environment. But for other types such as Point3d, Vector3d, String etc that would work. Here delegators can be useful. require 'delegate' module DanielB class SampleFace < DelegateClass(Sketchup;;Face) def inner_loops return loops.find_all { |l| l != outer_loop } end end def self.demo face = Sketchup.active_model.selection.find { |e| e.is_a?(Sketchup;;Face) } return if face.nil? face = SampleFace.new(face) puts face.inner_loops end end
  • One-shot toolbar buttons?

    11
    0 Votes
    11 Posts
    519 Views
    tt_suT
    Oh, right - yes I noticed that there's a bug under OSX. Sorry, I mostly use PC so I'd forgotten. I think there's an issue for it, but I'll check again and bump it.
  • Statistics on plugin users

    21
    0 Votes
    21 Posts
    1k Views
    jiminy-billy-bobJ
    @garry k said: This probably should be moved to another thread. Probably
  • Help! When an Object get touched by a Shadow (sun shade)

    4
    0 Votes
    4 Posts
    572 Views
    JuantxoJ
    You need to know if a panel is in shadow or not using this 2 vectors and using cosine law panel verctor-> v=Sketchup.active_model.selection[0].normal sun vector-> s=Sketchup.active_model.shadow_info["SunDirection"] But you need to know also if there is some object projecting shadow over the panel using raytest with sun vector and some points of the panel. You can modify this step and look for other methods if you need more accuracy...
  • Preserve integrity of curves when creating faces

    2
    0 Votes
    2 Posts
    249 Views
    D
    I think in the plugin code "weld" is what you need (google translator)
  • Maxwell export plugin for skecthup

    6
    0 Votes
    6 Posts
    4k Views
    brodieB
    This is probably a better solution since there are different versions of Maxwell and SU. You should be able to download the plugin including the exporter here... http://www.maxwellrender.com/index.php/try/sketchup -Brodie
  • Read_default webdialog position on OSX

    5
    0 Votes
    5 Posts
    393 Views
    D
    @jiminy-billy-bob said: it has to consider the window border. macs don't have window borders... available using vanilia.js from one of my webDialogs... outerHeight; 370 outerWidth; 422 pageXOffset; 0 pageYOffset; 0 parent; Window parseFloat; function parseFloat() { parseInt; function parseInt() { personalbar; BarProp constructor; BarPropConstructor visible; false __proto__; BarPropPrototype screen; Screen availHeight; 1174 availLeft; 0 availTop; 22 availWidth; 1920 colorDepth; 24 constructor; ScreenConstructor height; 1200 pixelDepth; 24 width; 1920 __proto__; ScreenPrototype screenLeft; 100 screenTop; 420 screenX; 100 screenY; 420 scrollX; 0 scrollY; 0 scr
  • Using each_slice possible?

    10
    0 Votes
    10 Posts
    1k Views
    Dan RathbunD
    You get a NoMethodError because Enumerable does not have that method defined in Ruby 1.8.x. This should do the same, except you pass the array in as the 1st argument: def slicer(ary,num) a2 = ary.dup len = num.to_i.abs until (s = a2.slice!(0,len)).empty? if block_given? yield(s) else puts(s.inspect) end end # until end # slicer() See another example that will collect the slices into an output array, IF a block is NOT given. (Sort of like the opposite to flatten().) If a block is given, it returns an array of the block's return values. Prints to $stdout only if $VERBOSE == true. Fixed absolute call. It is not a Math module function. It is a standard Ruby Numeric instance method.
  • Painting effect

    4
    0 Votes
    4 Posts
    353 Views
    mitcorbM
    And now, I recall having looked at this thread. Sorry for any misinformation, and thanks to pbacot
  • Progress bar

    4
    0 Votes
    4 Posts
    908 Views
    Chris FullmerC
    SketchUp does that just by writing text to the status bar. a series of | characters to show progress. You can mimic the same behavior, but you do have to re-write it yourself.
  • Multiple objects to groups

    8
    0 Votes
    8 Posts
    504 Views
    W
    @chris fullmer said: That was the first script I wrote and published, for this EXACT purpose. You can find it here: http://www.smustard.com/script/Loose2Groups Thanks so much, works perfectly
  • JScript innerHTML not working in WebDialog !

    8
    0 Votes
    8 Posts
    998 Views
    S
    @tt_su said: @onidarbe said: So Sketchup uses IE instead of Chrome, although I uninstalled IE? strange You cannot completely uninstall IE. You may have uninstalled the front-end, but the IE engine is embedded deep into the OS. Help files (chm files) are using the HTML engine, HTA files are also using it. And the embedded HTML IE webcontrol is more conservative in terms of compatibility, which is why you need to use META tags to force WebDialogs to use the very latest IE engine. And because so many things use the system HTML engine I recommend you keep IE up to date, even if you use a different browser. You can never remove it 100% anyway. The "uninstaller" is just a shim to please the public (and EU anti-trust). For Mac users, the equivalent statement is that SketchUp uses the WebKit Framework, not Safari. Just as on Windows, your choice of browser has no effect on what SketchUp's WebDIalogs do.
  • .gsub( /\n/, &quot;\n\r&quot; ) not working in WebDialog

    10
    0 Votes
    10 Posts
    1k Views
    onidarbeO
    Thanks Dan! But in this case I want for those maybe using my stuff to make it readable in notepad to
  • List of all possible functions

    13
    0 Votes
    13 Posts
    1k Views
    tt_suT
    @tig said: I know TT has done some 'shortcut fiddling' with some of his tools [VertexTools?], so pressing M is Move [Vertex] in that tool, rather than invoking the native Move, which already uses that shortcut, and will do so when TT's tool is exited... Perhaps TT can explain what he does to allow that... the files re encrypted... I never modified the shortcuts. What I did in Vertex Tools was that I wanted to activate Vertex Tool's Move tool when vertex mode was activated, and the native Move tool when it was not. So I created a method that did that - but the user still had to reassign it's short-cuts to my proxy-delegating command.
  • Applying new Material to a Selection is extremely slow

    6
    0 Votes
    6 Posts
    474 Views
    dkendigD
    good catch

Advertisement