Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Add prompt to open dialog box when FILEDIA=0

  1. #11
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,740

    Default Re: Add prompt to open dialog box when FILEDIA=0

    Quote Originally Posted by rkmcswain View Post
    Thanks for the re-open, as this wish has not been implemented in the program.
    FWIW -

    This could be implemented via .NET plug-in, where NEW/OPEN/SAVE Command is Veto()-ed when FILEDIA == 0, and a custom CommandMethod Method is called, which then provides the subsequent user prompt, and should the user select the 'dialog' PromptResult option, FILEDIA is programmatically set to 1, and then the initial Command is invoked again via SendStringToExecute().



    [Edit] - If I have time today, I'll mock something up during lunch.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 5860, Xeon W7-2495X, 128GB RAM, Dual PCIe 4.0 M.2 SSD (RAID 0), 20GB NVIDIA RTX 4000 ADA

  2. #12
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,526

    Default Re: Add prompt to open dialog box when FILEDIA=0

    R.K., I don't know why someone hasn't thought of this before. Get's my vote. From all the "where'd my dialog go" questions, it would probably reduce traffic on the acad forum by 50%.
    C:> ED WORKING....


    LinkedIn

  3. #13
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,740

    Default Re: Add prompt to open dialog box when FILEDIA=0

    Quote Originally Posted by BlackBox View Post
    FWIW -

    This could be implemented via .NET plug-in, where NEW/OPEN/SAVE Command is Veto()-ed when FILEDIA == 0, and a custom CommandMethod Method is called, which then provides the subsequent user prompt, and should the user select the 'dialog' PromptResult option, FILEDIA is programmatically set to 1, and then the initial Command is invoked again via SendStringToExecute().
    After trying out a few different ways of going about this, I decided that a simpler, more practical solution is to instead implement a CommandMethod Method aptly named FILEDIAAUTO as a working substitute for a would-be system variable of the same name.

    I've added some comments in the code to help explain each step, but this is admittedly less than a full description, mainly because there's additional features intentionally lacking here, such as storing the ON/OFF setting as a static field in lieu of registry key, etc.... Again, this is only working code for others' consideration.



    In any event... Doing this (adding a psuedo-system variable scenario rather than actually Veto()-ing the native command when FILEDIA=0), reduced the implementation's code-behind significantly, from the Switch Cases for each native command being monitored (i.e. Netload, New, Open, Saveas, etc.), to the small contingent of CommandCancelled, CommandEnded, and CommandFailed event handlers (as one has to account for the first command invoked by user which is Veto()-ed, in addition to the second, asynchronous command call [if SendStringToExecute() is used], based upon the user's input via command call at FILEDIA=0, etc.).



    Attached at the bottom of this post is an assembly compiled to .NET 4.0 framework for AutoCAD 2013 & 2014 (just unblock, unpack the .ZIP file, and NETLOAD the assembly). Should anyone be interested in having this available as an Autoloader .bundle, let me know, and I'll gladly compile an additional assembly to .NET 3.5 framework (for R18 Database), and post the .bundle, etc.

    ... Enough with the chatter, post the code!



    Source-code:
    Code:
    using Autodesk.AutoCAD.ApplicationServices;
    using Autodesk.AutoCAD.EditorInput;
    using Autodesk.AutoCAD.Internal;
    using Autodesk.AutoCAD.Runtime;
    
    using acApp = Autodesk.AutoCAD.ApplicationServices.Application;
    
    [assembly: ExtensionApplication(typeof(BlackBox.AutoCAD.FilediaAuto.Commands))]
    [assembly: CommandClass(typeof(BlackBox.AutoCAD.FilediaAuto.Commands))]
    
    namespace BlackBox.AutoCAD.FilediaAuto
    {
        public class Commands : IExtensionApplication
        {
            private static DocumentCollection acDocs;
            private static int filedia;
    
            // replace these fields with registry keys for published app:
            private static bool on;
            private static string commandsToMatch = "*NETLOAD,*NEW,*OPEN,*SAVEAS";
    
            public void Initialize()
            {
                acDocs = acApp.DocumentManager;
    
                acDocs.MdiActiveDocument.Editor.WriteMessage(
                    "\nFILEDIAAUTO loaded, another creative innovation by BlackBox " +
                    "\n\t\tEnter \"FILEDIAAUTO\" at the command line to invoke \n"
                );
            }
            public void Terminate()
            {
                if (on)
                    acApp.SetSystemVariable("FILEDIA", filedia);
            }
            [CommandMethod("FileDiaAuto")]
            public static void FileDiaAuto()
            {
                if (on)
                {
                    // unregister event handler
                    acDocs.DocumentLockModeChanged -= onDocumentLockModeChanged;
    
                    // set field to false
                    on = false;
    
                    // restore original system variable value
                    acApp.SetSystemVariable("FILEDIA", filedia);
                }
    
                else
                {
                    // store current system variable value
                    filedia = System.Convert.ToInt32(acApp.GetSystemVariable("FILEDIA"));
    
                    // register event handler
                    acDocs.DocumentLockModeChanged += onDocumentLockModeChanged;
    
                    // set field to true
                    on = true;
                }
    
                // prompt user 
                acDocs.MdiActiveDocument.Editor.WriteMessage(
                    "\nFILEDIAAUTO = {0} ", on == true ? "ON" : "OFF");
            }
            private static void onDocumentLockModeChanged(object sender,
                    DocumentLockModeChangedEventArgs e)
            {
                if (Utils.WcMatch(e.GlobalCommandName.ToUpper(), commandsToMatch))
                    acApp.SetSystemVariable("FILEDIA", 1);
            }
        }
    }
    Attached Files Attached Files
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 5860, Xeon W7-2495X, 128GB RAM, Dual PCIe 4.0 M.2 SSD (RAID 0), 20GB NVIDIA RTX 4000 ADA

  4. #14
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,824

    Default Re: Add prompt to open dialog box when FILEDIA=0

    12+ years later, figured this needed a bump
    R.K. McSwain | CAD Panacea |

Page 2 of 2 FirstFirst 12

Similar Threads

  1. 2012: Save dialog box not showing… it is not FILEDIA
    By chris.urner in forum AutoCAD General
    Replies: 2
    Last Post: 2012-02-28, 05:48 PM
  2. 2010: disable xref location prompt on file open
    By theloit in forum AutoCAD General
    Replies: 2
    Last Post: 2011-11-03, 11:46 AM
  3. Customization File Prompt on Open
    By stusic in forum AutoCAD General
    Replies: 4
    Last Post: 2007-12-10, 01:23 AM
  4. Customization File Prompt on Open
    By stusic in forum AutoCAD Customization
    Replies: 7
    Last Post: 2005-10-12, 07:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •