sketchucation logo sketchucation
    • Login
    1. Home
    2. Skastafari
    3. Posts
    โš ๏ธ Attention | Having issues with Sketchucation Tools 5? Report Here
    S
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 9
    • Posts 29
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Ruby Group Swap

      If anyone is interested, I finally solved my imported group's origin problem fairly simply with this...

      ga = entities.grep(Sketchup::Group) ga.each { |e| n=e.name; e.model.entities.add_group(e); e.parent.instances[0].name=n}

      Basically it just takes all the groups after import, adds them into a new group and names the new group the same name. This resets the origin, and allows the swap code to work properly.

      posted in Developers' Forum
      S
      Skastafari
    • RE: Ruby Group Swap

      I have plugged away at the imported origin problem some more, I found that exploding imported groups is undesirable as it leaves behind unwanted vertices on your non-grouped objects when you regroup. I messed around writing an explode/regroup routine (it was buggy) and then I found a similar thread where TIG had an elegant less buggy explode/regroup solution using an array. it was something like...
      sel = mod.selection groupArray=(sel[0].explode.find_all{|e|e if e.respond_to?(:bounds)}).uniq Sketchup.active_model.entities.add_group(groupArray)

      That fixed the origin points, but I found that I cannot explode to get a new origin as it ruins ungrouped geometry in my model. I found that exploding is unnecessary and is only really a limitation of using SketchUp's interface, as there is no option to add a single group object inside another group. You would need to select at least 1 other object since the only options available in SU are "edit group", "make component", or "explode". With ruby I can just use add_group and I have a single group inside a group. Easy enough for me even with my limited ruby experience. Now I just need a way to get the name of each group add it to a new group with the same name. I need help with syntax for this.

      The only potential problem I can see with this ide to reset origin is that perhaps SU won't like having a group inside a group of the same name. If it defaults to something like group_1 or something I can just update my "gname" to reflect that, hopefully that is the case.

      I will check out that thread link sdmitch, thanks for your help.

      posted in Developers' Forum
      S
      Skastafari
    • RE: Ruby Group Swap

      I was able to get some desirable results using most of sdmitch's code. Perhaps I am against some issues with my older license of Pro 8 that I was just not aware of (ruby 2.0 differences?) I am also having some new unforeseen issues with the origin points on my imported geometry. For some reason all imported groups are sharing the same origin. So it has become rather frustrating processing my models when all my components end up at what appears to be a global origin point for all imported groups (Using Fluid importer). I do think it is necessary to grab the transform from the group to apply to the component for proper placement of the component during the swap. Right now the only thing I can come up with to solve my problem would be to just first run another script that explodes each group, and then regroups it with the same name. Is there any easier way to reset a group's (transform) origin?

      I really appreciate the ideas and feedback here, You guys have saved me from hours and hours of trial and error frustration already. The day to day grind of manually swapping out hundreds of groups with components is about as pleasurable as getting my teeth pulled. Thanks again, these ideas so far are more than I could have hoped for.

      posted in Developers' Forum
      S
      Skastafari
    • RE: Ruby Group Swap

      I really like your idea. Keeping a list of group names and a corresponding list of component names will make managing my models really easy. I was trying to implement your method, and mostly failing. My template is set up with components already loaded, and the groups import with my geometry. I keep getting Error: #<LocalJumpError: no block given> and (eval):2536:in `each_with_index' I am still trying to figure out what I did wrong. If anything jumps out, let me know. The only thing I found was a period instead of a comma on gnames=[] I do really appreciate your time on this. I will continue working on it until I can get it running. I am thinking I better start making sure my origins match up on my groups and corresponding components. Thanks again TIG.

      posted in Developers' Forum
      S
      Skastafari
    • Ruby Group Swap

      My latest challenge is converting imported named groups to their local Sketchup component counterpart. For example I have a group named TubLeft, and I will need to swap it with an already made component named TubLeft4. I am completely unsure how to do this with ruby and need some ideas. I have found it is easy to convert a group to a component, but that does not give me any of the dynamic attributes already in the corresponding component. I really just want to swap a group object by name with a component instance by its name. Any ideas would be much appreciated.

      posted in Developers' Forum
      S
      Skastafari
    • RE: Need some help again.

      Thanks again TIG! I am very grateful. I knew I was missing something, but was pretty much stumped. Thanks for putting me back on track, and so quickly. Cheers

      posted in Developers' Forum
      S
      Skastafari
    • Need some help again.

      A few months ago, Tig helped me with some syntax for exploding walls in my model grouped by name, The specific line of code was:

      Sketchup.active_model.active_entities.grep(Sketchup;;Group).each{|e| e.explode if e.name=~/^[Ww]all/ }
      

      I now have to explode components by the same naming system, starting with 'wall'.
      I was thinking I could add another line to the module and simply switch (Sketchup::Group) with (Sketchup::ComponentInstance) and everything should work fine... but it does not. I found myself frustrated again and decided to come back to the pros and ask for some help here.

      posted in Developers' Forum
      S
      Skastafari
    • RE: Method to Explode Groups by name beginning...

      Looks like you focused only on group class, and corrected the wall name syntax, and I am very grateful as it now works! Thanks Tig ๐Ÿ˜Ž

      posted in Developers' Forum
      S
      Skastafari
    • Method to Explode Groups by name beginning...

      I need help with a method to explode select groups in my model, they are named "wall*".
      So they would appear in model as "wall_1_3, wall_1_4, etc. They must all be exploded, but nothing else in the model. They are not sub-grouped, so no re-curse needed. I was playing with something like...

      model=Sketchup.active_model
      entities=model.active_entities
      Sketchup.active_model.active_entities.each{|e|e.explode if e.name =~ /\A(wall-)/}

      This does not work. I am unsure of method and syntax, and being humbled my now apparent limited skills. Any help would be appreciated.

      posted in Developers' Forum
      S
      Skastafari
    • 1
    • 2
    • 2 / 2