.NET

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

OSnapOverrule crashes AutoCAD

245 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: 737
Registered: ‎03-21-2011
Message 2 of 3 (208 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 (190 Views)

Re: OSnapOverrule crashes AutoCAD

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

Thank you.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!