Hi,
I'm trying to get the coordinates of an entity while its being dragged.
The functionality im trying to create is a line with an associated circle on the endpoint. When i move the line up i want the circleto move up as well (while im dragging or stretching it). And when I move the circle i want the line to stretch with it.
So I have a custom entity and inherit this method: void AcDbEntity::dragStatus(const AcDb::DragStat status)
which gets called on moving but not on stretching, the other problem is AcGePoint3d sp = startPoint(); always gives me the same coordinates, because autocad clones the line. How do I access this clone??
Is there a better way to do this? I have researched:
- AcEdJig - seem to only be used to create new entities. not get drag information when its already created
- AcDbEntityReactor::dragCloneToBeDeleted --can not get this method called, else it would be great.
- The associative framework seems way too complex for this? Or is this the best way?
I'm kind of lost here.
Best regard,
Peter
Hi,
The best way to do this, it's to define a persistent reactor between entities. Have a look to the example reactors\persreac_dg in the Object ARX API.
Regards,
Hi Jonathan,
In the example it would be:
- stretch first line
- release mouse
- second line gets updated
what i want is
- stretch line
- update second line while the first one is being stretched/moved , live
Do you think something like that is possible? It might also just be a visual thing im looking for, because i can see the problem with the undo if it the stretch operation is cancelled. The visual thing is, imagine a line and circle that are both related but are seperate entities, i dont want to be able to move/drag the circle while the user doesnt see the associated line will be stretched with it.
I know autocad creates a clone of the entity being moved /stretched and displays that while it's moving/stretching, so i tried to get the clone data from within the AcDbEntity::dragStatus function, but have been unable to do that thus far and it seems like the wrong approach.
Any idea? Thanks for any feedback
Best regard, Peter
Maybe this makes more sense:
2 lines (custom entities)
1 circle in between (custom entity)
When the circle is modified i want to change the lines so it follows the circle (stretches). i think i can do that with above example.
But i also need to show some visual detail whats going to happen, like i want to draw ghost lines / rubber bands from the start points of the lines to where the circle is being dragged..
Is such a thing possible?
Cheers, peter
I don't know why you say you cannot do that with persistent reactor. If you add persistent reactor for each line and implement method modified(...), you will be notified when circle is modified and you can do what you want. Now it's a problem for live preview, cause notification will be sent only after drag ended.
But if your entities are linked and cannot be moved independently, why don't you consider to have just one entity (draw lines and circle and have multiple grip points) ? Or maybe you can embed entities into one?
Regards,
Hi,
Sorry you're right about the persistant reactor, it would work. Thanks for pointing me in that reaction, i was thinking too complicated.
As for the visual thing, i can not put them in one entity..they are two different things, the circle and two lines is just an example. would have been the easiest solution, i agree
The effect im trying to get is the same as with a polyline.. you take one stretch point and when you drag you can see rubber bands coming from the other two connected points.
Any idea if it's possible to make something like that yourself, with two lines and (for example) a circle?
Can you draw rubber bands yourself or control them with objectarx?
Thanks for the help!
Regard, peter
Hi Peter,
The best way seems to me to use a custom entity. You could have a custom entity that draws like a polyline or what ever other shapes you may need. Sounds like you would need a potentially complex custom entity with sub-entities. Upon stretching or moving, you could control excatly what's the behavior of the sub-entity being modified and your custom logic will update the other sub-entities.
It may require a bit of work to develop such a custom entity but I don't think there is a better to handle this scenario.
Regards,
Philippe.
Well I was originally thinking about a single custom entity which can handle all the subentities by itself. Obviously I have no further knowledge about what you are dealing with. The custom entity can handle any number of sub-entities and the internal logic can be pretty complex.
If you think this is not appropriate, you can also create several entities connected together by constraints. The constraint API is also pretty involved to work with, I created the following helper API that will greatly simplify the deal:
All depends what you want to the behavior to be, for example when dealing with a single custom entity, things like selection and grop points can be more easily dealt with...
Hope that helps,
Philippe.