private class OsOverrule : OsnapOverrule
{
public override void GetObjectSnapPoints(
Entity ent,
ObjectSnapModes mode,
IntPtr gsm,
Point3d pick,
Point3d last,
Matrix3d view,
Point3dCollection snap,
IntegerCollection geomIds)
{
if (IsApplicable(ent))
return;
base.GetObjectSnapPoints(ent, mode, gsm, pick, last, view, snap, geomIds);// ТУТ ПОЛУЧАЕМ ПАРАМЕТРЫ ТОЧКИ ПРИВЯЗКИ, MODE - ПАРАМЕТР ОБЪЕКТНОЙ ПРИВЯКИ
}
public override void GetObjectSnapPoints(
Entity ent,
ObjectSnapModes mode,
IntPtr gsm,
Point3d pick,
Point3d last,
Matrix3d view,
Point3dCollection snaps,
IntegerCollection geomIds,
Matrix3d insertion)
{
if (IsApplicable(ent))
return;
base.GetObjectSnapPoints(ent, mode, gsm, pick, last, view, snaps, geomIds, insertion);
}
public override bool IsContentSnappable(Entity entity)
{
return !IsApplicable(entity);
}
/// <inheritdoc />
public override bool IsApplicable(RXObject overruledSubject)
{
//ТУТ ПРОВЕРЯЕМ УДОВЛЕТВОРЯЕТ ЛИ ПРИМИТИВ УСЛОВИЯМ, ЧТОБЫ К НЕМУ ПРИВЯЗАТЬСЯ
return base.IsApplicable(overruledSubject) && overruledSubject is Entity ent &&
!Layers.Any(x => x.Equals(ent.Layer, StringComparison.OrdinalIgnoreCase)); //Знак НЕ, что выбиралось то что только в коллеции("!")
}
}
public class IntOverrule : GeometryOverrule
{
public override void IntersectWith(
Entity ent1,
Entity ent2,
Intersect intType,
Plane proj,
Point3dCollection points,
IntPtr thisGsm,
IntPtr otherGsm)
{
}
public override void IntersectWith(
Entity ent1,
Entity ent2,
Intersect intType,
Point3dCollection points,
IntPtr thisGsm,
IntPtr otherGsm)
{
}
}
private static void ToggleOverruling(bool on)
{
if (on)
{
if (_osOverrule == null)
{
_osOverrule = new OsOverrule();
Overrule.AddOverrule(RXObject.GetClass(typeof(Entity)), _osOverrule, false);
}
if (_geoOverrule == null)
{
_geoOverrule = new IntOverrule();
ObjectOverrule.AddOverrule(RXObject.GetClass(typeof(Entity)), _geoOverrule, false);
}
Overrule.Overruling = true;
}
else
{
if (_osOverrule == null)
return;
Overrule.RemoveOverrule(RXObject.GetClass(typeof(Entity)), _osOverrule);
_osOverrule.Dispose();
_osOverrule = null;
if (_geoOverrule == null)
return;
Overrule.RemoveOverrule(RXObject.GetClass(typeof(Entity)), _geoOverrule);
_geoOverrule.Dispose();
_geoOverrule = null;
}
}
[CommandMethod("ИгнорSnapSelection_On")]
public static void DisableSnapping()
{
Layers = FiltrPerem.namelayerCreate.ToArray();
ToggleOverruling(true);
}
[CommandMethod("ИгнорSnapSelection_Off")]
public static void EnableSnapping()
{
ToggleOverruling(false);
}
}
}