ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

get new entity coordinates while dragging

8 REPLIES 8
Reply
Message 1 of 9
peterv85
622 Views, 8 Replies

get new entity coordinates while dragging

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

8 REPLIES 8
Message 2 of 9
maisoui
in reply to: peterv85

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,

--
Jonathan
Message 3 of 9
peterv85
in reply to: maisoui

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

 

Message 4 of 9
peterv85
in reply to: peterv85

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

Message 5 of 9
maisoui
in reply to: peterv85

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,

--
Jonathan
Message 6 of 9
peterv85
in reply to: maisoui

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

Message 7 of 9
philippe.leefsma
in reply to: peterv85

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.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 8 of 9
peterv85
in reply to: philippe.leefsma

Thanks philippe for the response.
So when theres a chain of entities: circle - line - circle - line - circle - line etc.

Should every line have 2 sub entities (circles), and would there be a sort of chain reaction? Or do you need 1 huge entity that keeps track of all subentities (that would be pretty complex).

The class i would use for this is:AcDbAssocGeomDependency ? (cant find much documentation on subentities).

Thanks again for the help.




Message 9 of 9
philippe.leefsma
in reply to: peterv85

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:

 

http://adndevblog.typepad.com/autocad/2013/01/a-simplified-net-api-for-accessing-autocad-parameters-...

 

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.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost