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

I need advise about canceling object modification

8 REPLIES 8
Reply
Message 1 of 9
FRFR1586
623 Views, 8 Replies

I need advise about canceling object modification

Hello,

 

I need an advise for the following problem

 

we use lwpolylines in our software.

 

the users can modify this polylines using autocad commands like stretch or using grip edit or using properties palett

in some case , I want to control the resulting polyline (for exemple , a lwpolyline must have a least 4 vertices, and have 2 parallels segments spaced by a given value)

I know how to fire the control using a command , but my purpose is to automatcly execute the control

I know how to recognize monitored polylines

 

How can I produce an automated solution ?

 

by overrule ? but I don't know what ovverule using

 

by the object modified event ?

 

by commandended eent : no , the event is not fired then gripedit occurs

 

I need your advise on the best way to realize this, and any sample sould be apreciated

 

thanks in advance

 

Luc

 

8 REPLIES 8
Message 2 of 9
FRFR1586
in reply to: FRFR1586

complement :

 

when the control will have a negative result , the modification will be canceled

 

 

regards

 

Luc

Message 3 of 9
techsoft3d
in reply to: FRFR1586
Message 4 of 9
FRFR1586
in reply to: techsoft3d

hi,

 

thanks for your the reply, but

 

this solution don't work with standard autocad command (strech for example)

is it a solution to intercept the modification of an object without depending of the modification solution choosed par the user ?

 

regards

luc

Message 5 of 9
techsoft3d
in reply to: FRFR1586

Luc -

 

Do you want to override/hook into the standard STRETCH command and take care of specific lwpolylines within the selection set?

 

I'd create a gripoverrule and override the GetStretchPoints() and MoveStretchPointsAt() functions where you do your specific editing for your lwpolylines. Pass all other entities in the selection set to base.MoveStretchPointsAt().

You need to be able to identify your lwpolylines by some property or add xdata to them upon creation.

 

You need cmdWillStart, cmdEnded and cmdCancelled to activate and deactivate your overrule for the STRETCH command.

 

I recall the STRETCH command behaves differently for certain entity types, depending on how they were selected (crossing, window, pickpoint, etc), maybe you'll end up having to keep track of that for the entities in the selection set. I wouldn't start with coding that, but keep it in mind while designing your functions if it applies to your lwpolylines.

 

Hope this gives you some ideas. I'd start writing the gripoverrule and reactors for monitoring the STRETCH command and see what happens in the StretchPoint functions mentioned.

 

Cheers,

Paavo

Message 6 of 9
norman.yuan
in reply to: FRFR1586

Just some thought how you could do this:

 

1. At class/module level, create a collection (such as ObjectIdcollection) object;

 

2. Handdle Document.CommandWillStart event: clearing the ObjectIdCollection to empty;

 

3. Handle Database.ObjectModified event, save the modifed entity's ObjectId into the ObjectIdCollection

 

4. Handle Document.CommandEnded event: between CommandWilLStart and CommandEnded, there could be 0 or more entities being modified, which now have been tracked in the OBjectIdCollection. So, in this event handler, you can have code to loop through the modified entities to identfy if there are your targeting polylines among the modified entities. If found, you can then see if they meet your geometrical requirements. If not, you can prompt user to undo the change (well, it would also undo other non-target entities modified by the command, what ever it is).

 

It sounds easier saying it than actually coding it, though.

Message 7 of 9
techsoft3d
in reply to: norman.yuan

Norman -

 

Maybe that'll work as well, it's hard to say exactly what Luc is after.

I assumed he wanted to control the grip editing and with my suggestion I reckon he'd be able to do that, also hook into the STRETCH command - all in one place, i.e. the grip overrule class he'd implement.

 

Btw, it's possible to monitor the grip editing too in commandWillStart, I think it's something like 'GRIP_STRETCH' (that'll be easy to check, though).

 

 

Cheers,

Paavo

Message 8 of 9
mcicognani
in reply to: techsoft3d

In my opinion both method would work, but using the grip overruling is definitely more elegant and the user would see in real-time what's happening.

I published some code on Kean's blog forcing a polyline with fillets to remain always with valid fillets while user handled its grips.

It's not an easy way to go, a lot of things must be counted of, but the result is quite good and even user friendly.

 

This is the link: http://through-the-interface.typepad.com/through_the_interface/2012/09/overriding-the-grips-of-an-au...

 

Also, if you search for 'overrule' inside that blog, you'll find a number of useful articles and code snippets.

Message 9 of 9
techsoft3d
in reply to: mcicognani

That's one truly comprehensive sample. Thanks for sharing!

 

Cheers,

Paavo

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost