Urasik Extensions | Lots of new extensions to check out Learn More

Subcategories

  • No decscription available

    20 Topics
    462 Posts
    HornOxxH
    @pilou said: More appetizing in chocolate! Eggs are good as well - but only very fragile when falling down in SketchyPhysics
  • Automatic Export Scenes to .dwg/.dxf

    8
    0 Votes
    8 Posts
    3k Views
    C
    I am an avid sketchup promoter and user and have follow and use many extensions created by the authors from this thread i am very interested in being able to export all scenes to layout, does anyone know how you can import all the scenes from your sketchup model into individual viewports in layout, i usually have to create over 50 individual pages and individually select each scene for each viewport, is there any way to do this automatically I would be very grateful to pick your brains let me know if you have anyway of accomplishing this, writing a macro, or anything Please let me know any thoughts you might have cheers!
  • Setting dynamic attributes to expressions?

    9
    0 Votes
    9 Posts
    6k Views
    Dan RathbunD
    You want the facecopy to intersect with the glued_to face ? This might work, untested. <span class="syntaxdefault">def get_glued_bounds_facegroup</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">ci</span><span class="syntaxkeyword">)<br /></span><span class="syntaxcomment"># Arg; ci, a component instance<br /># Return nil if ci is not glued;<br />#  or a group with new face you can explode.<br /></span><span class="syntaxdefault">  </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault">  return nil if ci</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">glued_to</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">nil</span><span class="syntaxkeyword">?<br /></span><span class="syntaxdefault">  </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault">  model </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">active_model<br />  cd </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> ci</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">definition<br />  db </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> cd</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">bounds<br />  </span><span class="syntaxcomment"># get pts in counter-clockwise order;<br /></span><span class="syntaxdefault">  pt0 </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> db</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">corner</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxcomment"># left front bottom<br /></span><span class="syntaxdefault">  pt1 </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> db</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">corner</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxcomment"># right front bottom<br /></span><span class="syntaxdefault">  pt2 </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> db</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">corner</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">3</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxcomment"># right back bottom<br /></span><span class="syntaxdefault">  pt3 </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> db</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">corner</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxcomment"># left back bottom<br /></span><span class="syntaxdefault">  </span><span class="syntaxcomment"># get transform of ci;<br /></span><span class="syntaxdefault">  tr </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> ci</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">transformation<br />  </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault">  par </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> ci</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">parent<br />  ents </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> par</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities rescue model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_entities<br />  grp </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> ents</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_group</span><span class="syntaxkeyword">()<br /></span><span class="syntaxdefault">  grp</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_face</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">pt0</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">pt1</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">pt2</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">pt3</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  grp</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">transform</span><span class="syntaxkeyword">!(</span><span class="syntaxdefault">tr</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault">end</span>
  • Webdialog and ActiveXObject

    11
    0 Votes
    11 Posts
    1k Views
    D
    Thread Highjack... @aerilius said: ...I have been working for some months on making the one I use in my plugins standalone and re-usable (soon released). shoot me a copy if you want any mac testing, i'm not too fond of SKUI, as I prefer a more the native look and feel... john
  • Error Drawing Lines

    8
    0 Votes
    8 Posts
    866 Views
    ppoublanP
    Better understand. Thanks slb for these explanation. I Cant use scaling in this case as the points are the result of crossing lines, so at any scale the resulting point of two lines crossing can be very close to any other point in the model. This gave me an idea for a very bad workaround. Do not like it, but it works. this way SU does not seem to try sharing same vertex... pt1 = Geom::Point3d.new(0.98787,0.926013,0) pt2 = Geom::Point3d.new(0.988135,0.925025,0) pt3 = Geom::Point3d.new(0.977696,0.924673,0) grp1 = Sketchup.active_model.entities.add_group grp1.entities.add_line(pt3,pt2) grp2 = Sketchup.active_model.entities.add_group grp2.entities.add_line(pt2,pt1) grp1.explode grp2.explode Thks again Pascal
  • Intersect_with revisited

    27
    0 Votes
    27 Posts
    3k Views
    C
    @sdmitch said: Perhaps but then you have the added burden of figuring out what is horizontal and what is vertical. Creating a group for each edge seems to work every time and does so fairly quickly. The trouble is that entities.add_group becomes very slow after a while. Nevertheless, I've attached my final version. It divides the edges into classes based on orientation, and these classes are then further divided into groups of max 250 edges. All examples seems to merge correctly. There is also some verification built into the code. I encountered this problem in flowify where the (extended) projection grid intersects the geometry and even though distributing the edges over many groups alliviated the problem it did not fully solve it, so I'm quite happy to have found a better way. As a general observation, intersection is really two distinct problems, the first is to find the intersection edges and the second is to merge the geometry. My biggest problem with intersect stems from the first part. A face in Sketchup does only have to be almost flat while the intersection between two faces is computed from two exactly flat mathematical planes. This means that the intersection edges may fail to merge with the not-exactly-flat face due to tolerance issues. I've found that the following procedure produces a more robust intersect, especially for complicated surfaces: 1) Transform the geometry to a gigantic scale 2) Check all faces by computing a plane form the vertices and then check that all vertices are on that plane. If they are not, then triangulate the face. 3) Intersect Complicated grids.. GridTest.rb
  • [Question] Switch of model and Interactive Plugins on Mac

    6
    0 Votes
    6 Posts
    657 Views
    S
    As John's animation shows, it isn't a matter of each model not having its own Tool activated, it is an issue with SketchUp duplicating certain view.draw_xxx contents on all existing views. This is a bug we reported some time ago.
  • [Idea] Paint brush

    3
    0 Votes
    3 Posts
    1k Views
    T
    i think its better to have this idea, in terms of applying, you can overlay materials with another material looks like photoshop in 3d plugin
  • Create arbitrary shape from list of points

    4
    0 Votes
    4 Posts
    606 Views
    W
    @tig said: Look at http://www.sketchup.com/intl/en/developer/docs/ourdoc/entities#add_faces_from_mesh Thanks for that TIG. I had a look at that and with my simple cube example, it did not quite give me the result i was hoping for. DO i need to manually join the other edges? [image: FxA4R7em.png] @dan rathbun said: Also look at how the SketchUp Team makes shapes in the Shapes plugin example: http://extensions.sketchup.com/en/content/shapes Thanks Dan. I have had a look at that and it seems to describe how to do basic shapes, however what I am looking at is a bit more complex (despite my example) and shaped more like a balloon, or a very irregular shape.
  • SketchUp-Ruby Resources

    29
    0 Votes
    29 Posts
    123k Views
    Dan RathbunD
    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ |--<<< RUBY RESOURCES >>>--| ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Ruby Newbie's Guide to Getting Started viewtopic.php?f=180&t=10142&start=15#p298780 TUTORIALS & PRIMERS ~ Ruby (Generic) ~ Introduction to Ruby http://www.ruby-doc.org/docs/Tutorial/ Ruby User's Guide by Mark Slagell, Iowa State University http://www.rubyist.net/~slagell/ruby/ Ruby Study Notes by Satish Talim http://rubylearning.com/satishtalim/tutorial.html Learn to Program by Chris Pine http://pine.fm/LearnToProgram/ ~ Sketchup Specific ~ Edges to Rubies - The Complete SketchUp Tutorial by Martin Rinehart http://www.martinrinehart.com/models/tutorial/ Ruby Tutorials SketchUcation Forums http://forums.sketchucation.com/viewtopic.php?p=52665#p52665 Tutorial Index SketchUcation Forums http://forums.sketchucation.com/viewtopic.php?f=18%26amp;t=8767 BOOKS ~ Offline (PDF, CHM, TAR, etc.) ~ The Book of Ruby by Huw Collingbourne ** PDF http://www.sapphiresteel.com/IMG/zip/book-of-ruby.zip The Little Book of Ruby by Huw Collingbourne ** PDF http://www.sapphiresteel.com/IMG/pdf/LittleBookOfRuby.pdf Mr. Neighborly's Humble Little Ruby Book by Jeremy McAnally ** PDF http://www.humblelittlerubybook.com/book/hlrb.pdf Programming Ruby - The Pragmatic Programmer's Guide, 1st Ed. (aka "The Old Pick-Axe Book" circa Ruby ver 1.6.x) by David Thomas and Andrew Hunt ** TAR archive of website http://phrogz.net/ProgrammingRuby/ProgrammingRuby_20061016.tar.gz ** CHM edition file is included w/ Win 1.8.6 One-click install see your /ruby/doc directory OR [url=http://forums.sketchucation.com/viewtopic.php?f=180%26amp;t=10142%26amp;p=431798#p431798:23sdyhrr]download from SketchUcation[/url:23sdyhrr] Extending Ruby 1.9 - The Pragmatic Programmer's Guide by David Thomas [url:23sdyhrr]http://media.pragprog.com/titles/ruby3/ext_ruby.pdf[/url:23sdyhrr] Ruby Best Practices by Gregory T. Brown ** PDF http://sandal.github.com/rbp-book/pdfs/rbp_1-0.pdf Automatic SketchUp by Matthew Scarpino, Eclipse Engineering LLC [url:23sdyhrr]http://www.autosketchup.com/downloads/Automatic_SketchUp.pdf[/url:23sdyhrr] ~ Online ~ [i:23sdyhrr]Ruby Essentials[/i:23sdyhrr] Techotopia [url:23sdyhrr]http://www.techotopia.com/index.php/Ruby_Essentials[/url:23sdyhrr] Programming Ruby - The Pragmatic Programmer's Guide, 1st Ed. (aka "The Old Pick-Axe Book" circa Ruby ver 1.6.x) by David Thomas and Andrew Hunt [url:23sdyhrr]http://phrogz.net/ProgrammingRuby/frameset.html[/url:23sdyhrr] OR [url=http://forums.sketchucation.com/viewtopic.php?f=180%26amp;t=10142%26amp;p=431798#p431798:23sdyhrr]download from SketchUcation[/url:23sdyhrr] ~ Previews of Ruby Books for Sale ~ [i:23sdyhrr]Learn to Program, 2nd Ed.[/i:23sdyhrr] by Chris Pine (expanded from the original tutorial) [url:23sdyhrr]http://www.pragprog.com/titles/ltp2/learn-to-program-2nd-edition[/url:23sdyhrr] [i:23sdyhrr]Programming Ruby - The Pragmatic Programmer's Guide, 2nd Ed.[/i:23sdyhrr] (aka "The New Pick-Axe Book" circa Ruby ver 1.8.x) by David Thomas, with Chad Fowler and Andrew Hunt [url:23sdyhrr]http://pragprog.com/titles/ruby/programming-ruby[/url:23sdyhrr] [i:23sdyhrr]Programming Ruby 1.9: The Pragmatic Programmers' Guide[/i:23sdyhrr] by David Thomas, with Chad Fowler and Andrew Hunt http://pragprog.com/titles/ruby3/programming-ruby-1-9 [i:23sdyhrr]The Ruby Programming Language[/i:23sdyhrr] by David Flanagan and Yukihiro Matsumoto http://books.google.com/books?id=jcUbTcr5XWwC%26amp;lpg=PA98%26amp;ots=fHGordbwjC... TECHNICAL REFERENCES [i:23sdyhrr]Ruby Cheatsheet[/i:23sdyhrr] [url:23sdyhrr]http://www.zenspider.com/Languages/Ruby/QuickRef.html[/url:23sdyhrr] [i:23sdyhrr]Ruby Base Classes - circa ver 1.6.x[/i:23sdyhrr] (but most still OK for 1.8.x which has more methods) [url:23sdyhrr]http://phrogz.net/ProgrammingRuby/builtins.html[/url:23sdyhrr] [i:23sdyhrr]Ruby Core Documentation[/i:23sdyhrr] (may be ver 1.9.x) [url:23sdyhrr]http://www.ruby-doc.org/core/[/url:23sdyhrr] [i:23sdyhrr]RDoc Documentation[/i:23sdyhrr] [url:23sdyhrr]http://rdoc.rubyforge.org/[/url:23sdyhrr] [i:23sdyhrr]RubyGems User Guide[/i:23sdyhrr] [url:23sdyhrr]http://rubygems.org/read/chapter/1[/url:23sdyhrr] [i:23sdyhrr]RubyGems Manuals[/i:23sdyhrr] [url:23sdyhrr]http://docs.rubygems.org/[/url:23sdyhrr] INDEXES [i:23sdyhrr]Resources[/i:23sdyhrr] (SketchUp Sage) [url:23sdyhrr]http://sites.google.com/site/sketchupsage/resources[/url:23sdyhrr] SKETCHUP SPECIFIC ~ API ~ [i:23sdyhrr]SketchUp Ruby API Cheatsheet[/i:23sdyhrr] by Alex Schreyer [url:23sdyhrr]http://www.alexschreyer.net/cad/sketchup-ruby-api-cheatsheet/[/url:23sdyhrr] [i:23sdyhrr]SketchUp Ruby API[/i:23sdyhrr] [url:23sdyhrr]http://code.google.com/apis/sketchup/[/url:23sdyhrr] [i:23sdyhrr]SketchUp Ruby API - Class Index[/i:23sdyhrr] [url:23sdyhrr]http://code.google.com/apis/sketchup/docs/classes.html[/url:23sdyhrr] [i:23sdyhrr]SketchUp Ruby API - Method Index[/i:23sdyhrr] [url:23sdyhrr]http://code.google.com/apis/sketchup/docs/methods.html[/url:23sdyhrr] [i:23sdyhrr]SketchUp Ruby API - Class Diagram[/i:23sdyhrr] [url:23sdyhrr]http://code.google.com/apis/sketchup/docs/diagram.html[/url:23sdyhrr] [i:23sdyhrr]Sketchup Ruby API Class Diagrams[/i:23sdyhrr] by Jim Foltz [url:23sdyhrr]http://sketchuptips.blogspot.com/2008/08/sketchup-ruby-api-class-diagrams.html[/url:23sdyhrr] [i:23sdyhrr]Google SketchUp API Blog[/i:23sdyhrr] [url:23sdyhrr]http://sketchupapi.blogspot.com/[/url:23sdyhrr] [i:23sdyhrr]PickHelper - Visual Guide[/i:23sdyhrr] by Thomas Thomassen [url=http://forums.sketchucation.com/viewtopic.php?f=180%26amp;t=30232%26amp;p=266685:23sdyhrr]http://forums.sketchucation.com/viewtopic.php?f=180&t=30232&p=266685[/url:23sdyhrr] [i:23sdyhrr]WebDialogs - The Lost Manual[/i:23sdyhrr] by Thomas Thomassen [url:23sdyhrr]http://forums.sketchucation.com/download/file.php?id=36664[/url:23sdyhrr] ~ Indexes ~ [i:23sdyhrr]SketchUp-Ruby Resources[/i:23sdyhrr] [url:23sdyhrr]http://forums.sketchucation.com/viewtopic.php?f=180%26amp;t=10142[/url:23sdyhrr] ~ BBs / Forums ~ [i:23sdyhrr]Developers Forum - Google Groups[/i:23sdyhrr] [url:23sdyhrr]http://groups.google.com/group/google-sketchup-developers[/url:23sdyhrr] [i:23sdyhrr]Developers Forum - SketchUcation Community Forums[/i:23sdyhrr] [url:23sdyhrr]http://forums.sketchucation.com/viewforum.php?f=180[/url:23sdyhrr] ~ Code Snippets ~ [i:23sdyhrr]Code Snippets Index - SketchUcation Developers Forum[/i:23sdyhrr] [url:23sdyhrr]http://forums.sketchucation.com/viewtopic.php?f=180%26amp;t=28846[/url:23sdyhrr] ~ Plugins ~ [i:23sdyhrr]Plugins Index (by author) - SketchUcation Plugins Forum[/i:23sdyhrr] [url:23sdyhrr]http://forums.sketchucation.com/viewtopic.php?f=323%26amp;t=28782[/url:23sdyhrr] [i:23sdyhrr]Plugins Visual Index - SketchUcation Plugins Forum[/i:23sdyhrr] [url:23sdyhrr]http://forums.sketchucation.com/viewtopic.php?f=323%26amp;t=16909[/url:23sdyhrr] [i:23sdyhrr]Trimble SketchUp - Plugins (Download Page)[/i:23sdyhrr] [url:23sdyhrr]http://www.sketchup.com/intl/en/download/plugins.html[/url:23sdyhrr] [i:23sdyhrr]Trimble SketchUp - Ruby Scripts (Download Page)[/i:23sdyhrr] [url:23sdyhrr]http://www.sketchup.com/intl/en/download/rubyscripts.html[/url:23sdyhrr] [i:23sdyhrr]Jim Foltz SketchUp Plugins[/i:23sdyhrr] [url:23sdyhrr]http://sketchuptips.blogspot.com/2007/09/plugin-index-page.html[/url:23sdyhrr] [i:23sdyhrr]Ruby Libray Depot[/i:23sdyhrr] ! URL Removed due to too many outdated plugins ! [i:23sdyhrr]Smustard(TM) - Plugins and Scripts[/i:23sdyhrr] [url:23sdyhrr]http://www.smustard.com/scripts/[/url:23sdyhrr] [i:23sdyhrr]JohnJ - Plugins for Sketchup[/i:23sdyhrr] [url:23sdyhrr]http://www.johnj.com/drawing/sketchup/ruby-plugins-for-sketchup/[/url:23sdyhrr]
  • Include paths

    3
    0 Votes
    3 Posts
    476 Views
    Dan RathbunD
    IN Ruby you can do interpolation in double-quoted strings with the #{ } operator. The expression between the curlies is evaluated and passed to the result's to_s method, then stuffed into the string. So you'd create a string of html: html = %Q{ <html> <head> <base href="#{myroot}" /> <link rel="stylesheet" href="resources/css/webdialogs.css" /> </head> <body> </body> </html> } my_dialog.set_html(html) You can also use a HEREDOC. See: http://ruby-doc.org/core-2.0.0/doc/syntax/literals_rdoc.html
  • Tool: getMenu and toolbar

    8
    0 Votes
    8 Posts
    780 Views
    bomastudioB
    Thank you Dan. I'm going to study....
  • Simple Building Generator

    8
    0 Votes
    8 Posts
    2k Views
    R
    @unearthed said: being able to 'populate' and area quickly would be a real advantage. Would also be useful to be able to quickly show how an area could change over time say with single-floor buildings being replaced with multi-floor. Hi, I've managed to have a solution for the urban growth, however it's a pity you'd still have to growth it manually @unearthed said: Also many council GIS's are starting to to put building outlines online and this could 'build' from those... If it's not troubling you so much, could you share some websites or keywords to get those building outline? I'm sure it'll help a lot of people
  • Are there plugins for Layout?

    4
    0 Votes
    4 Posts
    1k Views
    Dan RathbunD
    FYI IMSI DoubleCAD XT was a 2D CAD application, that could be plugged into SketchUp (like Layout can be.) It ran embedded Ruby, and had a clone of SketchUp's API. It development has been discontinued, but you may still be able the download the latest version. http://www.doublecad.com/DoubleCAD/DoubleCAD-XT-v5 http://activate.imsisoft.com/doublecad.aspx?productpage=DoubleCAD_XT_v5 QCad is a low cost (~37USD) 2D application, that has Javascript API & Qt GUI toolkit for plugins. http://www.ribbonsoft.com/en/ There is a free stripped down edition you can tryout. (But it cannot really be used for work. For example trying to add a layer brings up a nag box, saying that is a Pro feature.) FreeCAD is a 2D/3D Open Source free CAD application, that uses Python for extensions and custom workbenches. http://www.freecadweb.org/ http://sourceforge.net/projects/free-cad/
  • [REQ SU api] Set component axis

    5
    0 Votes
    5 Posts
    704 Views
    kimpastroK
    @tig said: Although it's convoluted you can do it already... You use: definition.entities.transform_entities(Geom::Transformation.translation(ORIGIN.vector_to(some_other_point_in_the_context)), definition.entities.to_a) to move the origin/insertion-point of the definition. If there are any existing 'instances' you'll also need to apply an inverse transformation to them ? If the axes are rotated you can also do a ...Geom::Transformation.rotation(anchor_point, axis_vector, angle)... and again you might need to fix any existing 'instances'... Sorry bring back this post but, with this is possible to do the second move (at right)? [image: l3DH_6.png]
  • Help with loading performance using Sketchup C SDK.

    2
    0 Votes
    2 Posts
    564 Views
    Dan RathbunD
    You can also ask your question at: http://forums.sketchup.com/c/developers/sketchup-sdk The SketchUp Team members are more likely to answer, more quickly.
  • Toolbar position

    6
    0 Votes
    6 Posts
    670 Views
    bomastudioB
    A lot of things to study..... many thanks Dan....you are a GURU!!!
  • Deleting Component Instance

    5
    0 Votes
    5 Posts
    873 Views
    bomastudioB
    Guys you are and invaluable support for SU developers.... a beer to all of you!!!
  • ComponentInstance Guid question

    12
    0 Votes
    12 Posts
    2k Views
    thomthomT
    EntityID are unique for the model - but entities will be assigned a new ID each time you open it. They are not persistent. There will not be two entities with the same entityID in a model. ComponentDefinition GUIDs change as you modify the definition. ComponentInstance GUIDs persist - even if you edit the instance/definition.
  • Access specifies entity

    3
    0 Votes
    3 Posts
    502 Views
    Dan RathbunD
    # Search top and 1st nested level for a named group; grps = Sketchup.active_model.active_entities.grep(Sketchup;;Group) if !grps.empty? found = grps.find {|grp| grp.name = "Target Name" } else found = nil end if !found # found will be nil, if group was not found nested = Sketchup.active_model.entities.find_all {|ent| ent.is_a?(Sketchup;;Group) || ent.is_a?(Sketchup;;ComponentInstance) } nested.each {|ent| ents = ent.is_a?(Sketchup;;Group) ? ent.entities ; ent.definition.entities grps = ents.grep(Sketchup;;Group) found = grps.find {|grp| grp.name = "Target Name" } if !grps.empty? } end # found will be the group reference, if it was found # found will be nil, if group was not found
  • Extract 3D information to regenerate the shape

    4
    0 Votes
    4 Posts
    832 Views
    Dan RathbunD
    SketchUp is a surface modeler. Everything in SketchUp is basically made up of edges, vertices, and faces. There are no complex built-in 3D shape classes in the SketchUp Ruby API. Instead primitives are either grouped into Group class instances, or ComponentInstance class instances. (Each have a defining ComponentDefinition class instance.) These mentioned classes are all sub-classes of Entity, and inherit it's functionality (as well as the intermediate Drawingelement class functionality.) Any Entity subclass instance can have any number of AttributeDictionary instances attached to them. You can put whatever custom data you wish into attributes in a custom dictionary, usually named the same as your plugin. (Ex: "Ruts_Shaper_Properties") Back to the grouped 3D shape. Groups and components have a built-in definition name and each instance of them can have a separate more unique instance name. Group and component instances have built-in transformation property, from which you can query all the translational, rotational, scaling and axial subproperties. See the Geom::Transformation class. All Drawingelement subclasses (the objects that can be seen in the model,) have an invisible boundingbox, from which you can get the corners and the center. See the Geom::BoundingBox class. It would be more efficient to create the basic shapes as an external SKP component library, and insert them into the model, rather than draw each using code, but drawing them adhoc can be done. You should most likely install the SketchUp Team's example Shapes plugin, and study the code. http://extensions.sketchup.com/en/search/site/Shapes

Advertisement