sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Follow me code issue?

    Scheduled Pinned Locked Moved Developers' Forum
    12 Posts 3 Posters 874 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.
    • TIGT Offline
      TIG Moderator
      last edited by

      You suddenly produce a reference ' face' from nowhere!
      The .find_faces returns the number of faces found no more!
      Instead of
      entities.add_line(p4, p4d) entities.add_line(p4d, p8d) entities.add_line(p8d, p8) e = entities.add_line(p8, p4) e.find_faces face.followme(edges)### **error** what '**face**'
      Why not make the face from the four - hopefully coplanar points ?
      [which will automatically add the four edges anyway]
      face=entities.add_face(p4, p4d, p8d, p8) face.followme(edges)if face
      ๐Ÿ˜ฎ
      You could also pass an array so pts=[]
      You code adds points as they get made
      pts << p4 etc
      then pts

      [p4, p4d, p8d, p8]
      Then use
      face=entities.add_face(pts) face.followme(edges)if face
      ๐Ÿ˜ฒ

      TIG

      1 Reply Last reply Reply Quote 0
      • T Offline
        tomot
        last edited by

        I'm well aware the following works!

            #...1 followme profile 
            edges = entities.add_edges(p4, p1, p2, p3, p0, p4)
            #...2 primary section profile used by follow-me
            face = entities.add_face(p4, p4d, p8d, p8)
            face.followme(edges) 
        

        that's why I included asking how arc'swould be considered into a complex shape, a simple example would include 2 lines and one arc making a simple cove molding? once that shape is collected by ,e.find_faces what followme code will I need to get the extrusion?

        [my plugins](http://thingsvirtual.blogspot.ca/)
        tomot

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

          As I explained - or tried to - e.find_faces adds faces where it can BUT it only returns the number of faces the edge has after it's done - so it's relatively useless.
          However, IF you sensibly make all of your new geometry inside a group [even if you explode that group at the end!] then you can readily find the new face[s].
          Before you make the new faces get a list of existing ones
          facesIN=[] entities.each{|e|facesIN<<e if e.class==Sketchup::Face}
          now use find_faces and relist faces
          facesOUT=[] entities.each{|e|facesOUT<<e if e.class==Sketchup::Face}
          faces=facesOUT-facesIN
          if you are sure there's only one new face use
          face=faces[0]
          otherwise you need to iterate through faces...
          NOW you can use face.followme(edges) ๐Ÿค“

          TIG

          1 Reply Last reply Reply Quote 0
          • T Offline
            tomot
            last edited by

            TIG, after a lot of struggling. I finally found some existing ruby code that helped me solve the follow-me face problem I posted.

                #...1 followme profile 
                edges = entities.add_edges(p4, p1, p2, p3, p0, p4)
                #...2 draw the profile used by follow-me
                ent1=entities.add_arc( p7c, vecx, normal, -width/4, 0, 90.degrees) 
                ent2=entities.add_arc( p7, vecx, normal, width/2, 0, 90.degrees)
                ent3=entities.add_line(p5, p4) 
                ent4=entities.add_line(p4, p4d)
                ent5=entities.add_line(p4d, p8d)
                ent6=entities.add_line(p8d, p8c)
                face = entities.add_face([ent1, ent2, ent3, ent4, ent5, ent6].flatten)
                face.followme(edges) 
            

            I have not found a reference to flatten in the Sketchup ruby API, but without flatten the face will not be formed for face.followme(edges) to work!

            which now again raises my concern why we need a erase_face routine in the API which is required imminently, since followme does not behave the same in a Ruby as it does in the normal sketchup program.

            face = entities.erase_face([ent1, ent2, ent3, ent4, ent5, ent6.flatten)] should logically erase the redundant face in the attached pic. I know you provided a valuable workaround for faces which requires an additonal 15 lines of code see http://forums.sketchucation.com/viewtopic.php?f=180&t=40136, regardless it does not solve the current .flatten solution.


            frame1.jpg

            [my plugins](http://thingsvirtual.blogspot.ca/)
            tomot

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

              The Ruby method .flatten is used to 'explode' arrays inside an array.
              So array=[[0, 1, 2], [3, 4, 5]] flat_array=array.flatten
              returns another array thus
              [0, 1, 2, 3, 4, 5]
              The original array is not changed by this porcessing
              To change the original in place use
              array.flatten**!**
              which turns array into
              [0, 1, 2, 3, 4, 5]

              TIG

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                I would rather see the followme method have a 2nd boolean argument (whether to erase the profile or not... and it's false as it is now.)

                @Tomot: Do you have the CHM Reference for the standard Ruby classes ??
                If not get it here: http://forums.sketchucation.com/download/file.php?id=53397

                I'm not here much anymore.

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

                  If the profile is perfectly perpendicular to the first edge of the path, and the path is a loop then there should be no residual profile[s] left.
                  It seems you have a minor inaccuracy that results in the 'end-face[s]' being left, just as if the path were NOT a loop...
                  ๐Ÿ˜•
                  As I said before... your various transformations before the followme might cause this minor variance...
                  Why not forget the transformations - make the followme extrusion and then transform ts entities to be 'vertical' or whatever...

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    tomot
                    last edited by

                    TIG & Dan thanks for your input. The simplest example I have, is attached

                    It extrudes a circle via a user initiated rectangular path. It contains no transformations. The view stuff in the menu is my clumsy way of making sure the circle profile is oriented in the correct 3d plane prior to the user initiating the path. Or maybe more correctly the clumsy way the Ruby API deals with 3d entity orientation in a simple 3d coordinate system.

                    As I indicated before I use $ only for development purposes so I can check the coordinates of each point in the console. hence if I start with a predefined SKP file which has a rectangle of known coordinates starting at (0,0,0) and ending at (0,0,0), I can check if I have made any math errors in my ruby code, hence following a path of known coordinates, should verify my Ruby coordinates.

                    I do not disagree with you that in a perfect loop there should be no residual profile left over. But I have not been able to replicate that yet, with followme. Until.... NOW. Perhaps it has something to do with the accuracy in decimals places Sketchup uses in its internal math engine.

                    The attached .rb is quite straight forward it should not cause any great trouble in reading the intent of the code. It turns out that a simple closed path is NOT sufficient to eliminate the original profile. There needs to be one additional point on the loop with a new coordinate slightly more than the overlap, .001, appears to be the minimum value. This new point needs to be added to the loop to provide the required overlap, now the residual profile will disappear.

                    p.s. I wonder if Steve Jobs would have ever implemented Ruby, and Web dialogs, and Java and CSS ......R.I.P. Steve Jobs.


                    FrameTool.rb

                    [my plugins](http://thingsvirtual.blogspot.ca/)
                    tomot

                    1 Reply Last reply Reply Quote 0
                    • Dan RathbunD Offline
                      Dan Rathbun
                      last edited by

                      @tomot said:

                      I do not disagree with you that in a perfect loop there should be no residual profile left over. But I have not been able to replicate that yet, with followme. Until.... NOW. Perhaps it has something to do with the accuracy in decimals places Sketchup uses in its internal math engine.

                      Makes sense. All co-ordinates should be rounded to 0.001" intervals (accounting for model unit conversion.)

                      @tomot said:

                      p.s. I wonder if Steve Jobs would have ever implemented Ruby, and Web dialogs, and Java and CSS ......R.I.P. Steve Jobs.

                      All Macs come "out-of-the-box" with MRI Ruby pre-installed, and Apple is working on their own edition, coded in C++ (similar to YARV,) that is called MacRuby. Apple can recognize a good thing. MicroSoft will not support good things unless they create or control them. (They have dropped support for the IronRuby project.)

                      I'm not here much anymore.

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

                        My earlier recommendation stands.
                        Make the looped path 'flat' in the ground plane and the perpendicular profile-face
                        Do the followme using those.
                        There should be no residual geometry as there will be no transformation tolerance messing things up.
                        NOW transform the group.entities in one go so they are reoriented as you want - e.g. standing on end.
                        Moral: if doing something one way breaks it then do it another way that doesn't.
                        There can be several routes to a destination, so why keep trying the seemingly shortest route when you know the bridge is out as you won't arrive at all - better to go the long way round and actually get there !
                        ๐Ÿค“

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • Dan RathbunD Offline
                          Dan Rathbun
                          last edited by

                          Good "Occamish" advice TIG.

                          I'm not here much anymore.

                          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