Can you test the owner?
System.InvalidCastException: Unable to cast object of type
'Autodesk.AutoCAD.GraphicsInterface.ImpSubEntityTraits' to type
'Autodesk.AutoCAD.GraphicsInterface.DrawableTraits'.
at AcMgDrawableOverrule.setAttributes(AcMgDrawableOverrule* , AcGiDrawable*
pThis, AcGiDrawableTraits* traits)
at AcGiDrawableOverrule.worldDraw(AcGiDrawableOverrule* , AcGiDrawable* ,
AcGiWorldDraw* )
at Autodesk.AutoCAD.GraphicsInterface.DrawableOverrule.WorldDraw(Drawable
drawable, WorldDraw wd)
at DrawableOverruleBug.WorldDrawTest.WorldDraw(Drawable drawable, WorldDraw wd)
// Expected output:
BeginContainer: AcDbTable (0x1F7) Name: *T4 Level: 0
BeginContainer: AcDbBlockReference (0x226) Name: A Level: 1
Drawing: AcDbText (0x1BE) Level = 2
EndContainer: AcDbBlockReference (0x226) Name: A Level: 1
EndContainer: AcDbTable (0x1F7) Name: *T4 Level: 0
Command: QSAVE
// Actual result during QSAVE:
BeginContainer: AcDbTable (0x1F7) Name: *T4 Level: 0
BeginContainer: AcDbBlockReference (0x226) Name: A Level: 1
EndContainer: AcDbBlockReference (0x226) Name: A Level: 1
AcDbBlockReference (0x226) Name: A -> : System.InvalidCastException:
Unable to cast object of type 'Autodesk.AutoCAD.GraphicsInterface.ImpSubEntityTraits' to type
'Autodesk.AutoCAD.GraphicsInterface.DrawableTraits'.
at AcMgDrawableOverrule.setAttributes(AcMgDrawableOverrule* , AcGiDrawable*
pThis, AcGiDrawableTraits* traits)
at AcGiDrawableOverrule.worldDraw(AcGiDrawableOverrule* , AcGiDrawable* ,
AcGiWorldDraw* )
at Autodesk.AutoCAD.GraphicsInterface.DrawableOverrule.WorldDraw(Drawable
drawable, WorldDraw wd)
at CompoundDrawableOverrules.DrawableOverrule`1.BaseWorldDraw(Drawable
drawable, WorldDraw wd) in CompoundDrawable.cs:line 87
I was going to reply just joking around that Autodesk's solution was just not to override any methods in a class that derives from an overrule, but you can't even do that!!
Adding the overrule was all it took to go KABOOM!Code - C#: [Select]
Overrule.Overruling = true;
In ObjectARX you would check AcGiCommonDraw::regenType() to handle the proxy graphics generation differently. Perhaps the same can be done here?
Yes sir,
and did the following steps and it crashed each time.
-I tried the exact code you posted.
-I commented out WorldDraw Method
-Changed bAtLast to false
-Removed constructor and called AddOverrule in command.
This is how code ended upCode - C#: [Select]
class WorldDrawTest : DrawableOverrule { //public WorldDrawTest() //{ // Overrule.AddOverrule( RXClass.GetClass( typeof( DBText ) ), this, true ); // Overrule.Overruling = true; //} //public override bool WorldDraw( Drawable drawable, WorldDraw wd ) //{ // try // { // return base.WorldDraw( drawable, wd ); // } // catch( System.Exception ex ) // { // Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage( ex.ToString() ); // return true; // } //} } public static class Commands { static WorldDrawTest worldDrawTest = null; [CommandMethod("WORLDDRAWTEST")] public static void WorldDrawTest() { if (worldDrawTest == null) Overrule.Overruling = true; Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage( "\nDrawableOverrule enabled, issue the QSAVE command."); } }
*****Edit*************
The first test I followed your steps the others I saved a drawing with a table with block inserted and followed these steps for each drawing
-QSave
-NetLoad
-WorldDrawTest
-QSave
-KABOOM!
Your modified code looks correct. You are basically removing the added overrule from for the line entity in your modified code. I will be consulting my engineering team on your issue (Overrule.Overruling = Not Overrule.Overruling failing in 2012) and I will get back to you as soon as I get some relevant information.Solution
As mentioned in earlier mail, you need to remove overrule using API “RemoveOverrule” instead of toggling variable “Overruling”.
See my reply to Owen regarding a possible workaround.I guess in your example you were overruling Entity or Drawable?
See my reply to Owen regarding a possible workaround.I guess in your example you were overruling Entity or Drawable?
I have not spent much time with it but any call to base.WorldDraw() threw an error. The Invalid cast ImpSubEntityTraits.
I thought maybe anything that derived from a BlockReference containing the block might also throw an error but creating a MInsertBlock with block did not.
This was the only thing I got working and is your test code with a added overrule for tables, that is added in BeginSave event and removed in SaveComplete Event.
Setting Overruling to false did not change a thing but it could be something I missing.
This was what I had left and NOT meant as a solution.Code - C#: [Select]
class WorldDrawTest : DrawableOverrule { public WorldDrawTest() { Overrule.Overruling = true; } public override bool WorldDraw(Drawable drawable, WorldDraw wd) { try { return base.WorldDraw(drawable, wd); } catch (System.Exception ex) { Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(ex.ToString()); return true; } } } class TableBug : DrawableOverrule { public TableBug() { Overrule.Overruling = true; } public override bool WorldDraw(Drawable drawable, WorldDraw wd) { return wd.RegenType == RegenType.SaveWorldDrawForProxy ? true : base.WorldDraw(drawable, wd); //return base.WorldDraw(drawable, wd);/////Throws error everytime } } public static class Commands { static WorldDrawTest worldDrawTest = null; static TableBug tableBug = null; [CommandMethod("WORLDDRAWTEST")] public static void WorldDrawTest() { if (worldDrawTest == null) Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage( "\nDrawableOverrule enabled, issue the QSAVE command."); HostApplicationServices.WorkingDatabase.BeginSave += new DatabaseIOEventHandler(WorkingDatabase_BeginSave); HostApplicationServices.WorkingDatabase.SaveComplete += new DatabaseIOEventHandler(WorkingDatabase_SaveComplete); } static void WorkingDatabase_SaveComplete(object sender, DatabaseIOEventArgs e) { } static void WorkingDatabase_BeginSave(object sender, DatabaseIOEventArgs e) { if (tableBug == null) { } else { } } }
I linked this to another thread at Autodesk Forums http://forums.autodesk.com/t5/NET/Overrule-a-specific-subentity-in-block-and-not-showing-the-Base/m-p/3586752#M30649 (http://forums.autodesk.com/t5/NET/Overrule-a-specific-subentity-in-block-and-not-showing-the-Base/m-p/3586752#M30649) and looks like you died.
Sorry to hear your dead Tony, hopefully you will get over it and start feeling better.