.NET

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

OSnapOverrule crashes AutoCAD

247 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: 749
Registered: ‎03-21-2011
Message 2 of 3 (210 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 (192 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
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.