Prod.: Engine, ver.: 6017, ID: 60001001, Wish : Ability to get to the the figure that is in OSnap

Wish : Ability to get to the the figure that is in OSnap

Article60001001
TypeWish
ProductEngine
Version6017
Date Added11/13/2009
FixedYes [2/5/2010]
Submitted byMarkus Persson
Keywords

Subject

Ability to get to the the figure that is in OSnap

Summary

Is there an easy way to get the vdFigure/object that is currently in osnap?

Solution


In 6018 a new event OnFilterOsnap was added in vdDocument object.

 OnFilterOsnap is fired before an OsnapPoint added into the active selected Osnap collection.

The event method has the following form.

void OnFilterOsnap( object sender, vdEventArgs.FilterOsnapEventArgs args)

sender : represents the active Document object

args   : An object that contains the event data like Osnapoint and cancel property as boolean

          

           The cancel will info VectorDraw to cancel or not its default implementation after the fire of the event.Default value is false

           Set it to true in order the Osnapoint not to be added in osnaps

 

 C# Example (Description: Osnap points of an Insert subentities are not added into osnaps collection.Only the OsnapMode.INS are added for the vdInsert object.)

 

doc.OnFilterOsnap += new vdDocument.FilterOsnapEventHandler(doc_OnFilterOsnap);//Enable event Implementation inside doc_OnFilterOsnap method

void doc_OnFilterOsnap(object sender, VectorDraw.Professional.vdEventArgs.FilterOsnapEventArgs args)

{

 OsnapPoint pt = args.ObjectSnap;//get the Osnappoint that is going to be added in default osnappoints collection

 if (pt == null) return;//If it is not a valid OsnapPoint exit from method and do nothing

 vdFigure fig = pt.ObjectSnap as vdFigure;//Get the vdFigure where the OsnapPoint belongs

 if (fig == null) return;//If it is not a valid vdFigure exit from method and do nothing

//Do not add the OsnapPoints that belongs on a vdInsert subentities

 if (fig.Owner != null && fig.Owner.Owner != null && fig.Owner.Owner is vdBlock) args.Cancel = true;

}