I have been working much less on AutoCAD these days, thus have not posted something for quite a while.
A while ago, I was asked by one of the users of the CAD tools I developed before that if it is possible to write some code so that CAD user can drag an entity along a given path. "It surely can be done", I said to the user immediately, " but I have not tried it yet" I added. I was thinking that it can be done with a DrawJig. I did not find time write some code to materialize it until now.
The idea of doing it is fairly simple: just implementing a DrawJig, and in the Jig's Sampler() method, instead of letting the entity follow the a cursor's path during dragging, we can find a point for the entity to move to in such way that the point must be on a curve (moving path). Therefore, we need a Curve entity as our moving path.
Also, since the goal is to give user visual feedback while entity is dragged and the entity moving is only to occur after the drag (should user not cancel the dragging), I use a cloned, non-database-residing entity as the visually moving part, which is disposed when the dragging is done.
Here is the class GuidedMovingJig:
Since the code wraps all user input actions (picking moving entity and its moving base point, picking moving path), it is really simple to use GuidedMovingJig class. Here the command method to use it:
This video clip shows the GuidedMovingJig class in action.