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

    Exporting solids & reversed faces

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 114 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
      noelwarr
      last edited by

      I'm using a third party library that takes triangulated manifold polyhedra as input. I have a SketchUp plugin that iterates through a solid's Faces, creates PolygonMeshes from them and then does a bit of cleaning up to link these PolygonMeshes together. No big deal.

      Problem is when I reverse one of the faces inside SketchUp. Sketchup still considers this to be a solid but the PolygonMesh my script creates is also reversed and my thrird party library throws an error.

      I know of two possible solutions to this but they are both heavy duty and a but ugly. I was hoping someone might have a better suggestion. The two I am aware of are:

      1. Draw lines along the normals of each face (From the face, outwards). Count the number of faces it intersects. Reverse if even, do nothing if odd.

      2)Take one face as a reference. Make sure all adjacent faces are aligned similarly by checking the order of it's vertices. Iterate through the structure until all faces have been checked. If construction of polyhedron fails, reverse all faces.

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

        I wrote a face.orient_faces method that is in a [Code] post, from over 6 years ago - learn to SCF search... πŸ˜‰
        http://sketchucation.com/forums/viewtopic.php?p=15273#p15273
        This mimics the native 'orient'.
        Seems to me that since you will need to open these SKP files to see if they are OK [?] why not skip the awkward coding solution, use a style with a distinctly color back-face material, View>Monochrome mode and simply pick a right oriented face and use the native context-menu 'Orient' [you should have already set shortcut keys to 'Reverse' and 'Orient' !]... πŸ˜•

        TIG

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

          Cheers TIG. I did do a bit of SKF ploghing but obviously not enough.

          This is all part of a plugin I've been developing (http://www.vistii.com) which relies on users supplying the solids. It seems a little cumbersome to keep telling users that their solids are not valid for some reason or another. It would be much nicer to clean up after them.

          So, if you don't mind, I'll be mimicking your code. I don't want to take it "as is" since I don't want to monkey patch the Face class. Thanks for the help.

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

            @noelwarr said:

            1. Draw lines along the normals of each face (From the face, outwards). Count the number of faces it intersects. Reverse if even, do nothing if odd.

            You don't mean making actual edges, right?

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

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

              No, just lines and using methods like Geom::intersect_line_plane and then checking weather the intersection lies withing the face itself. It's complicated and error prone (When lines intersect edges instead of faces) but can be made to work.

              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