sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Array to or from objects

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    5 Posts 3 Posters 161 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N Offline
      ninehundred
      last edited by

      Hello,

      I would like to know if its possible to have an object draw lines from itself to many other objects or conversely is it possbile to have various objects draw lines from themselves to a single selected object?

      Right now I have 247 objects and would like this process repeated with each object. So for instance say i had four, I would want to take object 1 and have it array lines from itself to objects 2,3 and 4. I would like to then go on to repeat this process for each object so take object 2 and array lines to objects 1,3 and 4 and so on.

      Is there any way to do this at all in sketchup? If anyone has seen this function in another programme I would be equally interested.

      thanks all,

      ninehundred

      1 Reply Last reply Reply Quote 0
      • Dave RD Offline
        Dave R
        last edited by

        If the surrounding objects are instance of a single component arrayed radially around the central object, you could draw all those lines at once by making them part of the component.


        array1.png


        array2.png

        Etaoin Shrdlu

        %

        (THERE'S NO PLACE LIKE)

        G28 X0.0 Y0.0 Z0.0

        M30

        %

        1 Reply Last reply Reply Quote 0
        • TIGT Offline
          TIG Moderator
          last edited by

          What is the nature of these 'objects'?
          If they are single lines or groups/component-instances etc then here's a way
          One way is to preselect them all, and then run this one-liner.

          m=Sketchup.active_model;g=m.active_entities.add_group();e=g.entities;a=m.selection.to_a;m.start_operation('x');a.dup.each{|o|a.shift;a.each{|i|e.add_line(o.bounds.min, i.bounds.min)}};m.commit_operation
          

          Copy paste into the Ruby Console+<enter>...
          This adds the new edges [bb.min to bb.min] to a group - explode if if that's not what's wanted... It is one step undo-able. You can of course filter it to only work on certain sorts of objects, or filter you selection beforehand... At the moment all of the edges go into one group but you could create groups for each set in turn thus:

          m=Sketchup.active_model;a=m.selection.to_a;m.start_operation('x');a.dup.each{|o|;g=m.active_entities.add_group();e=g.entities;(a-[o]).each{|i|e.add_line(o.bounds.min, i.bounds.min)}};m.commit_operation
          

          Which is probably more useful 😒

          TIG

          1 Reply Last reply Reply Quote 0
          • N Offline
            ninehundred
            last edited by

            Thank you so much for your reply, Im afraid im a bit of a novice when it comes to the ruby console so ive not been able to get it to work on my first go. ill tell you exactly what ive done. ive opened sketchup, made my 'components' (which are 2d circles) into actual components (using G). then ive opened up the ruby console and put in the second code. after i put the code in i changed every instance of '.min' to '.center' and then pushed enter. nothing has happened im afraid when i do this. what am i doing wrong?

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              It works on a selection so you need to select some objects before running the code.
              Incidentally, I recommend that you do use a component for the marker, otherwise a raw geometry circle will have many 'parts' [face+all_edges] that with each return a 'center' !
              Were there no messages in the Console?
              It probably said 'true' when it immediately finished processing the empty selection !

              Try as I say and report what happens... It works for me.
              here's the line with the 2 'center' methods added...

              m=Sketchup.active_model;a=m.selection.to_a;m.start_operation('x');a.dup.each{|o|;g=m.active_entities.add_group();e=g.entities;(a-[o]).each{|i|e.add_line(o.bounds.center, i.bounds.center)}};m.commit_operation
              

              TIG

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement