<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Simulate the opening function of CAD in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12960871#M2965</link>
    <description>&lt;P&gt;If you don't need the user to interact with the dwg, then you can open the dwg as a database instead of opening it as a dwg in the Editor environment. Then you won't get any prompts at all. Often, this is used to copy objects from the database of the readonly file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;
          // Read the DWG into a side database
          Database sourceDb = new Database(false, true);
          sourceDb.ReadDwgFile(Properties.Settings.Default.PlotSettingPath,
                              System.IO.FileShare.Read,
                              true,
                              "");&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Aug 2024 14:55:49 GMT</pubDate>
    <dc:creator>Ed__Jobe</dc:creator>
    <dc:date>2024-08-15T14:55:49Z</dc:date>
    <item>
      <title>Complete CAD file opening function</title>
      <link>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12957546#M2962</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;div class="lia-vid-container video-embed-left"&gt;&lt;div id="lia-vid-6360436981112w200h114r603" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6360436981112" data-account="6057940548001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6057940548001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6360436981112w200h114r603');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://forums.autodesk.com/t5/video/gallerypage/video-id/6360436981112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;div class="lia-vid-container video-embed-left"&gt;&lt;div id="lia-vid-6360438167112w200h114r457" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6360438167112" data-account="6057940548001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6057940548001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6360438167112w200h114r457');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://forums.autodesk.com/t5/video/gallerypage/video-id/6360438167112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;When opening a file using CAD, if the file contains proxy graphics, a proxy graphics prompt will pop up; Alternatively, when the file is missing fonts, a prompt for missing fonts will pop up; Alternatively, when opening the same file for the second time, a read-only prompt will pop up.&lt;BR /&gt;What I need now is to include these prompts when opening DWG files in the code, and to be able to open DWG files read-only.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Open prompt" style="width: 531px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1397567iDC5DC9237248EF3F/image-size/large?v=v2&amp;amp;px=999" role="button" title="2024-08-14_143757.png" alt="Open prompt" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Open prompt&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Read-only prompt" style="width: 618px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1397569i1CAD6181C7E72EC7/image-size/large?v=v2&amp;amp;px=999" role="button" title="2024-08-14_144047.png" alt="Read-only prompt" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Read-only prompt&lt;/span&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Here are two ways I tried to open files, each with its own advantages and disadvantages&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Autodesk.AutoCAD.ApplicationServices.DocumentCollectionExtension.Open&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Autodesk.AutoCAD.ApplicationServices.DocumentCollectionExtension.Open Can be opened read-only, but will ignore prompts，And no prompt message will pop up&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;System.Diagnostics.Process.Start &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;System.Diagnostics.Process.Start Will not ignore the prompt, but cannot open the same file repeatedly and cannot be opened read-only&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So is there a way to open a file that meets these conditions simultaneously: it can pop up a prompt, open the file in read-only mode, and open the same file multiple times&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 02:42:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12957546#M2962</guid>
      <dc:creator>SimonaQQ</dc:creator>
      <dc:date>2024-08-15T02:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate the opening function of CAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12958539#M2963</link>
      <description>&lt;P&gt;You may want to rephrase your question as what exactly you want to know/archive.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The 2 lines of code are quite different and is not comparable as apple vs banana: first code runs inside AutoCAD to open a drawing; the second code is for external app to lunch AutoCAD, which may or may not have a drawing being opened, and it have no control on what AutoCAD will do after it starts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume what you want is whenever a drawing in AutoCAD opens, you want to do something, such as checking if particular conditions are met, particular data status in drawing... and prompt user in some way. If so, you can simply handle DocumentCollection.DocumentCreated event, which provide a chance for you to examine the Document and do something accordingly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2024 15:26:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12958539#M2963</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2024-08-14T15:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate the opening function of CAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12959705#M2964</link>
      <description>Thank you for your reply. I have revised my question. Do you think it is easier to understand</description>
      <pubDate>Thu, 15 Aug 2024 02:45:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12959705#M2964</guid>
      <dc:creator>SimonaQQ</dc:creator>
      <dc:date>2024-08-15T02:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate the opening function of CAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12960871#M2965</link>
      <description>&lt;P&gt;If you don't need the user to interact with the dwg, then you can open the dwg as a database instead of opening it as a dwg in the Editor environment. Then you won't get any prompts at all. Often, this is used to copy objects from the database of the readonly file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;
          // Read the DWG into a side database
          Database sourceDb = new Database(false, true);
          sourceDb.ReadDwgFile(Properties.Settings.Default.PlotSettingPath,
                              System.IO.FileShare.Read,
                              true,
                              "");&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 14:55:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12960871#M2965</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2024-08-15T14:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate the opening function of CAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12960911#M2966</link>
      <description>What I need is interaction, because there is no interaction when opening DWG documents using APIs, so I asked how to interact.</description>
      <pubDate>Thu, 15 Aug 2024 15:03:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12960911#M2966</guid>
      <dc:creator>SimonaQQ</dc:creator>
      <dc:date>2024-08-15T15:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate the opening function of CAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12960996#M2967</link>
      <description>&lt;P&gt;It's not easy to understand what you're asking for, but I think this is what you want. AutoCAD automatically takes care of prompting when there are proxy objects and when xrefs, fonts are missing, etc. So all you really need to do is open the file read-only. The DocumentCollectionExtension class isn't used explicitly. It provides extension methods to the DocumentManager class, which is the Open method shown below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;using acApp = Autodesk.AutoCAD.ApplicationServices.Application;

Document readOnlyDoc = acApp.DocumentManager.Open("filepath", true);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 15:34:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12960996#M2967</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2024-08-15T15:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate the opening function of CAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12961043#M2968</link>
      <description>I use the 2016 version of the API to open files without any prompt messages, and there will be no interactive content when opened read-only. Therefore, I have this question. Perhaps my problem has been solved in the updated version?&lt;BR /&gt;My English is really poor, what I really want is what is demonstrated in the video.&lt;BR /&gt;There are prompt messages or interactive content when opening the file, and it can be opened read-only</description>
      <pubDate>Thu, 15 Aug 2024 15:50:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12961043#M2968</guid>
      <dc:creator>SimonaQQ</dc:creator>
      <dc:date>2024-08-15T15:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate the opening function of CAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12961071#M2969</link>
      <description>&lt;P&gt;AutoCAD automatically takes care of checking the dwg when opening. It has been that way since I can remember. If you open a dwg with custom objects in it and the plugin that created the objects is loaded, then you won't get the proxy notice dialog. A proxy is a representation of the real thing. If you have a custom object, only the custom app that created it knows how to edit it. If that app is not loaded in AutoCAD, then AutoCAD only know how to show a proxy or a representation of the object. When you open the file, you can choose to view the proxies or not. If font's or xrefs are not able to be found when opening the file, you are shown dialogs to help you locate the missing files. This all happens without you needing to write code for it. All you have to do is open the document. If you use the code I gave you, you can use the second argument as true to open the file readonly. If you leave the second argument off, then acad will attempt to open the document for write.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 16:01:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12961071#M2969</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2024-08-15T16:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate the opening function of CAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12962142#M2970</link>
      <description>&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6360486781112w200h115r747" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6360486781112" data-account="6057940548001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6057940548001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6360486781112w200h115r747');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://forums.autodesk.com/t5/video/gallerypage/video-id/6360486781112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;&lt;P&gt;However, the actual result is not as expected. I recorded a video where I opened a DWG file using both an API and a manual method. When using the API, there were no prompts, such as proxy notices or the read-only prompt when opening the file a second time. These prompts do appear when opening the file manually. What I want is for these prompts to also appear when opening the file through the API. Could you please help me correct my code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 03:00:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12962142#M2970</guid>
      <dc:creator>SimonaQQ</dc:creator>
      <dc:date>2024-08-16T03:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate the opening function of CAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12963232#M2971</link>
      <description>&lt;P&gt;You might try document.SendCommand method with the OPEN command.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 14:31:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12963232#M2971</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2024-08-16T14:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: Complete CAD file opening function</title>
      <link>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12965211#M2972</link>
      <description>&lt;P&gt;If the drawing file opened by code is currently in use (i.e. opened in other AutoCAD session, or even in the same AutoCAD session), the DocumentCollection.Open() method will SILENTLY opens the drawing file as read-only. So, it is the opening code's responsibility to decide whether users should be prompted or not. See following code:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        [CommandMethod("OpenTest", CommandFlags.Session)]
        public static void OpenDrawingInAutoCAD()
        {
            var dwgFile = @"E:\Temp\Test.dwg";
            var dwg = CadApp.DocumentManager.Open(dwgFile);
            if (dwg.IsReadOnly)
            {
                var keep = PromptUserForKeepOpenOrClose(dwgFile);
                if ( !keep)
                {
                    dwg.CloseAndDiscard();
                }
            }
        }

        private static bool PromptUserForKeepOpenOrClose(string dwgFile)
        {
            WhoHasInfo whoHas = CadApp.GetWhoHasInfo(dwgFile);

            // show WhoHasInfo to user and ask Keep/Close
            // with a MessageBox with Yes/No button here

            // Assume user want to close
            return false;
        }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To test this code. make sure you start another AutoCAD session and open the drawing file there first. Then run the command in different session (likely, your debugging session). After the drawing is opened, you would see the Document.IsReadonly property is true. Then you can prompt user/simulate what AutoCAD does.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For other types of prompt, if the code does not trigger the AutoCAD's built-in prompts, you would/could have to do it yourself, say to handle Document.EndDwgOpen event so that you can examine the drawing contents to decide what type of prompts are needed. In order to hook Document.EndDwgOpen event handler, you may have to handle DocumentCollection.DocumentCreated event, I guess (never did that myself).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2024 01:39:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12965211#M2972</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2024-08-18T01:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Complete CAD file opening function</title>
      <link>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12966404#M2973</link>
      <description>It feels quite complicated to determine the file content and provide prompts on my own. Do you have any understanding of the `System.Diagnostics.Process.Start` method? Can this method be used to open the same DWG file twice? I only know that this method controls system processes, and to open the same file, you need support from the corresponding software, such as CAD. But CAD can open the same file, so I still have hope for this method, hoping that I couldn't open the same file because I didn't use it correctly.</description>
      <pubDate>Mon, 19 Aug 2024 02:16:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12966404#M2973</guid>
      <dc:creator>SimonaQQ</dc:creator>
      <dc:date>2024-08-19T02:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate the opening function of CAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12966464#M2974</link>
      <description>&lt;P&gt;I've tried this command, but it brings up a file selection dialog box. In reality, I can directly obtain the file path, so having to select the file again is not very user-friendly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 03:28:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12966464#M2974</guid>
      <dc:creator>SimonaQQ</dc:creator>
      <dc:date>2024-08-19T03:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Complete CAD file opening function</title>
      <link>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12967365#M2975</link>
      <description>All the user prompts that users see when a drawing is opened in AutoCAD ARE DONE INSIDE AutoCAD, while System.Diagnostics.Process.Start() ONLY STARTS AutoCAD and HAS NOTHING TO DO with what AutoCAD does after it begins running. That is, System.Giagnostics.Process KNOWS NOTHING about AutoCAD, except to get it started on behalf of the OS (Windows).&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 19 Aug 2024 12:32:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/complete-cad-file-opening-function/m-p/12967365#M2975</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2024-08-19T12:32:51Z</dc:date>
    </item>
  </channel>
</rss>

