sketchucation logo sketchucation
    • Login
    1. Home
    2. tiktuk
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    T
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 10
    • Groups 1

    tiktuk

    @tiktuk

    10
    Reputation
    1
    Profile views
    10
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    tiktuk Unfollow Follow
    registered-users

    Latest posts made by tiktuk

    • RE: Why is my Group deleted while trying to add entities to it?

      Thanks everybody, this forum is splendid, got it working thanks to your explanations 👍 . Ended up just collecting the groups in an array an creating a group with that. Works perfectly.

      <span class="syntaxdefault">def&nbsp;create_frame&nbsp;edges</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">center</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">size<br />&nbsp;&nbsp;all_struts&nbsp;</span><span class="syntaxkeyword">=&nbsp;[]<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">edges</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each_with_index&nbsp;</span><span class="syntaxkeyword">{&nbsp;|&nbsp;</span><span class="syntaxdefault">edge</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">index&nbsp;</span><span class="syntaxkeyword">|<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">strut&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">create_strut&nbsp;edge</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">center</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">size<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;props&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">strut_properties&nbsp;edge</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strut</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">name&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">props</span><span class="syntaxkeyword">[</span><span class="syntaxstring">"name"</span><span class="syntaxkeyword">]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">strut</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">material&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">props</span><span class="syntaxkeyword">[</span><span class="syntaxstring">"color"</span><span class="syntaxkeyword">]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">all_struts&nbsp;</span><span class="syntaxkeyword"><<&nbsp;</span><span class="syntaxdefault">strut<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxkeyword">}<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">frame_group&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">active_entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_group&nbsp;all_struts<br />&nbsp;&nbsp;&nbsp;&nbsp;frame_group</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">name&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxstring">"Geodome&nbsp;frame"<br /></span><span class="syntaxdefault">end</span>
      

      I see that your idea would work too, Dan, thanks!

      posted in Developers' Forum
      T
      tiktuk
    • RE: Why is my Group deleted while trying to add entities to it?

      @tig said:

      Only ever use entities.add_group(ents) when 'entities' is the 'model.active_entities' and 'ents' are also in the 'model.active_entities'...
      Something like...
      frame_group = Sketchup.active_model.active_entities.add_group() for edge in edges frame_group.entities.add_group(self.create_strut(edge,center,size)) end
      might be better...

      Thanks TIG. Did not solve this problem but learning about 'active_entities' was very useful. Was wondering why my struts were being created outside the active component before..

      posted in Developers' Forum
      T
      tiktuk
    • RE: Why is my Group deleted while trying to add entities to it?

      @thomthom said:

      I'm guessing it refer to line 58. I'm pretty sure it's because you make the containing group after you make the child entities. Refactor the code so you always create the container first - and then add the entities to the container.

      strut = create_strut edge, center, size frame_group.entities.add_group strut

      I think you are onto something there. I just noticed that I am creating an extra group in that line, that I don't want or need. create_strut is already returning a group and I have used add_group strut to add that group to my frame_group but while doing that I am creating another group.

      How do I add an existing entity (a group in this instance), to an existing group? I can't find any methods for that.

      posted in Developers' Forum
      T
      tiktuk
    • RE: Why is my Group deleted while trying to add entities to it?

      @thomthom said:

      Error line doesn't match anything in the BitBucket repository... ❓

      Sorry, the file was out of sync, yes. Corrected.

      Looking into your suggestions now!

      posted in Developers' Forum
      T
      tiktuk
    • RE: Why is my Group deleted while trying to add entities to it?

      @thomthom said:

      Where in the script does the error occur?

      I have updated the post to include the full error message.

      @unknownuser said:

      [off:56wfnlq5]Btw - you should wrap your plugin in a module in order to contain it to its own namespace.
      Read more: http://www.thomthom.net/thoughts/2012/01/golden-rules-of-sketchup-plugin-development/[/off:56wfnlq5]

      Great, will look into that! And thanks for all your other tips as well 😄 .

      posted in Developers' Forum
      T
      tiktuk
    • Why is my Group deleted while trying to add entities to it?

      Hi all,

      I am trying to create a script for creating struts for models of geodesic domes. I do this by iterating over all edges in a model of a geodome and create boxes along the edges. I have gotten all this to work, but for convenience I would like to add all my created boxes to a new group. This fails in the second iteration of the loop, with this message:

      Error; #<TypeError; reference to deleted Group>
      geodome_frame.rb;58;in `entities'
      geodome_frame.rb;58;in `create_frame'
      geodome_frame.rb;53;in `each'
      geodome_frame.rb;53;in `create_frame'
      geodome_frame.rb;115;in `main'
      geodome_frame.rb;84
      geodome_frame.rb;57;in `call'
      geodome_frame.rb;57
      
      

      The frame is created if I uncomment the code that adds all struts to a group.

      Here is the relevant code:

      <span class="syntaxdefault"></span><span class="syntaxcomment"># Create a strut (as a box in a group)<br /># along an edge, facing a center point.<br /></span><span class="syntaxdefault">def create_strut edge</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> center</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> size<br />    entities </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities<br />    width</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> depth </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> size<br />    <br />    vec_to_center </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> edge</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">position</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">vector_to center<br />    plane_intersecting_with_center </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Geom</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">fit_plane_to_points center</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> edge</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">position</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> edge</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">end</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">position<br />    <br />    </span><span class="syntaxcomment"># We need a vector in the plane of the top of the strut.<br /></span><span class="syntaxdefault">    </span><span class="syntaxcomment"># It is the same as the normal to the plane intersecting with the center<br /></span><span class="syntaxdefault">    </span><span class="syntaxcomment"># which is the same as the three first values in the plane we just calculated.<br /></span><span class="syntaxdefault">    width_vec </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Vector3d</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">new plane_intersecting_with_center</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0..2</span><span class="syntaxkeyword">]<br /></span><span class="syntaxdefault">    width_vec</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> width </span><span class="syntaxkeyword">/</span><span class="syntaxdefault"> 2<br />    <br />    </span><span class="syntaxcomment"># We add half a strut-width to the end points<br /></span><span class="syntaxdefault">    </span><span class="syntaxcomment"># of the edge to get the corners of the top of the strut.<br /></span><span class="syntaxdefault">    e1 </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> edge</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">position </span><span class="syntaxkeyword">+</span><span class="syntaxdefault"> width_vec<br />    e2 </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> edge</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">position </span><span class="syntaxkeyword">-</span><span class="syntaxdefault"> width_vec<br />    e3 </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> edge</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">end</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">position </span><span class="syntaxkeyword">-</span><span class="syntaxdefault"> width_vec<br />    e4 </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> edge</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">end</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">position </span><span class="syntaxkeyword">+</span><span class="syntaxdefault"> width_vec<br />    <br />    </span><span class="syntaxcomment"># We add a group for the strut and create the strut top face<br /></span><span class="syntaxdefault">    strut_group </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_group<br />    strut_top_rect </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">[</span><span class="syntaxdefault">e1</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> e2</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> e3</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> e4</span><span class="syntaxkeyword">]<br /></span><span class="syntaxdefault">    strut_top_face </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> strut_group</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_face strut_top_rect<br />    <br />    </span><span class="syntaxcomment"># Push pull the top face to create the final strut<br /></span><span class="syntaxdefault">    strut_top_face</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">pushpull </span><span class="syntaxkeyword">-</span><span class="syntaxdefault">depth<br />    <br />    return strut_group<br />end<br /><br /></span><span class="syntaxcomment"># Loop through all edges in the current selection and<br /># create struts. And add all the struts to a group.<br /></span><span class="syntaxdefault">def create_frame edges</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> center</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> size<br />    frame_group </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_group<br />    frame_group</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">name </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'Geodome frame'<br /></span><span class="syntaxdefault">    for edge in edges<br />        puts frame_group</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">name<br />        puts frame_group<br />        strut </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> create_strut edge</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> center</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> size<br />        </span><span class="syntaxcomment"># strut.name = <br /></span><span class="syntaxdefault">        frame_group</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_group strut<br />    end<br />end</span>
      

      The entire script is here: https://bitbucket.org/tiktuk/geodome-frames-for-su/src/86808fce358a/geodome_frame.rb .

      If you would like to reproduce:

      1. Install the plugin as usual.
      2. Select some geometry including edges (doesn't have to be a geodome model) for this test.
      3. Choose Create geodome frame from the plugin menu.

      Any ideas..?

      posted in Developers' Forum
      T
      tiktuk
    • RE: Anti-aircraft, anti-tank and anti-social WIP

      Looks amazing.. I'm also looking forward to see your progress.

      Which renderer did you use?

      posted in Gallery
      T
      tiktuk
    • RE: Plugin to create visual part (component) list?

      @dave r said:

      The custom board sizes is a feature that is coming.

      Great, I'm looking forward to that!

      posted in Plugins
      T
      tiktuk
    • RE: Plugin to create visual part (component) list?

      @dave r said:

      There is a plugin that will give you a cutlist and will do a layout of the parts but it only shows the bounding box dimensions so it won't show the various cuts.

      Yeah, I found that in my search, quite cool (although I couldn't find a way to enter custom (metric) board sizes). But not quite what I'm looking for.

      Thanks, though.

      posted in Plugins
      T
      tiktuk
    • Plugin to create visual part (component) list?

      Hi,

      I'm currently doing some simple woodworking: A holder for two solar panels.

      Model

      I have manually created a model with all the relevant components and their dimensions, here inserted in LayOut:

      Parts

      It is quite tedious to copy, move and rotate all the components to the same plane, to create a page like this, so my question is: Is there any plugin that can automate this? (I have been googling for a while.)

      Regards

      posted in Plugins
      T
      tiktuk