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

    Draw cpoint on face

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 275 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.
    • liquid98L Offline
      liquid98
      last edited by

      Hello,

      I was wandering how to draw a point on a face like this?

      https://lh3.googleusercontent.com/-k7cP9G4kfYg/URAAWspge9I/AAAAAAAABbo/RcWw9FqtfvM/s1280/face.jpg

      My strategy would be:
      1: Find outer_loop.vertices for the face.
      2: Use outer_loop.vertices[0] as a starting-point to place the desired point by trial and error, while using the classify_point method for the face.

      The problem of this method is that near the vertices there could be holes of
      which the script is not aware.

      Best regards,

      Liquid


      face.skp

      Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

      1 Reply Last reply Reply Quote 0
      • jolranJ Offline
        jolran
        last edited by

        Well where do you want the point?

        You also have face.plane and face.bounds to play with.
        From bounds you can find the center etc..

        Might be more useful if you wanna find a position in a hole..

        1 Reply Last reply Reply Quote 0
        • liquid98L Offline
          liquid98
          last edited by

          This might be usefull:

          http://geomalgorithms.com/a03-_inclusion.html

          Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

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

            You can easily find an arbitrary point on the face.plane - for example:
            face.outer_loop.vertices[0].position
            face.bounds.center
            etc

            Then API's face.classify_point(point) returns various codes depending on the state of that point.
            See http://sketchup.com/intl/en/developer/docs/ourdoc/face.php#classify_point

            0: Sketchup::Face::PointUnknown (indicates an error),
            1: Sketchup::Face::PointInside (point is on the face, not in a hole),
            2: Sketchup::Face::PointOnVertex (point touches a vertex),
            4: Sketchup::Face::PointOnEdge (point is on an edge),
            16: Sketchup::Face::PointOutside (point outside the face or in a hole),
            32: Sketchup::Face::PointNotOnPlane (point off the face's plane).
            

            It is important that return value comparisons be made against the symbolic constants (i.e. Sketchup::Face::PointUnknown, Sketchup::Face::PointInside, Sketchup::Face::PointOnVertex etc) rather than the absolute integer values, as these values may change from one release to the next.

            Once you have a point you know is on the face.plane, then you can 'nudge' it using point.offset!(vector), where the vector has a small length and is predetermined to run along the face.plane - you know the face.normal vector already... Then you retest the point for its classification on the face... Iterate until the point is on [or off?] the face as you want it to be...

            To add the cpoint is straightforward... face.parent.entities.add_cpoint(point)

            TIG

            1 Reply Last reply Reply Quote 0
            • liquid98L Offline
              liquid98
              last edited by

              TIG,

              Thanx for your answer, it completely elucidates my question.

              Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

              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