Author Topic: Autoloader  (Read 6096 times)

0 Members and 1 Guest are viewing this topic.

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Autoloader
« Reply #15 on: August 28, 2015, 03:17:09 PM »
Winforms is not dead!  Still making a lot of money using this supposedly dead and archaic technology!


Every time you use Winforms a puppy gets eaten in the far east. :cry:

Seriously though, good luck with those Winforms when you have to move to Universal Apps.
« Last Edit: August 28, 2015, 03:22:01 PM by MexicanCustard »
Revit 2019, AMEP 2019 64bit Win 10

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Autoloader
« Reply #16 on: August 28, 2015, 03:35:45 PM »
With WPF  I like to put all the code in the window class because everyone you do a mvvm purist dies a little.  :devilsidesmile:


RICVBA

  • Newt
  • Posts: 62
Re: Autoloader
« Reply #17 on: August 30, 2015, 03:22:23 PM »
I looked at "Zero Document State and Custom Tool Palettes" link given by BB in replay#9
I went through TT's "PaletteSetWithCloseEvent" extension successfully (i.e.: it ran!)
then I tried the same with Keith Brown's "EnhancedPaletteSet" extension class but I got stuck quite near (I guess) the endline: in my VSE2105 Error List window there showed three errors only, all with the same 'Code' (CS0103) and 'Description' ("The name 'Active' does not exist in the current context")
the three lines responsible for those errors are:
Code: [Select]
if (Active.Document == null)
Code: [Select]
if (documentCollection.Count > 1 && Active.Document != null)
Code: [Select]
if (documentCollection.Count == 1 || Active.Document == null)
I searched in theswamp NET forum with "Active.Document" keyword but all posts it put out just used "Active" as if it was a component/field/class granted for sure.
Also Google search didn't end up with any result
so I'm asking you where should I search for this topic?

thank you

Keith Brown

  • Swamp Rat
  • Posts: 601
Re: Autoloader
« Reply #18 on: August 30, 2015, 03:51:15 PM »
Oops.  Active is just a class I use to get the active document, database, etc.  just replace with the mdiactivedocument.
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Autoloader
« Reply #19 on: August 30, 2015, 04:55:51 PM »
RICVBA,


Have a look at the downloadable material from Scott McFarlane's AutoDesk University class lecture
http://au.autodesk.com/au-online/classes-on-demand/class-catalog/2013/autocad/dv2177#chapter=0


You'll find this Class source code  in Active.cs
I'd assume Keith's usage is similar  With references to the namespace this class is defined in.


Code - C#: [Select]
  1. using Autodesk.AutoCAD.ApplicationServices;
  2. using Autodesk.AutoCAD.ApplicationServices.Core;
  3. using Autodesk.AutoCAD.DatabaseServices;
  4. using Autodesk.AutoCAD.EditorInput;
  5.  
  6.  
  7. namespace DV2177.Common
  8. {
  9.     /// <summary>
  10.     /// Provides easy access to several "active" objects in the AutoCAD
  11.     /// runtime environment.
  12.     /// </summary>
  13.     public static class Active
  14.     {
  15.         /// <summary>
  16.         /// Returns the active Editor object.
  17.         /// </summary>
  18.         public static Editor Editor
  19.         {
  20.             get { return Document.Editor; }
  21.         }
  22.  
  23.  
  24.         /// <summary>
  25.         /// Returns the active Document object.
  26.         /// </summary>
  27.         public static Document Document
  28.         {
  29.             get { return Application.DocumentManager.MdiActiveDocument; }
  30.         }
  31.  
  32.  
  33.         /// <summary>
  34.         /// Returns the active Database object.
  35.         /// </summary>
  36.         public static Database Database
  37.         {
  38.             get { return Document.Database; }
  39.         }
  40.  
  41.  
  42.         /// <summary>
  43.         /// Sends a string to the command line in the active Editor
  44.         /// </summary>
  45.         /// <param name="message">The message to send.</param>
  46.         public static void WriteMessage(string message)
  47.         {
  48.             Editor.WriteMessage(message);
  49.         }
  50.  
  51.  
  52.         /// <summary>
  53.         /// Sends a string to the command line in the active Editor using String.Format.
  54.         /// </summary>
  55.         /// <param name="message">The message containing format specifications.</param>
  56.         /// <param name="parameter">The variables to substitute into the format string.</param>
  57.         public static void WriteMessage(string message, params object[] parameter)
  58.         {
  59.             Editor.WriteMessage(message, parameter);
  60.         }
  61.       }
  62. }
  63.  




   
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.

Keith Brown

  • Swamp Rat
  • Posts: 601
Re: Autoloader
« Reply #20 on: August 30, 2015, 05:21:37 PM »
Yes,  that's definitely the one.  I have made a couple small changes to the class but the original I got from Scott's class.
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

RICVBA

  • Newt
  • Posts: 62
Re: Autoloader
« Reply #21 on: August 31, 2015, 01:50:53 AM »
thank you all
I downloaded the course and I'll get through it as soon as possible
Hope it will bring me one step further on the knowledge of the Transaction/OpenMode stuff and the likes

BlackBox

  • King Gator
  • Posts: 3770
Re: Autoloader
« Reply #22 on: August 31, 2015, 11:58:49 AM »
Hope it will bring me one step further on the knowledge of the Transaction/OpenMode stuff and the likes

Generally speaking -

Transactions are essentially a mechanism to simplify the way we interact with DBObjects, and when wrapped within a 'using' block, all of the overhead you'd otherwise have to manually manage, is handled for you with a simple call to Commit().

You can do everything that the using block, and Transaction do for you - the trade off is better performance, but more work on your part, with the added potential for fatal crashes if not managed properly.
"How we think determines what we do, and what we do determines what we get."

RICVBA

  • Newt
  • Posts: 62
Re: Autoloader
« Reply #23 on: August 31, 2015, 02:42:09 PM »
I see

generally speaking can there be put a limit (number of database record, number and/or type of operations on them, other...) above which the better performance trade off is or can be actually worth the risk for fatal crashes?

I'm aiming at the awareness that for my actual uses it will never be

BlackBox

  • King Gator
  • Posts: 3770
Re: Autoloader
« Reply #24 on: August 31, 2015, 03:14:25 PM »
I see

generally speaking can there be put a limit (number of database record, number and/or type of operations on them, other...) above which the better performance trade off is or can be actually worth the risk for fatal crashes?

I'm aiming at the awareness that for my actual uses it will never be

I'll have to defer to someone more experienced than I to answer that, as I've been **perfectly happy with the performance of using Transactions + using block, and have never even tried - figured I'd leave that for the to-do list when I decide to step up into ObjectARX (C++ for AutoCAD).



** What I've not been happy with is Civil 3D-specific Objects not having sufficient .NET API exposure, to allow me to obtain the information I need without exploding in memory (not actually exploding the source Object), which is incredibly inefficient, just so to cull the information I'm after; example: Alignment Station Offset Labels. Grrr
"How we think determines what we do, and what we do determines what we get."