Transformation tap method
-
Can anyone tell me more about the #tap method listed in the #transformation method?
-
@sjn001tvh said:
Can anyone tell me more about the #tap method listed in the #transformation method?
Please give us a clue why you think you need this...
There is no [useful] 'tap
' method for a 'transformation
' exposed in the API...
However, like a lot of other things there are many 'inherited' methods - which are not always very useful...
A 'tap
' call can be used to pass data to a{}
block.
But if you usetransformation.tap{|e| p e }
It simple produces a reference back to the 'transformation
' !
So not too useful !!Google Ruby tap and you'll see that there's not a lot of use with a
transformation
, since you can get the same results by directly interrogating it... -
Thank you for your response. I'm trying to create a center point of a circle when I add this object to a group, and maintain the center point reference so that I can quickly move it to a perpendicular line in my model.
I have researched midpoint.rb by Rick Wilson, but the method he proposes in this routine suggests the user (ie. myself) is/am moving the cursor over the object to create the center point.
My goal is to use his calculations in creating the center point automatically to create the center point of a circle or an object.
In short my goal is, when I Create and/or Select the object from my model (for instance: a circle, which is not definitively defined as a circle except if I place it the object type Circle in the name), and somehow maintain specific information about the circle object such as diameter or radius, and use that information to determine the center point. And then, use a Snap button to quickly move the object to the specific reference line that I have created for a drilled hole.
This information needs to be generated at the time I create the object. I have researched for days, cpoint, cline, bounds, origin, width, height, depth, and many other methods, which simply after several iterations makes my head spin, and I simply go back to the basic concept, and start again.
Step 1. I create the circle, and it has a radius, but the original information doesn't seemed to stored permanently with the object, such as diameter/radius.
Step 2. I had previous created a reference line (2 connected lines which I'm able to group) perpendicular to the circle.
Step 3. I Select the circle (Group) and from an HTML input screen and select from a list of objects (such as the reference line for the middle of a drilled hole) and execute a button to snap to the end of the reference line.
The data I need is the center point of the circle so that I can use the transformation method to move the circle to the end of the reference line and automatically position it to the center.
As I was reviewing all of these options, I came across the tap method and there was nothing in the documentation on this method. This is the reason for the request.
I'm still stumped. It seems my only options are to prompt the input of the original radius of the circle when I create the a group with the name containing the word circle.
Am I the only one who has ever come up with this type of method that has made it seem so difficult to perform?
Thanks,
Scott.
-
http://ruby.sketchup.com/Sketchup/Entities.html#add_circle-instance_method
When you add acircle
you need to specify its 'center
' - so you know where that is.
You also have a 'normal
' vector specified for the circle - so you have that to create a perpendicular line etc.So I can't see the issue.
BUT, if this
circle
is preexisting before your code runs, then consider using methods from...
http://ruby.sketchup.com/Sketchup/ArcCurve.html
The edges of any circle each contain things like that arc's 'center
' and 'normal
'...There's no need for '
transformation
' etc... -
Hi TIG,
I think I discovered a method that will work.
When I first create the circle, it has a face, and using the bounds.height I'm able to calculate the actual diameter of the circle. If a create a washer which has a hole in the middle, I can query the two circles to determine the largest of .bounds.height of the two circles and that provides me the diameter. I can then calculate the center point from that measurement of the diameter.
I've tried it several times and it seems to work. With that information I can also add an option to create a construction point/line if I want to visually see the center point.
Thanks again,
Scott.
-
You have the
center
,radius
andnormal
before you add thecircle
.
Then when you add thecircle
it returns an array of edges
edges = entities.add_circle(...)
From any one of thoseedges
you can get theArcCurve
, and from that you can get itscenter
,radius
andnormal
.I still think this can be done more simply.
But if you have something that works... then go with it...
Advertisement