Author Topic: WorldDraw override for GripData/GripOverrule keeps crashing?  (Read 810 times)

0 Members and 1 Guest are viewing this topic.

shupsta2010

  • Mosquito
  • Posts: 17
WorldDraw override for GripData/GripOverrule keeps crashing?
« on: October 19, 2022, 10:17:59 AM »
I've created a custom derived class for GripOverrule as well as GripData. I have the custom grip points rendering correctly during the Overrule's GetGripPoints() command.
What I am having trouble with is overriding GripData's WorldDraw() method?

Code: [Select]
public override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.WorldDraw worldDraw, ObjectId entityId, DrawType type, Point3d? imageGripPoint, double dGripSize)
        {
            return base.WorldDraw(worldDraw, entityId, type, imageGripPoint, dGripSize);
        }

Just trying to use this override, if I debug I can see that the code gets to inside the method, and it seems to make it through the base.Method() call no problem. But when I continue to step through after the base.Method() call AutoCAD freezes and then eventually crashes, with no StackTrace or any warning?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 7486
  • AKA Daniel
Re: WorldDraw override for GripData/GripOverrule keeps crashing?
« Reply #1 on: October 19, 2022, 11:58:25 PM »
Are you having issue or just trying to step through? What happens if you put a try catch inside the function?
I donít think you will be able to step though too far into the base class, it probably just a wrapper for native code.
It could be threaded or something internally
Is your overrule for all entities or one type?
Retired

shupsta2010

  • Mosquito
  • Posts: 17
Re: WorldDraw override for GripData/GripOverrule keeps crashing?
« Reply #2 on: October 20, 2022, 10:22:18 AM »
Sorry I should have said it clearer. The crash does not only occur when I'm debugging/stepping through the method. It happens even if I am not.
I did try your suggestion and added a try catch

Code: [Select]
public override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.WorldDraw worldDraw, ObjectId entityId, DrawType type, Point3d? imageGripPoint, double dGripSize)
        {
            try
            {
                return base.WorldDraw(worldDraw, entityId, type, imageGripPoint, dGripSize);
            }
            catch(Autodesk.AutoCAD.Runtime.Exception e)
            {
                return false;
            }
        }

I did put break points at both returns. And once again the base method was called, and returned false. Then as the method is ending is when my IDE and AutoCAD start to freeze, and then stop working.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 7486
  • AKA Daniel
Re: WorldDraw override for GripData/GripOverrule keeps crashing?
« Reply #3 on: October 20, 2022, 05:10:46 PM »
I don't see that there's anything you can do if the crash is internal, except filter out whatís coming through the via the incoming parameters.
Are you overriding IsApplicable, SetCustomFilter? Maybe you can catch something bad trying to get though there too.
Retired

shupsta2010

  • Mosquito
  • Posts: 17
Re: WorldDraw override for GripData/GripOverrule keeps crashing?
« Reply #4 on: October 20, 2022, 05:16:53 PM »
I am overriding IsApplicable() for the GripOverrule, and I did call base.SetCustomFilter() in the GripOverrules constructor.
But WorldDraw() is part of the GripData not the GripOverrule. I'm just so confused because I've read two different sources and they both can override no problem?

https://gist.github.com/beweir/83882a0bb28b80e97f2178d731671491

https://www.keanw.com/2012/09/overriding-the-grips-of-an-autocad-polyline-to-maintain-fillet-segments-using-net.html

Jeff H

  • Needs a day job
  • Posts: 6117
Re: WorldDraw override for GripData/GripOverrule keeps crashing?
« Reply #5 on: October 20, 2022, 08:56:53 PM »
I'm just so confused because I've read two different sources and they both can override no problem?

https://gist.github.com/beweir/83882a0bb28b80e97f2178d731671491

https://www.keanw.com/2012/09/overriding-the-grips-of-an-autocad-polyline-to-maintain-fillet-segments-using-net.html
The one from through the interface only overrides viewportdraw, which  I also do for some custom stuff without errors have you tried just viewportdraw?

shupsta2010

  • Mosquito
  • Posts: 17
Re: WorldDraw override for GripData/GripOverrule keeps crashing?
« Reply #6 on: October 21, 2022, 09:35:37 AM »

The one from through the interface only overrides viewportdraw, which  I also do for some custom stuff without errors have you tried just viewportdraw?

I have not tried this yet, as I was doing testing in model space and hadn't done anything with viewports yet. But I will give it a try.

shupsta2010

  • Mosquito
  • Posts: 17
Re: WorldDraw override for GripData/GripOverrule keeps crashing?
« Reply #7 on: October 21, 2022, 10:02:00 AM »
Very strange behavior. When I added an override for ViewPortDraw() by itself, no WorldDraw() override, there was no crash. No crashes when looking at the block in model space, or through a Viewport. But the grips dont render now.

But when I also added back in the WorldDraw() override, with the ViewportDraw() override, there was no more crashing! No crashing in model space or through a viewport! But like before the grips are no longer rendering.

And if I remove the override for both of these methods, the grips render as normal??

shupsta2010

  • Mosquito
  • Posts: 17
Re: WorldDraw override for GripData/GripOverrule keeps crashing?
« Reply #8 on: October 21, 2022, 05:36:36 PM »
So it turns out WorldDraw() was not the method I was looking for  :tickedoff:

ViewportDraw() alone did the trick. I thought if I wasn't looking through a viewport in paper space that it wouldn't apply, but it seems to work when I'm just in model space.

Jeff H

  • Needs a day job
  • Posts: 6117
Re: WorldDraw override for GripData/GripOverrule keeps crashing?
« Reply #9 on: October 25, 2022, 05:30:24 PM »