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

How can I draw a circle on a slope

Scheduled Pinned Locked Moved Newbie Forum
sketchup
17 Posts 6 Posters 2.7k Views 6 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.
  • J Offline
    jim130
    last edited by 30 Jun 2016, 02:53

    I need to draw a set of circles with in a loop with the center and 0,0,0 and all having the same radius but having the normal vector increment each time through the loop. So that each circle is sloped at a deferent angle.

    1 Reply Last reply Reply Quote 0
    • P Offline
      pilou
      last edited by 30 Jun 2016, 10:06

      Using Copy Rotate multiple?
      (if i understand the question πŸ˜„ )

      Make one copy with Selection + CTRL for give a step then type "" and any reasonable number on the numeric Keyboard!
      Note : you can type "
      " and different numbers untill you don't choose another tool! πŸ˜„
      If you type "/" you will have circles between the "step"! πŸ˜‰

      Very practical isn't it ? 😎

      GIF_circle.gif

      With "/" πŸ˜‰

      GIF_circle2.gif

      Frenchy Pilou
      Is beautiful that please without concept!
      My Little site :)

      1 Reply Last reply Reply Quote 0
      • W Offline
        wimve
        last edited by 30 Jun 2016, 15:38

        Ok, stupid question: how do you change the axes of the rotation ?

        Best regards,
        Wim
        Holland
        http://www.petromax.nl/DeBeer.html

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 30 Jun 2016, 17:07

          @wimve said:

          Ok, stupid question: how do you change the axes of the rotation ?
          Read up on how to use the Rotate tool [and Circle tool]... πŸ€“
          There are several ways...
          The axis of rotation can be inferred from the view direction into 'open space' orbit to see it change from red/green/blue.
          The axis of rotation can also be inferred from the 'normal' of any face currently below the cursor - this can be axial [red/green/blue] or off axis [black] depending on that face's orientation.
          Once the required axis of rotation is shown, then you can hold Shift to lock onto that axis, irrespective of the next point you click to set its actual location.
          With Rotate [but not Circle] you can also click+hold+drag along any edge, OR any axis, to lock the axis of rotation to that edge/axis...

          TIG

          1 Reply Last reply Reply Quote 0
          • P Offline
            pilou
            last edited by 30 Jun 2016, 17:12

            Select something
            Take the tool Rotation
            Snap it on the origine (move it and as soon as the snap is done)
            Move your mouse in any direction wanted! πŸ˜„

            In more general put the protractor on an existing face and block the oriention by Shift! πŸ€“
            (see the bottom help line text )

            Draw a little cube can be helping for have 6 faces oriented! πŸ˜‰

            Frenchy Pilou
            Is beautiful that please without concept!
            My Little site :)

            1 Reply Last reply Reply Quote 0
            • W Offline
              wimve
              last edited by 30 Jun 2016, 17:18

              @pilou said:

              Select something
              Take the tool Rotation
              Snap it on the origine (move it and as soon as the snap is done)
              Move your mouse in any direction wanted! πŸ˜„

              In more general put the protractor on an existing face and block the oriention by Shift! πŸ€“
              (see the bottom help line text )

              Draw a little cube can be helping for have 6 faces oriented! πŸ˜‰

              Ok, this is the way I do it now (the cube). Or sometimes use the shift from a already defined surface.
              But the example shown uses only the axes (I guess) since there isn't a surface already.

              Best regards,
              Wim
              Holland
              http://www.petromax.nl/DeBeer.html

              1 Reply Last reply Reply Quote 0
              • P Offline
                pilou
                last edited by 30 Jun 2016, 17:21

                Else with any surface if you want a special start inclinaison! πŸ˜„
                Here with the "/"

                GIF_inclined.gif

                Frenchy Pilou
                Is beautiful that please without concept!
                My Little site :)

                1 Reply Last reply Reply Quote 0
                • J Offline
                  jim130
                  last edited by 30 Jun 2016, 23:06

                  Sorry I should have been more specific.
                  Using Ruby in Sketchup: how to draw a circle and through the use of a loop to make copies of it rotated around the Y axis incremented by an angle each reiteration.

                  Thanks for all the responses.
                  Jim

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    TIG Moderator
                    last edited by 1 Jul 2016, 16:48

                    @jim130 said:

                    Sorry I should have been more specific.
                    Using Ruby in Sketchup: how to draw a circle and through the use of a loop to make copies of it rotated around the Y axis incremented by an angle each reiteration.

                    Thanks for all the responses.
                    Jim
                    Posting questions like this in the correct forum would be a better start [perhaps in Developers ?]...

                    Anyway...
                    Drawing a circle is explained here:
                    http://www.sketchup.com/intl/en/developer/docs/ourdoc/entities#add_circle
                    Set the axis for the normal for the initial circle - if you are adding it onto a face then it's probably best got from the face.normal ?
                    If you first add a main container_group into the active_entities context - to hold the various circles you are going to create - then you add a circle_group [or component] into that container_group.entities, then you add the circle into that circle_group.entities ...
                    http://www.sketchup.com/intl/en/developer/docs/ourdoc/entities#add_group
                    After making one circle_group you can copy it in code and adjust its transformation: read up here on rotation transformation - you need to determine an axis for this - possible from the cross of the initial 'normal' and the Z_AXIS - trapping for the normal==Z_AXIS
                    http://www.sketchup.com/intl/en/developer/docs/ourdoc/transformation#rotation
                    Tip - use angle.degrees to avoid headaches with PI etc !
                    Set up a loop, copying the circle_group the number required and also using a counter to increment the angle.
                    Because the circle groups are separate within the container you might want to explode them when you are done...
                    That depends on what you are expecting...

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • P Offline
                      pilou
                      last edited by 1 Jul 2016, 17:06

                      @unknownuser said:

                      Sorry I should have been more specific.

                      Indeed! That is not my part to code in SU! πŸ˜„

                      Frenchy Pilou
                      Is beautiful that please without concept!
                      My Little site :)

                      1 Reply Last reply Reply Quote 0
                      • J Offline
                        jim130
                        last edited by 6 Jul 2016, 22:58

                        This is my attempt at making and rotating the circle.
                        This is inside a loop so that angle_a changes each time through.
                        Without the two lines of code to make the transformation rotation, the grouped circle is created.
                        But when I add the transformation.rotation I get the error message "wrong number of arguments (5 for 3)"
                        The coke:

                        centerpoint = Geom::Point3d.new

                        vector = Geom::Vector3d.new 1,0,0

                        vector2 = vector.normalize!

                        model = Sketchup.active_model

                        entities = model.active_entities

                        circle = mod.active_entities

                        group=circle.add_group # Add the group to the entities in the model

                        edges = entities.add_circle centerpoint, vector2, 1,100 # at this point a circle is made

                        but when I add the next two line I get the error message.

                        pt1 = 0,0,0

                        transformation = Geom::Transformation.rotation pt1, 0,1,0, angle_a.radians

                        1 Reply Last reply Reply Quote 0
                        • S Offline
                          slbaumgartner
                          last edited by 7 Jul 2016, 12:31

                          Geom::Transformation.rotation takes three arguments: a Point3d, a Vector3d, and an angle. You need to either create an explicit Vector3d akin to what you did for vector or else pass the three components as an Array [0,1,0].

                          1 Reply Last reply Reply Quote 0
                          • T Offline
                            TIG Moderator
                            last edited by 7 Jul 2016, 13:12

                            The example code you gave has typos and incorrectly formed arguments etc.
                            Here's what you wrote:

                            centerpoint = Geom;;Point3d.new
                            vector = Geom;;Vector3d.new 1,0,0
                            vector2 = vector.normalize!
                            model = Sketchup.active_model
                            entities = model.active_entities
                            circle = mod.active_entities
                            group=circle.add_group # Add the group to the entities in the model
                            edges = entities.add_circle centerpoint, vector2, 1,100 # at this point a circle is made
                            # but when I add the next two line I get the error message.
                            pt1 = 0,0,0
                            transformation = Geom;;Transformation.rotation pt1, 0,1,0, angle_a.radians
                            

                            Here's what it should say:

                            model = Sketchup.active_model
                            ents = model.active_entities
                            contr = ents.add_group()
                            # to hold the circle groups
                            cents = contr.entities
                            group = ents.add_group()
                            gps = [group]
                            # Add the group to the container
                            gents = group.entities
                            gents.add_circle(ORIGIN, X_AXIS, 10.0, 96)
                            # circle at origin centered on the x axis 10" radius and 96 segments
                            # make reference to that group's definition
                            defn = gents.parent
                            # set step angle - here 30Β°
                            angle = 30.0
                            # set up counter - here 5 times for 180Β° == all needed circles [we already have 1 on x axis] !
                            ang = 0.0 # start at zero
                            5.times{
                              ang += angle
                              tp = Geom;;Transformation.new(ORIGIN)
                              tr = Geom;;Transformation.rotation(ORIGIN, Y_AXIS, ang.degrees)
                              inst = cents.add_instance(defn, tp*tr)
                              inst.make_unique
                              gps << inst
                            }
                            # you now have 4 circles, each inside a group, all inside a container-group
                            # if desired explode them - remove initial #
                            # gps.each{|gp| gp.explode }
                            # if desired explode container - remove initial #
                            # contr.explode
                            
                            

                            TIG

                            1 Reply Last reply Reply Quote 0
                            • J Offline
                              jim130
                              last edited by 11 Jul 2016, 23:03

                              TIG
                              Thank you very much.
                              I applied the code and it worked perfectly. I did make a modification to it as I was really looking for arcs in those circles.
                              But with few modifications I was able to achieve my goal. I had given up on the arcs and thought circles would be easier but still had to ask for help.
                              Thanks again.
                              One question about your solution, for me it is very hard to follow all the different group statements and there logical order. Without the logical understanding it is very hard to move forward in writing code.
                              I am probably not alone, and I was wandering if you could give a more thorough treatment of the grouping statements.
                              I’ve always been befuddled by the progression of these statements.
                              Thank you
                              Jim

                              1 Reply Last reply Reply Quote 0
                              • T Offline
                                TIG Moderator
                                last edited by 16 Jul 2016, 22:25

                                Put simply [no code]
                                Add a new 'container' group into the active_entities context [name==contr].
                                Then make some more groups inside that 'containers' entities context - each time these are made incrementing the angle... so into each of those we add the desired circle. oriented at that angle.
                                Now you have a new container-group which contains several sub-groups - each containing an oriented circle...

                                Do it manually to get a feel for what's involved.
                                Ding this kind of thing in code is just like doing it manually - but faster...

                                TIG

                                1 Reply Last reply Reply Quote 0
                                • J Offline
                                  jim130
                                  last edited by 24 Jul 2016, 21:59

                                  Thanks TIG
                                  I’ve have been beating my head against the code and am starting to get it.
                                  I do have one more question about the angle circle code though
                                  what does the "tptr" do in this statement? It looks like it is multiplying the two points together "inst = cents.add_instance(defn, tptr)"

                                  1 Reply Last reply Reply Quote 0
                                  • sdmitchS Offline
                                    sdmitch
                                    last edited by 24 Jul 2016, 23:01

                                    Actually it is multiplying two transformations and using that product to place the circle.

                                    Nothing is worthless, it can always be used as a bad example.

                                    http://sdmitch.blogspot.com/

                                    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