.NET

Reply
Active Contributor
cincir
Posts: 32
Registered: ‎08-12-2011
Message 1 of 3 (234 Views)

OSnapOverrule crashes AutoCAD

234 Views, 2 Replies
11-15-2012 03:01 PM

hello everyone

i have a problem about OsnapOverrule. when i register a derived class of OsnapOverrule doing nothing but only calling the base classes GetObjectSnapPoints function , Autocad crashes after object snap tracking from the end point along the direction of polyline occurs. if i unchecked "extension" from object snap it just works fine. it only crashes while object snap tracking. Code is so plain as i said but i am posting it just in case

 

public class OsnapOverruleDemo : OsnapOverrule
    {
        private static OsnapOverruleDemo _singleton;
        public static OsnapOverruleDemo Instance
        {
            get
            {
                if (_singleton == null)
                {
                    _singleton = new OsnapOverruleDemo();
                }
                return _singleton;
            }
        }
        protected OsnapOverruleDemo()
            : base()
        {
        }

        public void Register()
        {
            if (!Overrule.HasOverrule(Instance,RXClass.GetClass(typeof(Autodesk.AutoCAD.DatabaseServices.Polyline))))
            {
                Overrule.AddOverrule(RXClass.GetClass(typeof(Autodesk.AutoCAD.DatabaseServices.Polyline)), Instance, true);
            }
        }

        public void UnRegister()
        {
            if (Overrule.HasOverrule(Instance, RXClass.GetClass(typeof(Autodesk.AutoCAD.DatabaseServices.Polyline))))
            {
                Overrule.RemoveOverrule(RXClass.GetClass(typeof(Autodesk.AutoCAD.DatabaseServices.Polyline)), Instance);
            }
        }

        public override void GetObjectSnapPoints(Entity entity, ObjectSnapModes snapMode, IntPtr gsSelectionMark, Point3d pickPoint, Point3d lastPoint, Matrix3d viewTransform, Point3dCollection snapPoints, IntegerCollection geometryIds, Matrix3d insertionMat)
        {
            base.GetObjectSnapPoints(entity, snapMode, gsSelectionMark, pickPoint, lastPoint, viewTransform, snapPoints, geometryIds, insertionMat);
        }
    }

    public class Demo
    {
        [CommandMethod("OverruleOn")]
        public static void OverruleOn()
        {
            OsnapOverruleDemo.Instance.Register();
        }
    }

should i also implement other overrule functions like GeometryOverrules IntersectWith function or something like this?

thanks.

 

 

ADN Support Specialist
Balaji_Ram
Posts: 701
Registered: ‎03-21-2011
Message 2 of 3 (197 Views)

Re: OSnapOverrule crashes AutoCAD

11-21-2012 08:08 AM in reply to: cincir

Hello,

 

I could reproduce the crash in AutoCAD 2011 / 2012 and 2013.

The issue seems to be specific to polyline and the extension osnap.

 

I have logged this behavior in our internal database for our engineering team to analyze.

 

Sorry, there is no workaround that I could find.

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Active Contributor
cincir
Posts: 32
Registered: ‎08-12-2011
Message 3 of 3 (179 Views)

Re: OSnapOverrule crashes AutoCAD

11-22-2012 08:11 AM in reply to: cincir

Thank you.

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.