<?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: How to open file by AutoCAD command in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-open-file-by-autocad-command/m-p/7739071#M27766</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;Did you run the code in CAD2008?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, only 2013 to 2018.&lt;/P&gt;</description>
    <pubDate>Wed, 31 Jan 2018 10:29:53 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2018-01-31T10:29:53Z</dc:date>
    <item>
      <title>How to open file by AutoCAD command</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-open-file-by-autocad-command/m-p/7734818#M27759</link>
      <description>&lt;P&gt;Hi！&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; I want open DWG file by AutoCAD command. There are two methods Application.DocumentManager.MdiActiveDocument.SendStringToExecute() and C++ acedCmd() i&lt;SPAN&gt;mplemented as follow:&amp;nbsp;[DllImport("accore.dll", EntryPoint = "acedCmd", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl)]&amp;nbsp;private extern static int acedCmd(IntPtr rbp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; But i don't know how to write the correct code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; I&amp;nbsp;have tried the following code, but ITdoes not work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;(1) ResultBuffer rb = new ResultBuffer();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rb.Add(new TypedValue(5005, "_.OPEN D:\\1.dwg"));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!AcadApp.DocumentManager.IsApplicationContext)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; acedCmd(rb.UnmanagedObject);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;(2)AcadApp.DocumentManager.MdiActiveDocument.SendStringToExecute("OPEN D:\\1.dwg ", true, false, true);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;Anybody can help me.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 02:54:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-open-file-by-autocad-command/m-p/7734818#M27759</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-30T02:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to open file by AutoCAD command</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-open-file-by-autocad-command/m-p/7735252#M27760</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do not need to call the OPEN command to open a drawing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should use the DocumentCollection.Open() method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DocumentCollection docMgr = AcadApp.DocumentManager;
Document doc = docMgr.Open("&lt;SPAN&gt;D:\\1.dwg&lt;/SPAN&gt;");
docMgr.MdiActiveDocument = doc;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Jan 2018 07:59:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-open-file-by-autocad-command/m-p/7735252#M27760</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-01-30T07:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to open file by AutoCAD command</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-open-file-by-autocad-command/m-p/7735485#M27761</link>
      <description>&lt;P&gt;Thank you!&amp;nbsp;I did as you said.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-align: left; color: #2a2e2e; text-transform: none; text-indent: 0px; letter-spacing: normal; font-family: 'Helvetica Neue', arial, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; orphans: 2; widows: 2; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px;"&gt;I have a problem about using WPF&amp;nbsp;inside an AutoCAD palette, and i think the problem may be solved if i use another way to open file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-align: left; color: #2a2e2e; text-transform: none; text-indent: 0px; letter-spacing: normal; font-family: 'Helvetica Neue', arial, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; orphans: 2; widows: 2; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px;"&gt;So, my question is whether there is another way to open DWG file.&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 09:38:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-open-file-by-autocad-command/m-p/7735485#M27761</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-30T09:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to open file by AutoCAD command</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-open-file-by-autocad-command/m-p/7735532#M27762</link>
      <description>&lt;P&gt;The upper method should work from a WPF click event:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        private void CmdButton_Click(object sender, RoutedEventArgs e)
        {
            DocumentCollection docMgr = AcAp.DocumentManager;
            docMgr.Open("D:\\1.dwg", false);
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 09:57:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-open-file-by-autocad-command/m-p/7735532#M27762</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-01-30T09:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to open file by AutoCAD command</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-open-file-by-autocad-command/m-p/7735909#M27763</link>
      <description>&lt;P&gt;Here's a minimalist example of PaletteSet with a WPF UserControl.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Commands class&lt;/P&gt;
&lt;PRE&gt;using Autodesk.AutoCAD.Runtime;

namespace OpenDwgFromWpfPalette
{
    public class Commands
    {
        static CustomPaletteSet palette;

        [CommandMethod("TEST_PALETTE")]
        public void CmdPalette()
        {
            if (palette == null)
                palette = new CustomPaletteSet();
            palette.Visible = true;
        }
    }
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CustomPaletteSet class&lt;/P&gt;
&lt;PRE&gt;using Autodesk.AutoCAD.Windows;

namespace OpenDwgFromWpfPalette
{
    public class CustomPaletteSet : PaletteSet
    {

        public CustomPaletteSet() : base("Palette")
        {
            AddVisual("Open file", new PaletteTab());
        }
    }
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PaletteTab XAML&lt;/P&gt;
&lt;PRE&gt;&amp;lt;UserControl x:Class="OpenDwgFromWpfPalette.PaletteTab"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:OpenDwgFromWpfPalette"
             mc:Ignorable="d" 
             d:DesignHeight="150" d:DesignWidth="250"&amp;gt;
    &amp;lt;StackPanel Background="WhiteSmoke"&amp;gt;
        &amp;lt;Button x:Name="OpenButton" Width="80" Margin="10" Click="OpenButton_Click"&amp;gt;Open&amp;lt;/Button&amp;gt;
    &amp;lt;/StackPanel&amp;gt;
&amp;lt;/UserControl&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PaletteTab code behind&lt;/P&gt;
&lt;PRE&gt;using Autodesk.AutoCAD.ApplicationServices;
using System.Windows;
using System.Windows.Controls;
using AcAp = Autodesk.AutoCAD.ApplicationServices.Core.Application;

namespace OpenDwgFromWpfPalette
{
    public partial class PaletteTab : UserControl
    {
        public PaletteTab()
        {
            InitializeComponent();
        }

        private void OpenButton_Click(object sender, RoutedEventArgs e)
        {
            AcAp.DocumentManager.Open("D:\\1.dwg", false);
        }
    }
}&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 12:44:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-open-file-by-autocad-command/m-p/7735909#M27763</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-01-30T12:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to open file by AutoCAD command</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-open-file-by-autocad-command/m-p/7739001#M27764</link>
      <description>&lt;P&gt;Thank you！&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 10:02:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-open-file-by-autocad-command/m-p/7739001#M27764</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-31T10:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to open file by AutoCAD command</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-open-file-by-autocad-command/m-p/7739020#M27765</link>
      <description>&lt;P&gt;Did you run the code in CAD2008?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 10:08:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-open-file-by-autocad-command/m-p/7739020#M27765</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-31T10:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to open file by AutoCAD command</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-open-file-by-autocad-command/m-p/7739071#M27766</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;Did you run the code in CAD2008?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, only 2013 to 2018.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 10:29:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-open-file-by-autocad-command/m-p/7739071#M27766</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-01-31T10:29:53Z</dc:date>
    </item>
  </channel>
</rss>

