Linetool.rb in the developer docs example files


So i’m learning sketchup scripts, I know ruby and have been refering to the example files in the sketchup API developer docs. in the line tool example there is a cylinder tool that inherits from the line tool, i am trying to do the same thing as the cylinder tool only not as a cylinder, but as a more complex shape such as a T shape. however when adding a circle you give it a normal vector which is mouse-click-1 to mouse-click-2. i’m wondering how to give a different shape a normal vector so as to pushpull the profile in that direction in the script.
any suggestions or help?


In the example, the code needed input from the user to define a normal vector because that is one of the parameters required when you add a Circle. But any Face that you add will automatically have a normal vector associated to it. That is the direction that pushpull will extrude the Face. The only caution is to check which side is facing the direction you want to pushpull, as a positive distance will be in the direction of the normal and a negative direction will be opposite.


So how would you suggest i create a L or T shaped face with the two click points as the normal vector and position the T or L centered and on top of the click points line, if that makes sense


It sounds like you want to place your L or T at an arbitrary location and orientation based on two click points? Or do you just want to draw an L or T and pushpull it along its normal? As I mentioned before, unlike for a circle, you do not need a predefined normal vector to add a planar L or T shaped Face, just the array of its corner points.

But if you want the Face located and oriented arbitrarily, you need to calculate the locations of those corner points as located and rotated. That is a fairly complicated calculation unless you attack it in the right way: calculate the points as if they are on one of the primary planes (e.g. red-green), create a Transformation to your desired location and orientation, and remap the points using Point3d.transform! before adding the Face.

However, you should realize that as stated, this is not a well-posed problem. You don’t have enough information to specify the rotation of the L or T about the normal vector from the clicks. This is not the same as a circle (well, at least a real circle vs SketchUp’s collection of Edges representation) because a circle is the same at any rotation about its normal.


In case it was not clear what I meant by ill-posed, take a look at the attached screenshot. Both the gray and the green L’s have the same origin (are in the same plane) and the same normal, but they are rotated differently. There is not enough information from the two clicks to decide which you meant!


Thank you for your help with this, and i apologize for not being able to describe what i am looking for very clearly. I’m pretty new, I’m trying to create a tool that when selected you click two points just like the line tool, but instead of a line i want to create a predetermined shape in the code that aligns with the two points and is extruded from point to point.

i’m not familiar enough yet with sketchups methods to know how to orient a face to those points before extruding it the length of point A to point B. i know the clicks are not enough information to do the rotations and alignments. but rather they would set a path and length to extrude any pre-determined face on.

but maybe this attempt is out of my league for now. perhaps i should start on something a little simpler to polish my skills on the basics of the Sketchup framework. any suggestions for additional documentation or tutorials? I am currently reading which is from 2010