ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • How to Use Graphing Gem in SketchUp Plugin

    11
    0 Votes
    11 Posts
    899 Views
    tt_suT
    Ah, the docs are wrong. Why am I not surprised...
  • OSX - WebDialog blank initially?

    18
    0 Votes
    18 Posts
    544 Views
    tt_suT
    New chapter for the Lost Manual.
  • Face-tag number

    12
    0 Votes
    12 Posts
    547 Views
    pingpinkP
    Thank you very much,Renderiza ! I've tested the codes , it works very good.I can see the different panel types by coloured faces. I noticed the same face area of the sloped faces and the upright faces , they have different colours.I don't know why it happens for this time , I will look later. I just tried to map components on coloured faces , but I have to select faces and a panel component together to place and copy on the faces. Not sure that I have to do the attribute's name on coloured faces to have the same names as component's names for component mapping.
  • Strange behavior in derived class

    11
    0 Votes
    11 Posts
    417 Views
    tt_suT
    If you extend and instance with module "FooBar" then you can use instance.is_a?(FooBar)
  • Pick closest point of a polyline

    3
    0 Votes
    3 Posts
    680 Views
    T
    @tig said: Let's start simple... Thanks, TIG, for the suggestion. Unfortunately it does not work very well at all, basically because in 3D the mouse represents a ray, not a point. Sketchup generates a point via InputPoint and PickHelper using a heuristic that does not work very well at all in this application. I have a method that works well: get the mouse ray via view.pickray(x,y) loop over all segments of the polyline compute the position along the line containing the segment, where the ray is closest to the line trim that to the endpoints of the segment compute distance from the resulting point to the ray remember the closest one now I have the segment and location within the segment of the mouse generate the Geom::Transform for that location Basically this represents the centerline of a particle accelerator, and the code is inside my custom DragTool, using the mouse to place an object along the centerline; so the object is constrained to lie on the centerline, and its local z-axis is aligned with the centerline where it is located. For <= 200 segments this tracks the mouse quite well; for 1000 segments it takes about 1 second to catch up. That's acceptable for now; ultimately I may optimize it. I'm rather surprised that this much Ruby computation is acceptable. If a segment is parallel to the pickray, the math will divide by zero. So my code disallows any segment that is nearly parallel to the pickray. This makes sense, as the user cannot possibly select a position along such a segment; use the middle button to rotate the display so the desired position is visible. I ended the centerline with a half-infinite straight line. SketchUp cannot draw that (or rather, it tries to do so, zooming out so much that it's useless). So I split the final segment in two, with the first being half as long as the preceding centerline; the code does not display the final segment. The next challenge is to generalize this to include segments that are circular arcs (so far the code is limited to radius=0).... If anyone wants my code, or references to the geometrical calculations I'm using, just ask.
  • Link failed for Sketchup on Mac OS X

    5
    0 Votes
    5 Posts
    291 Views
    Z
    Thanks, really appreciate your help. Now I am clear and wait for the 64-bit SDK.
  • Module variables and nested class

    11
    0 Votes
    11 Posts
    363 Views
    A
    Thank you ThomThom Moving to instance variables
  • Detecting a flipped transform.

    13
    0 Votes
    13 Posts
    3k Views
    tt_suT
    This is digging up an old thread, but here's a snippet I think should work: <span class="syntaxdefault"><br />module&nbsp;TransformationHelper<br /><br />&nbsp;&nbsp;def&nbsp;flipped_x</span><span class="syntaxkeyword">?<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">dot_x</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">dot_y</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">dot_z&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">axes_dot_products</span><span class="syntaxkeyword">()<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">dot_x&nbsp;</span><span class="syntaxkeyword"><&nbsp;</span><span class="syntaxdefault">0&nbsp;</span><span class="syntaxkeyword">&&&nbsp;</span><span class="syntaxdefault">flipped</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">dot_x</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">dot_y</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">dot_z</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;</span><span class="syntaxdefault">end<br /><br />&nbsp;&nbsp;def&nbsp;flipped_y</span><span class="syntaxkeyword">?<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">dot_x</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">dot_y</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">dot_z&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">axes_dot_products</span><span class="syntaxkeyword">()<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">dot_y&nbsp;</span><span class="syntaxkeyword"><&nbsp;</span><span class="syntaxdefault">0&nbsp;</span><span class="syntaxkeyword">&&&nbsp;</span><span class="syntaxdefault">flipped</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">dot_x</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">dot_y</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">dot_z</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;</span><span class="syntaxdefault">end<br /><br />&nbsp;&nbsp;def&nbsp;flipped_z</span><span class="syntaxkeyword">?<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">dot_x</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">dot_y</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">dot_z&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">axes_dot_products</span><span class="syntaxkeyword">()<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">dot_z&nbsp;</span><span class="syntaxkeyword"><&nbsp;</span><span class="syntaxdefault">0&nbsp;</span><span class="syntaxkeyword">&&&nbsp;</span><span class="syntaxdefault">flipped</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">dot_x</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">dot_y</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">dot_z</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;</span><span class="syntaxdefault">end<br /><br />&nbsp;&nbsp;</span><span class="syntaxkeyword">private<br /><br />&nbsp;&nbsp;</span><span class="syntaxdefault">def&nbsp;axes_dot_products<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxkeyword">[<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">xaxis</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">dot</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">X_AXIS</span><span class="syntaxkeyword">),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">yaxis</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">dot</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">Y_AXIS</span><span class="syntaxkeyword">),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">zaxis</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">dot</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">Z_AXIS</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;]<br />&nbsp;&nbsp;</span><span class="syntaxdefault">end<br /><br />&nbsp;&nbsp;def&nbsp;flipped</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">dot_x</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">dot_y</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">dot_z</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">dot_x&nbsp;</span><span class="syntaxkeyword">*&nbsp;</span><span class="syntaxdefault">dot_y&nbsp;</span><span class="syntaxkeyword">*&nbsp;</span><span class="syntaxdefault">dot_z&nbsp;</span><span class="syntaxkeyword"><&nbsp;</span><span class="syntaxdefault">0<br />&nbsp;&nbsp;end<br /><br />end<br /><br /><br />module&nbsp;Example<br /><br />&nbsp;&nbsp;def&nbsp;self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">inspect_flipped<br />&nbsp;&nbsp;&nbsp;&nbsp;tr&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">selection</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">transformation<br />&nbsp;&nbsp;&nbsp;&nbsp;tr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">extend</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">TransformationHelper</span><span class="syntaxkeyword">)<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">p&nbsp;tr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">flipped_x</span><span class="syntaxkeyword">?<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">p&nbsp;tr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">flipped_y</span><span class="syntaxkeyword">?<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">p&nbsp;tr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">flipped_z</span><span class="syntaxkeyword">?<br />&nbsp;&nbsp;</span><span class="syntaxdefault">end<br /><br />end<br /></span>
  • Newbie

    5
    0 Votes
    5 Posts
    181 Views
    tt_suT
    Here's some getting started tips to SketchUp Extension development: http://www.thomthom.net/thoughts/2012/01/golden-rules-of-sketchup-plugin-development/ Check out the rest of the blog for more articles.
  • Area to text

    4
    0 Votes
    4 Posts
    163 Views
    tt_suT
    Note that when computing the area of the faces you want to apply the transformation of the parent context in order to get the correct size. The Face.area method accepts and optional transformation argument.
  • Distributing models with sketchup and plugins installed

    8
    0 Votes
    8 Posts
    531 Views
    zobo3360Z
    I agree! I am using the LinksManager Plugin by Dieder...His instructions on using the plugin require that you unzip the file into the Plugins folder. It will not work to copy and paste the folder into the Plugins folder. ThomThom recommended that I try to open the plugin from a sketchup shortcut using an argument. It creates the icon. But because the encrypted part of the plugin does all the functional work, I can not modify it to look to another drive for the files. (The error I get when I run the .rb part of the plugin in the ruby console is that the .rbs is undefined). I am thinking it will be best to try and create one .zip package that contains everything I need to distribute, and puts it into the Plugins folder so that I don't have to remap the location of the .rbs file. My group of users is small~10, they have no experience with sketchup, and they may or may not have access to the internet...I know--the dark ages. I need to make the process of accessing the collaborative model as easy, painless, and complete as possible. The group requested that I distribute hard copies of all needed peices--software, plugins, model, files, on a DVD drive. The next best option is an external hard drive. I have to get this to work, so invent I will! (Unless someone comes up with a slick way to solve this ) Thanks for your help!
  • Change plugin variables within Undo

    4
    0 Votes
    4 Posts
    320 Views
    danielbowringD
    you could store the value/flag on the model instead, then it would also change with the undo steps model = Sketchup.active_model model.set_attribute('maricanis', 'dl_materials_changed', true) #... model.get_attribute('maricanis', 'dl_materials_changed', false)
  • Connecting Sketchup's ruby with MYSQL database

    7
    0 Votes
    7 Posts
    2k Views
    danielbowringD
    Oh, if you're only intending to use the data locally, then any remote data source would be overkill. If you want to just save it to the model, you can just save it as an attribute to the model. Entity#(g|s)et_attribute can store a few different types, including Point3d objects. model = Sketchup.active_model # Save array of points to the model model.set_attribute('my-points', 'some-key', [ORIGIN, Geom;;Point3d.new(1, 2, 3)]) # Get the points from the model, or an empty list if none are present my_points = model.get_attribute('my-points', 'some-key', [])
  • Finding deepest entity in pick path

    6
    0 Votes
    6 Posts
    1k Views
    dukejazzD
    PickHelper I will have to read up on this? Thanks tt & eneroth3 I will be following on what you find out - dj
  • The new? Trimble Sketchup SDK

    9
    0 Votes
    9 Posts
    1k Views
    bugraB
    Hi, sorry about the delayed response. One important thing about the current SDK is that it cannot work with the in-memory model that's live in SketchUp, it can only open existing skp files. So you'll have get the file saved first. Here are some answers to your questions. For the ones I skipped, it means we should be able to do it. @th3lurker said: 4b. I used to create new faces using a mesh(because of speed issues), but this poses several problems. The face does not "exist" until i use fill faces from mesh, so i have to store the texture information separately. Fill from mesh erases all entities that existed previously in the group, so i have to wait until i am sure i have no more faces to add to the mesh. Could i use SUFaceCreate instead? Like i said, speed is an issue here, some of out projects have thousands of entities, and 10+ faces/ entity is not uncommon. Yes, you can use SUFaceCreate but using meshes (i.e. SUGeometryInput*) is currently the only way to map textures due to various reasons. We are looking into adding that to individual faces as well. @th3lurker said: Locking the group is not that important We do not support locking groups yet. I'll make a note. @th3lurker said: Are the .skp's backwards compatible?(sketchup8, maybe even 7, i have no real idea what the clients use). We currently save only in the 2013 format. It's on our list to be able to save in older formats. Thanks!
  • Toolbar conversion

    7
    0 Votes
    7 Posts
    239 Views
    D
    I sent it in a PM as a 'code block', just copy paste, no zip... john
  • Ruby Script for Adding up length of Edges

    5
    0 Votes
    5 Posts
    378 Views
    D
    @tig said: You can only really parse through entities 'collections': model.entities/model.active_entities and group.entities/definition.entities AND model.selection... However, once you have a collected set from that, you can parse that set to find just the things on a certain layer, with a certain material etc... Recently the use of 'grep' has been found to speed up entity parsing significantly, I recommend you try it... So to find all groups in a selection use: gps=model.selection.grep(Sketchup::Group) Now 'gps' is an array of all groups in the current selection. To find every selected group that's assigned layer 'XXX' use xxx=[]; gps.each{|gp| xxx << gp if gp.layer.name=='XXX' } If you want to find absolutely everything in the model using that layer, then: gps=model.entities.grep(Sketchup::Group) and process 'gps'... To get matches within a group use: gps=group.entities.grep(Sketchup::Group) and process 'gps'... To find everything in the model using a certain layer try: xxx=[]; model.entities.each{|e| xxx << e if e.layer.name=='XXX' } There are several alternative methods, like 'collect', but here I just show you make an empty array 'xxx=[]' and then we add to it using 'push' [<<] when we get a match... Hello TIG, This is once again very helpful. I think I understand your examples to experiment a bit and report back what I develop using this information.
  • Set layer color with code possible?

    6
    0 Votes
    6 Posts
    162 Views
    renderizaR
    Hopefully next API update includes this function...Thanks TIG!
  • Detect changes in geometry?

    7
    0 Votes
    7 Posts
    258 Views
    thomthomT
    @maricanis said: However, I've never used start_operation and Undo related features, so this is good opportunity to look them too. Indeed - they are essential for a good UX so the user an go back and forth. Another note on the ToolsObserver - the tool state of the tools vary and are not consistent so you need to dig a little to figure out their behaviour. I described some of the behaviour of Move, Rotate and Scale in the comments of AutoSmooth. You can view the source at GitHub: https://github.com/thomthom/AutoSmooth
  • Using chunkyPng library with Sketchup

    3
    0 Votes
    3 Posts
    715 Views
    massimoM
    Done.

Advertisement