These days it seems like most of my API manipulations can be accomplished by rehashing previous code with some minor tweaks. In other words I don’t come across something totally new as much as I used to, I guess I’ve been at this a while now.
Today however, I am trying to build a tool which will allow me to select one of the edges of a face/group however the actual edges may or may not actually exist within the model. The points that define these edges are actually an array within my foundation’s attribute library. I can utilize these points to define the edges in question.
My first thought is to draw a temporary face/group given the points and then my tool can allow the user to select an edge. Once the selection is done the tool would then have to erase this temp group (face and edges), at that point I would then pass the vertices of that edge to the rest of my logic. My only reservation with this method is I don’t like inserting temp geometry as a rule of thumb since something could potentially disrupt the tool and then this temp group would be left abandoned within my model.
My other thought is to use the Draw method(s) of the Tool class and create the virtual face/edges this way. However there does not appear to be any way to select the geometry created by the Draw method of the Tool class since it really isn’t valid geometry within the model.
It’s highly possible that there is a something I’m missing here or even a third and better way to accomplish this edge selection process. I am very open to any thoughts or ideas anyone might have on the matter.
I think you are on to something here but I also need to be able to determine what edge the point is on and then send the vertices of that edge/line (two points) back to the rest of the program.
I’m digging through the Geom class right now to see if I can make this happen without actually having to construct (temporary) physical geometry within SketchUp.
There is probably more than one way to solve this problem but the first method that comes to me is to create a vector for each endpoint (pointing towards the point in question). Then compare their directions.
If the point is between the two endpoints the vectors will always be in opposite directions. If the point is outside of the end points then the two vectors will be in the same direction.
There may be a more computationally lightweight solution that this, but I don’t see a ready made method so far in the class.