@tt_su said:
@f94sbu said:
It might be desirable to extend InputPoint so that it can return the transformation for each of the different entities that it can refer to. Or at least add a note to the documentation that the transformation might not be useful for all referenced entities.
The purpose of InputPoint isn't to pick entities, that's why there is differences between the PickHelper.
The fact that is returns a face, edge, or vertex is simply meta data to indicate what it gets the position from.
Are you trying to pick an entity and at the same time get a 3d position? Can you explain the use case for this?
It took me a while to understand the difference between PickHelper and InputPoint, and your explanations were very helpful. The documentation was rather vague as it mostly described the two as 'similar' but did not go into depth of the difference.
This is the use case:
I have created a 'drilling' tool that allows you to drill holes through objects. I am using Sketchup for mechanical construction and I needed a way to place (and track) screw holes in my model. The usage of the tool is rather simple, just click a face and the tool will ask you which drill size you want to use (and an optional depth for blind holes). The tool will then create a circle on the face (centered around the click), push the cut surface through the object and then it records the center by placing a cross (2 edges) in the center of the circle. The drill size used is also assigned as an attribute to one of the edges so that I can iterate through the model at a later time (during G-code generation) to generate G-code for drilling the holes. The purpose of the cross is to have an anchor for the hole when you want to line things up (such as screws or objects with corresponding holes). Most of the time, matching holes will be of different sizes as one hole is sized for the screw and the other is sized smaller to use a tap to create threads in it. (That's why I don't rely on Sketchup's ability to snap the two holes together.)
Also, if I have added a hole to an object and I want to drill the corresponding hole, all I need to do is to add a guide that is perpendicular to the hole by grabbing a perpendicular edge and then snap the guide with the center of the cross.
To accomplish the above I needed to get the following things to work:
- To push the hole through, I obviously needed to get the face to modify, but I also need to get this in the local coordinates of the face as I am adding entities to the same group/component as the face it self, otherwise I would just add a cylinder, not a hole, and it is desirable tha the holes move with the component if I rearrange things
- To know which 3d coordinate to use, I need to get the 3d coordinate that the user clicked on, but this needs to be snapped to whatever guide that the user used. As often place holes referenced from other holes, I need to make sure that the 3d point is snapped correctly. Most of the time, I create the guides without caring about which group that is open for editing. The transformation returned by InputPoint will be from the guide which is often different from the transformation of the group that I will be modifying.
PickHelper gives me all that I need (picked face and translation) except that it does not tell me the 3d coordinate that was snapped from the mouse x,y. Thats what I need to use InputPoint for. I guess I could disregard the face returned from InputPoint, I just added a comparison between the face from InputPoint and the leaf in PickHelper to make sure that they are equal in case something goes wrong and PickHelper does not pick the same face as InputPoint snapped to. I guess this is unlikely (impossible) and I have not yet seen them to be different, but I just felt it was a good safeguard.
So short answer I guess would be, Yes I need to pick an entity at the same time as I am picking a (snapped) 3d position
I would not be surprised if the 'problem' fredo described is related to what you described about InputPoint. InputPoint may have used several entities to snap its position and as it is not possible to tell which of them that was the origin for the transformation in InputPoint, the transformation in InputPoint is most of the time too ambiguous to be used for editing or adding entities.