Transformation tap method

Transformation tap method

Postby sjn001tvh » Thu Nov 08, 2018 5:03 am

Can anyone tell me more about the #tap method listed in the #transformation method?
0

sjn001tvh 
 

Re: Transformation tap method

Postby TIG » Thu Nov 08, 2018 4:19 pm

sjn001tvh wrote: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 use transformation.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...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: Transformation tap method

Postby sjn001tvh » Thu Nov 08, 2018 8:52 pm

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.
0

sjn001tvh 
 

Re: Transformation tap method

Postby TIG » Thu Nov 08, 2018 9:15 pm

http://ruby.sketchup.com/Sketchup/Entit ... nce_method
When you add a circle 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...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: Transformation tap method

Postby sjn001tvh » Thu Nov 08, 2018 9:21 pm

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.
0

sjn001tvh 
 

Re: Transformation tap method

Postby TIG » Thu Nov 08, 2018 9:38 pm

You have the center, radius and normal before you add the circle.
Then when you add the circle it returns an array of edges
edges = entities.add_circle(...)
From any one of those edges you can get the ArcCurve, and from that you can get its center, radius and normal.

I still think this can be done more simply.
But if you have something that works... then go with it... ;)
0
TIG
User avatar
TIG 
Global Moderator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: Bing [Bot], shreyas and 7 guests

Visit our sponsors: