How can I draw a circle on a slope
-
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.
-
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 ?
With "/"
-
Ok, stupid question: how do you change the axes of the rotation ?
-
@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... -
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!
-
@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. -
Else with any surface if you want a special start inclinaison!
Here with the "/" -
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 -
@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... -
@unknownuser said:
Sorry I should have been more specific.
Indeed! That is not my part to code in SU!
-
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
-
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].
-
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
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 -
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... -
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)" -
Actually it is multiplying two transformations and using that product to place the circle.
Advertisement