sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Getting normal to cylinder face

    Scheduled Pinned Locked Moved Newbie Forum
    sketchup
    5 Posts 3 Posters 846 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.
    • P Offline
      peterjohnson84
      last edited by

      Hi there,

      I am having some trouble with some code I'm writing and was wondering if there was a simple solution that I'm unaware of.

      My aim is to find vector the normal to a cylinder face (where the cylinder has beeen 'stored' as a group) and from that, work out the orientation of the cylinder group. So far, I have been able to do this for a cylinder which I created. However if I rotate the cylinder and perform the same operation, the normal vector does not change with the rotation i.e. if I create a cylinder aligned along the z axis - circle.normal will always give (0,0,1) despite any rotation i perform on the group.

      I assume the information about the rotation is stored somewhere and from this I could work out the cylinder orientation - but I'm at a loss to work out how to do this.

      Any help with this would be greatly appreciated.

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

        Try adjusted_normal=face.normal.transform!(group.transformation)
        where 'group' is the container of the circle-'face' on the end?

        TIG

        1 Reply Last reply Reply Quote 0
        • P Offline
          peterjohnson84
          last edited by

          Cheers TIG, that did the trick.

          1 Reply Last reply Reply Quote 0
          • B Offline
            bentleykfrog
            last edited by

            Just answered my own question, transformation is relative to the parent.

            Here's some more compact code:

            normal = entity.normal
            for i in (0..(path_to_entity.length-2)) do
              e = intersect_path[i]
              normal = normal.transform! (e.transformation)
            end
            
            1 Reply Last reply Reply Quote 0
            • B Offline
              bentleykfrog
              last edited by

              @tig said:

              Try adjusted_normal=face.normal.transform!(group.transformation)
              where 'group' is the container of the circle-'face' on the end?

              Sorry for digging up an old topic, but will this work with nested groups/component instances?

              normal = entity.normal
              i = 0
              path_to_entity.each {|entity|
                i +=1
                break if i >= path_to_entity.length
                normal = normal.transform! (entity.transformation)
              }
              

              Or does transform represent a transformation from the models axes? (ie, just require normal = normal.transform! (entity.transformation)

              Just for background, I'm trying to get a model based vector of the face normal as in peterjohnson84's example

              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