Author Topic: AutoLoader for MgdDbg  (Read 23135 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
AutoLoader for MgdDbg
« on: April 25, 2012, 08:32:49 AM »
For Stephen Preston or Fenton Webb
.. posted here because the DevBlog won't accept XML.

but EVERYONE should feel free to post relevant comments :)

Re : ADN DWG Debugger and DataBase Viewer - MGDDBG
http://adndevblog.typepad.com/autocad/2012/04/dwg-debugger-mgddbg-app-for-autocad-20122013.html

I wanted to change the functionality to Demand load rather than than StartUp load
ie : use LoadOnCommandInvocation
The attached PackageContents.xml is my revised file.

Here's the Quandry : The LocalNames in the Source are SnoopDb and SnoopEd.
They wouldn't work so I used the Global Names MgdDbgSnoopDb and MgdDbgSnoopEd as the LocalName.

The Assembly demand loads and runs sucessfully using the GlobalName at the CommandLine.

Lines 35 to 51 have been added and I've left the 2013 listing so the Assembly loads at startup.
Code - XML: [Select]
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <ApplicationPackage
  3.  AppNameSpace="adn.exchange.autodesk.com"
  4.  AppVersion="1.0.0"
  5.  Author="Fenton Webb"
  6.  AutodeskProduct="AutoCAD"
  7.  Description="Debugging tools for AutoCAD - MgdDBG"
  8.  HelpFile="./Contents/Resources/helpfile.html"
  9.  Icon="./Contents/Resources/resource/Inspector.jpg"
  10.  Name="DWG MgdDBG"
  11.  OnlineDocumentation=" "
  12.  ProductCode="{DB35F952-289A-4453-A46D-B424A6FCFDFB}"
  13.  ProductType="Application"
  14.  SchemaVersion="1.0"
  15.  SupportedLocales="Enu"
  16.  UpgradeCode="{E5B78003-2D7B-490F-B947-65D804392151}">
  17.   <CompanyDetails
  18.    Email=" adn.autodesk.com"
  19.    Name="Autodesk"
  20.    Phone=" "
  21.    Url=" www.autodesk.com"/>
  22.   <RuntimeRequirements
  23.    OS="Win32|Win64"
  24.    Platform="AutoCAD|AutoCAD*"
  25.    SeriesMax="R19.0"
  26.    SeriesMin="R18.2"/>
  27.   <Components
  28.    Description="AutoCAD 2012">
  29.     <RuntimeRequirements
  30.      OS="Win32|Win64"
  31.      Platform="AutoCAD*|AutoCAD"
  32.      SeriesMax="R18.2"
  33.      SeriesMin="R18.2"/>
  34.  
  35.     <ComponentEntry
  36.      AppDescription="Debugging tools for AutoCAD - MgdDBG"
  37.      AppName="DWGMgdDBG"
  38.      LoadOnCommandInvocation="True"
  39.      ModuleName="./Contents/Resources/DWGMgdDbgSource/bin/Debug2012/MgdDbg.dll"
  40.      Version="1.0.0">
  41.  
  42.       <Commands
  43.        GroupName="MgdDbg">
  44.         <Command
  45.          Global="MgdDbgSnoopDb"
  46.          Local="MgdDbgSnoopDb"/>
  47.         <Command
  48.          Global="MgdDbgSnoopEd"
  49.          Local="MgdDbgSnoopEd"/>
  50.       </Commands>
  51.     </ComponentEntry>
  52.  
  53.     <ComponentEntry
  54.      Description="AutoCAD 2013">
  55.       <RuntimeRequirements
  56.        OS="Win32|Win64"
  57.        Platform="AutoCAD*|AutoCAD"
  58.        SeriesMax="R19.0"
  59.        SeriesMin="R19.0"/>
  60.       <ComponentEntry
  61.        AppDescription="Debugging tools for AutoCAD - MgdDBG"
  62.        AppName="DWGMgdDBG"
  63.        ModuleName="./Contents/Resources/DWGMgdDbgSource/bin/Debug2013/MgdDbg.dll"
  64.        Version="1.0.0"/>
  65.     </ComponentEntry>
  66.   </Components>
  67. </ApplicationPackage>
  68.  
  69.  

Any ideas why the LocalName is not being recognised ??


Regards
Kerry


« Last Edit: April 25, 2012, 08:40:03 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Jeff H

  • Needs a day job
  • Posts: 6144
Re: AutoLoader for MgdDbg
« Reply #1 on: April 25, 2012, 10:56:48 AM »
I can't remeber all them but in
MgdDbg.Snoop.CollectorExts
 
 
 
                 else if ((typeCode >= 90) && (typeCode <= 99)) {
                    dxfCodeStr = string.Format("{0:d}    (long)", typeCode);
Line 482         data.Add(new Snoop.Data.Int(dxfCodeStr, (int)(long)tmpVal.Value));
 
 
The (long) cast needs to be removed.
 
There was something with mleaders where values were null and throwing a exception and will try to find it.
I think a couple more but a very useful tool.
 

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: AutoLoader for MgdDbg
« Reply #2 on: April 25, 2012, 11:03:14 AM »
I can't remeber all them but in
MgdDbg.Snoop.CollectorExts
 
 
 
                 else if ((typeCode >= 90) && (typeCode <= 99)) {
                    dxfCodeStr = string.Format("{0:d}    (long)", typeCode);
Line 482         data.Add(new Snoop.Data.Int(dxfCodeStr, (int)(long)tmpVal.Value));
 
 
The (long) cast needs to be removed.
 
There was something with mleaders where values were null and throwing a exception and will try to find it.
I think a couple more but a very useful tool.

I second Jeff, I just found this today while playing with MLeaders.  I get and eInvlaidContext exception anytime I try to snoop a MLeader object.
Revit 2019, AMEP 2019 64bit Win 10

Jeff H

  • Needs a day job
  • Posts: 6144
Re: AutoLoader for MgdDbg
« Reply #3 on: April 25, 2012, 11:04:27 AM »
I will look back in 2012 version and see what I did to get it working.
**************Edit*********************
In MgdDbg.Snoop.CollectorExts.Entity starting at line 892
Code - C#: [Select]
  1.  
  2.              data.Add(new Snoop.Data.Double("Arrow size", mleader.ArrowSize));
  3.             data.Add(new Snoop.Data.ObjectId("Arrow symbol Id", mleader.ArrowSymbolId));
  4.             data.Add(new Snoop.Data.Object("Block color", mleader.BlockColor));
  5.             data.Add(new Snoop.Data.String("Block connection type", mleader.BlockConnectionType.ToString()));
  6.             data.Add(new Snoop.Data.ObjectId("Block content Id", mleader.BlockContentId));
  7. 897       data.Add(new Snoop.Data.Point3d("Block position", mleader.BlockPosition));
  8.             data.Add(new Snoop.Data.Double("Block rotation", mleader.BlockRotation));
  9.             data.Add(new Snoop.Data.Scale3d("Block scale", mleader.BlockScale));
  10.             data.Add(new Snoop.Data.String("Content type", mleader.ContentType.ToString()));
  11.             data.Add(new Snoop.Data.Double("Dogleg length", mleader.DoglegLength));
  12.             data.Add(new Snoop.Data.Bool("Enable annotation scale", mleader.EnableAnnotationScale));
  13.             data.Add(new Snoop.Data.Bool("Enable dogleg", mleader.EnableDogleg));
  14.             data.Add(new Snoop.Data.Bool("Enable frame text", mleader.EnableFrameText));
  15.             data.Add(new Snoop.Data.Bool("Enable landing", mleader.EnableLanding));
  16.             data.Add(new Snoop.Data.Double("Landing gap", mleader.LandingGap));
  17.             data.Add(new Snoop.Data.Int("Leader count", mleader.LeaderCount));
  18.             data.Add(new Snoop.Data.Object("Leader line color", mleader.LeaderLineColor));
  19.             data.Add(new Snoop.Data.Int("Leader line count", mleader.LeaderLineCount));
  20.             data.Add(new Snoop.Data.String("Leader line type", mleader.LeaderLineType.ToString()));
  21.             data.Add(new Snoop.Data.ObjectId("Leader line type Id", mleader.LeaderLineTypeId));
  22.             data.Add(new Snoop.Data.String("Leader line weight", mleader.LeaderLineWeight.ToString()));
  23.             data.Add(new Snoop.Data.ObjectId("MLeader style", mleader.MLeaderStyle));
  24.             data.Add(new Snoop.Data.Object("MText", mleader.MText));
  25.             data.Add(new Snoop.Data.Vector3d("Normal", mleader.Normal));
  26.             data.Add(new Snoop.Data.String("Text alignment type", mleader.TextAlignmentType.ToString()));
  27.             data.Add(new Snoop.Data.String("Text angle type", mleader.TextAngleType.ToString()));
  28.             data.Add(new Snoop.Data.String("Text attachment type", mleader.TextAttachmentType.ToString()));
  29.             data.Add(new Snoop.Data.Object("Text color", mleader.TextColor));
  30.             data.Add(new Snoop.Data.Double("Text height", mleader.TextHeight));
  31.             data.Add(new Snoop.Data.Point3d("Text location", mleader.TextLocation));
  32.             data.Add(new Snoop.Data.ObjectId("Text style Id", mleader.TextStyleId));
  33.             data.Add(new Snoop.Data.Point3d("Tolerance location", mleader.ToleranceLocation));
  34.  

Need to add logic to check if it contains a Block or Mtext so it errors out at 897 if it contains Mtext since BlockPosition is not valid and if it contains a Block then it errors out on some the Mtext porperties
« Last Edit: April 25, 2012, 11:27:34 AM by Jeff H »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: AutoLoader for MgdDbg
« Reply #4 on: April 26, 2012, 06:27:55 AM »
Colour me embarrased  :oops:

I should have had a closer look at the source code.

Here's a typical example of the CommandMethodAttribute constructor used.

 
Code - C#: [Select]
  1.        
  2.         //[CommandMethod("MgdDbg", "MgdDbgSnoopDb", "SnoopDb", CommandFlags.Modal)]
  3.         [CommandMethod("MgdDbgSnoopDb", CommandFlags.Modal)]
  4.        
  5.         public void
  6.         SnoopDatabase()
  7.         {
  8.             Database db = AcadApp.DocumentManager.MdiActiveDocument.Database;
  9.  
  10.             using (TransactionHelper trHlp = new TransactionHelper(db)) {
  11.                 trHlp.Start();
  12.                
  13.                 Snoop.Forms.Database dbox = new Snoop.Forms.Database(db, trHlp);
  14.                 dbox.Text = db.Filename;
  15.                 AcadApp.ShowModalDialog(dbox);
  16.                
  17.                 trHlp.Commit();
  18.             }
  19.         }

You'll notice that the full constructor has been commented out and a light constructor used.

ie in place of
Code - C#: [Select]
  1. public CommandMethodAttribute(
  2.     string groupName,
  3.     string globalName,
  4.     string localizedNameId,
  5.     CommandFlags flags
  6. );

this was used
Code - C#: [Select]
  1. public CommandMethodAttribute(
  2.     string globalName,
  3.     CommandFlags flags
  4. );

Silly me ...
In the XML I've declared the Global name and the Local name which aren't defined in the code, so they can't be used.
... only the Global Name is used .
I've left the redundant expressions in the XML for the time being.

... at least that's the way I read the situation.


This is the  PackageContents.xml  I'm using
Code - XML: [Select]
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--reworked by kdub@theSwamp 2012.04.26-->
  3. <!--http://www.theswamp.org/index.php?topic=41576.0-->
  4. <!--fileName :  %AppData%\Autodesk\ApplicationPlugins\Autodesk DWG MgdDBG.bundle\PackageContents.xml-->
  5. <ApplicationPackage
  6.  AppNameSpace="adn.exchange.autodesk.com"
  7.  AppVersion="1.0.0"
  8.  Author="Fenton Webb"
  9.  AutodeskProduct="AutoCAD"
  10.  Description="Debugging tools for AutoCAD - MgdDBG"
  11.  HelpFile="./Contents/Resources/helpfile.html"
  12.  Icon="./Contents/Resources/resource/Inspector.jpg"
  13.  Name="DWG MgdDBG"
  14.  OnlineDocumentation=" "
  15.  ProductCode="{DB35F952-289A-4453-A46D-B424A6FCFDFB}"
  16.  ProductType="Application"
  17.  SchemaVersion="1.0"
  18.  SupportedLocales="Enu"
  19.  UpgradeCode="{E5B78003-2D7B-490F-B947-65D804392151}">
  20.   <CompanyDetails
  21.    Email=" adn.autodesk.com"
  22.    Name="Autodesk"
  23.    Phone=" "
  24.    Url=" www.autodesk.com"/>
  25.   <RuntimeRequirements
  26.    OS="Win32|Win64"
  27.    Platform="AutoCAD|AutoCAD*"
  28.    SeriesMax="R19.0"
  29.    SeriesMin="R18.2"/>
  30.   <Components
  31.    Description="AutoCAD 2012">
  32.     <RuntimeRequirements
  33.      OS="Win32|Win64"
  34.      Platform="AutoCAD*|AutoCAD"
  35.      SeriesMax="R18.2"
  36.      SeriesMin="R18.2"/>
  37.  
  38.     <ComponentEntry
  39.      AppDescription="Debugging tools for AutoCAD - MgdDBG"
  40.      AppName="DWGMgdDBG"
  41.      LoadOnCommandInvocation="True"
  42.      ModuleName="./Contents/Resources/DWGMgdDbgSource/bin/Debug2012/MgdDbg.dll"
  43.      Version="1.0.0">
  44.  
  45.       <Commands
  46.        GroupName="MgdDbg">
  47.         <Command
  48.          Global="MgdDbgSnoopDb"
  49.          Local="MgdDbgSnoopDb"/>
  50.         <Command
  51.          Global="MgdDbgSnoopEd"
  52.          Local="MgdDbgSnoopEd"/>
  53.       </Commands>
  54.     </ComponentEntry>
  55.  
  56.     <ComponentEntry
  57.      Description="AutoCAD 2013">
  58.       <RuntimeRequirements
  59.        OS="Win32|Win64"
  60.        Platform="AutoCAD*|AutoCAD"
  61.        SeriesMax="R19.0"
  62.        SeriesMin="R19.0"/>
  63.       <ComponentEntry
  64.        AppDescription="Debugging tools for AutoCAD - MgdDBG"
  65.        AppName="DWGMgdDBG"
  66.        ModuleName="./Contents/Resources/DWGMgdDbgSource/bin/Debug2013/MgdDbg.dll"
  67.        Version="1.0.0"/>
  68.     </ComponentEntry>
  69.  
  70.   </Components>
  71. </ApplicationPackage>
  72.  

Regards
Kerry
« Last Edit: April 26, 2012, 06:31:57 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Jeff H

  • Needs a day job
  • Posts: 6144
Re: AutoLoader for MgdDbg
« Reply #5 on: May 03, 2012, 01:18:36 AM »
You probably have figured it out but here is the quick fix for mleaders with mgddbg
In the Snoop-> CollectorExts folder inside Entity class
Just added some if statements to check ContentType
starting at line 887
Code - C#: [Select]
  1.  
  2.          private void
  3.         Stream(ArrayList data, MLeader mleader)
  4.         {
  5.             data.Add(new Snoop.Data.ClassSeparator(typeof(MLeader)));
  6.             data.Add(new Snoop.Data.Double("Arrow size", mleader.ArrowSize));
  7.             data.Add(new Snoop.Data.ObjectId("Arrow symbol Id", mleader.ArrowSymbolId));
  8.             data.Add(new Snoop.Data.Object("Block color", mleader.BlockColor));
  9.             data.Add(new Snoop.Data.String("Block connection type", mleader.BlockConnectionType.ToString()));
  10.             data.Add(new Snoop.Data.ObjectId("Block content Id", mleader.BlockContentId));
  11.             if (mleader.ContentType == ContentType.BlockContent)
  12.             {
  13.                 data.Add(new Snoop.Data.Point3d("Block position", mleader.BlockPosition));
  14.                 data.Add(new Snoop.Data.Double("Block rotation", mleader.BlockRotation));
  15.             }        
  16.             data.Add(new Snoop.Data.Scale3d("Block scale", mleader.BlockScale));
  17.             data.Add(new Snoop.Data.String("Content type", mleader.ContentType.ToString()));
  18.             data.Add(new Snoop.Data.Double("Dogleg length", mleader.DoglegLength));
  19.             data.Add(new Snoop.Data.Bool("Enable annotation scale", mleader.EnableAnnotationScale));
  20.             data.Add(new Snoop.Data.Bool("Enable dogleg", mleader.EnableDogleg));
  21.             data.Add(new Snoop.Data.Bool("Enable frame text", mleader.EnableFrameText));
  22.             data.Add(new Snoop.Data.Bool("Enable landing", mleader.EnableLanding));
  23.             data.Add(new Snoop.Data.Double("Landing gap", mleader.LandingGap));
  24.             data.Add(new Snoop.Data.Int("Leader count", mleader.LeaderCount));
  25.             data.Add(new Snoop.Data.Object("Leader line color", mleader.LeaderLineColor));
  26.             data.Add(new Snoop.Data.Int("Leader line count", mleader.LeaderLineCount));
  27.             data.Add(new Snoop.Data.String("Leader line type", mleader.LeaderLineType.ToString()));
  28.             data.Add(new Snoop.Data.ObjectId("Leader line type Id", mleader.LeaderLineTypeId));
  29.             data.Add(new Snoop.Data.String("Leader line weight", mleader.LeaderLineWeight.ToString()));
  30.             data.Add(new Snoop.Data.ObjectId("MLeader style", mleader.MLeaderStyle));
  31.             if (mleader.ContentType == ContentType.MTextContent)
  32.             {
  33.                 data.Add(new Snoop.Data.Object("MText", mleader.MText));
  34.             }
  35.             else
  36.             {
  37.                 data.Add(new Snoop.Data.Object("MText", null));
  38.             }
  39.             data.Add(new Snoop.Data.Vector3d("Normal", mleader.Normal));
  40.             data.Add(new Snoop.Data.String("Text alignment type", mleader.TextAlignmentType.ToString()));
  41.             data.Add(new Snoop.Data.String("Text angle type", mleader.TextAngleType.ToString()));
  42.             data.Add(new Snoop.Data.String("Text attachment type", mleader.TextAttachmentType.ToString()));
  43.             data.Add(new Snoop.Data.Object("Text color", mleader.TextColor));
  44.             data.Add(new Snoop.Data.Double("Text height", mleader.TextHeight));
  45.             if (mleader.ContentType == ContentType.MTextContent)
  46.             {
  47.                 data.Add(new Snoop.Data.Point3d("Text location", mleader.TextLocation));
  48.             }
  49.             if (mleader.ContentType == ContentType.ToleranceContent)
  50.             {
  51.                 data.Add(new Snoop.Data.Point3d("Tolerance location", mleader.ToleranceLocation));  
  52.             }
  53.             data.Add(new Snoop.Data.ObjectId("Text style Id", mleader.TextStyleId));
  54.                      
  55.         }
  56.  

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: AutoLoader for MgdDbg
« Reply #6 on: May 03, 2012, 04:40:31 AM »

Thanks Jeff,
I'll have a play over the weekend.

Perhaps one of the ADN Dev peeps will grab it and update the download source :)

Regards
Kerry
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

KewlToyZ

  • Guest
Re: AutoLoader for MgdDbg
« Reply #7 on: May 10, 2012, 10:07:47 PM »
Thanks this is going to help me a lot!

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: AutoLoader for MgdDbg
« Reply #8 on: May 10, 2012, 10:33:56 PM »

You're welcome.

In the 'early days' the source for this was a BIG help in grocking the API.
We have Jim Awe at AutoDesk to thank really ... thanks Jim :)

Regards
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

kvstone

  • Guest
Re: AutoLoader for MgdDbg
« Reply #9 on: December 01, 2012, 04:36:45 AM »
It's really useful, unfortunately it's not for autocad2008(my company need use this version for some reason)

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: AutoLoader for MgdDbg
« Reply #10 on: October 29, 2013, 08:16:17 AM »
Does anybody have a working version for 2014? I downloaded the 2012/2013 installer link at the beginning of this thread.  I had to change the RuntimeComponent Max to "19.1". That gets it to load up but I'm still getting errors when I try to inspect Polylines and Mleaders.  The installer does not install the 2013 source code just the 2008 and 2010 versions.

I would really like to avoid converting the 2010 source code if I can.
Revit 2019, AMEP 2019 64bit Win 10

BlackBox

  • King Gator
  • Posts: 3770
Re: AutoLoader for MgdDbg
« Reply #11 on: October 29, 2013, 01:16:19 PM »
... I'm still getting errors when I try to inspect Polylines and Mleaders.

See comments at the bottom of this DevBlog article for some encouragement.  :-P



Separately, if ArxDbg might help, here's an Autoloader .bundle for the most recent build I know of for this utility.

HTH
"How we think determines what we do, and what we do determines what we get."

Jeff H

  • Needs a day job
  • Posts: 6144
Re: AutoLoader for MgdDbg
« Reply #12 on: October 29, 2013, 03:34:15 PM »
I do not use 2014 much yet but opened up 2014 and this works for polylines & mleaders in 2014 and the same bundle used for 2013 & 2012.
 
4MB so here is a dropbox link
 
https://dl.dropboxusercontent.com/u/17374049/Autodesk%20DWG%20MgdDBG.bundle.zip
 
 
 
« Last Edit: October 29, 2013, 03:37:31 PM by Jeff H »

WILL HATCH

  • Bull Frog
  • Posts: 450
Re: AutoLoader for MgdDbg
« Reply #13 on: October 29, 2013, 04:28:43 PM »
Hows this for interesting Jeff:
Code - XML: [Select]
  1. -<AppCDATA>
  2. <![CDATA[Command: CLOSE Clr Data: at MgdDbg.Utils.AcadUi.PrintToCmdLine(String str) in C:\Users\jhornsby\AppData\Roaming\Autodesk\ApplicationPlugins\Autodesk DWG MgdDBG.bundle\Contents\Resources\DWGMgdDbgSource\Utils\AcadUi.cs:line 57 at MgdDbg.Reactors.Events.DocumentMgrEvents.PrintEventMessage(String eventStr, String msg) in C:\Users\jhornsby\AppData\Roaming\Autodesk\ApplicationPlugins\Autodesk DWG MgdDBG.bundle\Contents\Resources\DWGMgdDbgSource\Reactors\Events\DocumentMgrEvents.cs:line 197 at MgdDbg.Reactors.Events.DocumentMgrEvents.event_DocumentDestroyed(Object sender, DocumentDestroyedEventArgs e) in C:\Users\jhornsby\AppData\Roaming\Autodesk\ApplicationPlugins\Autodesk DWG MgdDBG.bundle\Contents\Resources\DWGMgdDbgSource\Reactors\Events\DocumentMgrEvents.cs:line 138 at CDocCollReactorImpl.FireDocumentDestroyed(CDocCollReactorImpl* , Char* fileName) ]]>
  3. </AppCDATA>
it's somehow telling me the files are on your computer

Jeff H

  • Needs a day job
  • Posts: 6144
Re: AutoLoader for MgdDbg
« Reply #14 on: October 29, 2013, 04:52:57 PM »
Did you rebuild it?
 
If not it might have something to do with MgdDbg.pdb files being included?