sketchucation logo sketchucation
    • Login
    ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

    Face loop vertex order?

    Scheduled Pinned Locked Moved Developers' Forum
    15 Posts 4 Posters 2.1k Views
    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.
    • D Offline
      draftomatic
      last edited by

      Is there an order to Loop.vertices retrieved from Faces? I think I read somewhere that outer_loop is guaranteed to be counter-clockwise. What about inner loops?

      Just did a quick check on a donut-like face, and the outer loop is CCW, but the inner loop is CW. Is that always the case?

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        hm... not sure... never looked into iut. but you bring up an important issue. This should be information written down in the manual.

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • honoluludesktopH Offline
          honoluludesktop
          last edited by

          When I import a 3dface from a Dxf file, the direction of the front face determines the direction the vertices's are drawn. As I recall, when the front side is visible, the vertices's are CCW, and when the back face is seen, the vertices's are CW.

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

            Outer-loops are always returned counter-clockwise.
            Inner-loops are always returned clockwise.
            This 'rotation' is relative to the face.normal.
            Both face.vertices and loop.vertices are 'ordered' - starting from a non-specific vertex.

            To demonstrate it to yourself use this snippet...
            [NB: you must have selected a face with inner and outer loops beforehand]

            m=Sketchup.active_model;es=m.active_entities;f=m.selection[0];o=f.outer_loop;ls=f.loops-[o];i="outer#t000";o.vertices.each{|v|es.add_text(i,v.position,[2,2,2]);i.next!};i="inner#000";ls.each{|l|l.vertices.each{|v|es.add_text(i,v.position,[2,2,2]);i.next!}};
            
            

            TIG

            1 Reply Last reply Reply Quote 0
            • D Offline
              draftomatic
              last edited by

              @tig said:

              Outer-loops are always returned counter-clockwise.
              Inner-loops are always returned clockwise.

              Thanks TIG, I know you've posted on this before... just wanted to be sure!

              1 Reply Last reply Reply Quote 0
              • honoluludesktopH Offline
                honoluludesktop
                last edited by

                TIG, I got the following error:

                Temp91.jpg
                Btw, Is there a way to tell if the inner loop is faced or not? How are multiple inner loops vertexes created?

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  Did you select the face before running the code?

                  Thomas Thomassen — SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • honoluludesktopH Offline
                    honoluludesktop
                    last edited by

                    Yes, I ran it in web console. The error message says that the problem is that the outer_loop is not a method for edges, so I tried to do a loop for faces, but failed.

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      From the screenshot it doesn't look like you selected the face.
                      I just tried the code myself, works fine.

                      Thomas Thomassen — SketchUp Monkey & Coding addict
                      List of my plugins and link to the CookieWare fund

                      1 Reply Last reply Reply Quote 0
                      • honoluludesktopH Offline
                        honoluludesktop
                        last edited by

                        Hmm.... I'll try again.

                        1 Reply Last reply Reply Quote 0
                        • honoluludesktopH Offline
                          honoluludesktop
                          last edited by

                          What could the problem be.....Must be with my system???????


                          temp00.jpg

                          1 Reply Last reply Reply Quote 0
                          • thomthomT Offline
                            thomthom
                            last edited by

                            In that example you have selected lots of edges.

                            Select only the face.

                            Thomas Thomassen — SketchUp Monkey & Coding addict
                            List of my plugins and link to the CookieWare fund

                            1 Reply Last reply Reply Quote 0
                            • honoluludesktopH Offline
                              honoluludesktop
                              last edited by

                              Got it. I was previously selecting everything. Guess I'am not too good at following instructions. The top image is with selection of the outer ring, and the bottom image is that of the center. Btw, I have on-board Intel at home, so OpenGl fails here for me, and face selection isn't clear.

                              When I draw faces by lines, going clock wise, or counter clockwise creates different sides of a face. but clearly (now to me), that is a situation unrelated to this.

                              Too bad I can't use this to find holes in faces generated by closed Dxf polyline data.


                              temp00.jpg

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

                                A loop that is ONLY an outer-loop returns its vertices counter-clockwise.
                                A loop that is an inner-loop only OR that is an outer-loop to one face BUT also formers an inner-loop to another face returns its vertices clockwise - even if it is the outer-loop to a face you are testing - you can of course check for the loop's duplicity and take that into account.
                                You need two sample DXFs - one with a face+hole and the other the same but with the hole filled - then you could find the difference ?
                                There are rules about face normal and loop direction for CAD 3D Faces ? Are you following these ??

                                TIG

                                1 Reply Last reply Reply Quote 0
                                • honoluludesktopH Offline
                                  honoluludesktop
                                  last edited by

                                  TIG, As you suggest, I will work on this and post what I find. Thanks.

                                  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