sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    How to inspect all faces?

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 3 Posters 267 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.
    • M Offline
      Mcdull
      last edited by

      i want to inspect all faces of a model,and get coordinats of each face,how to do it?is there any demo?example code?
      thank u

      1 Reply Last reply Reply Quote 0
      • Chris FullmerC Offline
        Chris Fullmer
        last edited by

        Sure, have you coded anything before? Anything in Ruby? Its pretty simple to get the base of what you want, but I'm concerned about what you want to do with it. Just a list of xyz values for every vertex in the model seems rather useless, but perhaps its useful to you? This will get you started.

        ` model = Sketchup.active_model
        ents = model.entities
        faces = []
        vert_array = []

        ents.each { |e| faces << e if e.is_a? Sketchup::Face }
        faces.each { |e| vert_array << e.vertices.collect { |ff| ff.position } }

        puts vert_array`

        That will not drill down into components or groups, it just skips them I think. But its a start. Do have any better clues what you wouild like to use this for?

        Lately you've been tan, suspicious for the winter.
        All my Plugins I've written

        1 Reply Last reply Reply Quote 0
        • M Offline
          Mcdull
          last edited by

          yes ,i have coded before,but the peogramme is very simple. thanks for your relpy.the reason why i want to do it is that i want to load SKP model in XNA.yes,it can load directly only if transforming the model type into .fbx.however,the model in XNA is triangular mesh,i want to organize the model with face,which can contains triangular meshes. then i can trace the face from eachtriangular mesh. so i can select each face like doing it in sketchup,rather than a triangular mesh in XNA.
          i don't whether my representation is clear,and i am very happy to discuss with u.thank u!

          1 Reply Last reply Reply Quote 0
          • M Offline
            Mcdull
            last edited by

            @chris fullmer said:

            Sure, have you coded anything before? Anything in Ruby? Its pretty simple to get the base of what you want, but I'm concerned about what you want to do with it. Just a list of xyz values for every vertex in the model seems rather useless, but perhaps its useful to you? This will get you started.

            ` model = Sketchup.active_model
            ents = model.entities
            faces = []
            vert_array = []

            ents.each { |e| faces << e if e.is_a? Sketchup::Face }
            faces.each { |e| vert_array << e.vertices.collect { |ff| ff.position } }

            puts vert_array`

            That will not drill down into components or groups, it just skips them I think. But its a start. Do have any better clues what you wouild like to use this for?

            yes ,i have coded before,but the peogramme is very simple. thanks for your relpy.the reason why i want to do it is that i want to load SKP model in XNA.yes,it can load directly only if transforming the model type into .fbx.however,the model in XNA is triangular mesh,i want to organize the model with face,which can contains triangular meshes. then i can trace the face from eachtriangular mesh. so i can select each face like doing it in sketchup,rather than a triangular mesh in XNA.
            i don't whether my representation is clear,and i am very happy to discuss with u.thank u!

            1 Reply Last reply Reply Quote 0
            • Chris FullmerC Offline
              Chris Fullmer
              last edited by

              So you want the vertices of each SU face because SU allows non-triangulated faces. And you want to use that data to convert the triangulated faces in XNA into faces more like in SU? Is that more or less the idea? Do you know how to use this data in xna? Can you create a script in xna that takes a series of vertices, finds all faces in xna bounded by those vertices, then turns them all into a single xna face? That seems to be about what your looking for, maybe?

              Lately you've been tan, suspicious for the winter.
              All my Plugins I've written

              1 Reply Last reply Reply Quote 0
              • M Offline
                Mcdull
                last edited by

                @chris fullmer said:

                So you want the vertices of each SU face because SU allows non-triangulated faces. And you want to use that data to convert the triangulated faces in XNA into faces more like in SU? Is that more or less the idea? Do you know how to use this data in xna? Can you create a script in xna that takes a series of vertices, finds all faces in xna bounded by those vertices, then turns them all into a single xna face? That seems to be about what your looking for, maybe?

                yes,i am trying to realize the idea.we can just draw point,line,triangle in XNA,so we have to draw a series of triangles to represent a polygon or a face.i know how to draw a series of triangle meshes with a series of vertices. any other method to trace the face from each triangle mesh in .x model or .fbx model?

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

                  You probably want to look into the PolygonMesh class as well. if you use face.mesh - it willl return a PolygonMesh for that face. The PolygonMesh is triangualted.
                  I got a plugin that let you hover over a face and visually see the PolygonMesh representation of that face: http://forums.sketchucation.com/viewtopic.php?f=323&t=21472

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

                  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