<?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: Save a password protected drawing without password with VB.NET in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/save-a-password-protected-drawing-without-password-with-vb-net/m-p/3470384#M55676</link>
    <description>&lt;P&gt;Hello Alexander,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you! It works very fine in AutoCAD Architecture 2011.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Udo&lt;/P&gt;</description>
    <pubDate>Thu, 24 May 2012 07:24:23 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-05-24T07:24:23Z</dc:date>
    <item>
      <title>Save a password protected drawing without password with VB.NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/save-a-password-protected-drawing-without-password-with-vb-net/m-p/3450290#M55673</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;our drawings are&amp;nbsp;protected by a password.&lt;/P&gt;&lt;P&gt;We have a VB.NET programm to export a drawing without password.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;Dim securityPar As New SecurityParameters(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)&lt;/P&gt;&lt;P&gt;doc.Database.SaveAs("C:\Temp\Test.DWG", False, DwgVersion.Current, securityPar)&lt;/P&gt;&lt;P&gt;doc.CloseAndSave("C:\Temp\Test.DWG")&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In AutoCAD Architecture 2009 (Win XP) it works fine.&lt;/P&gt;&lt;P&gt;In AutoCAD Architecture 2011 (Win 7) the drawing is still password protected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for help,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Udo&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2012 13:57:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/save-a-password-protected-drawing-without-password-with-vb-net/m-p/3450290#M55673</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-09T13:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Save a password protected drawing without password with VB.NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/save-a-password-protected-drawing-without-password-with-vb-net/m-p/3450500#M55674</link>
      <description>&lt;P&gt;With help of ObjecARX (native) you can clear password protection: &lt;A href="http://forums.autodesk.com/t5/Autodesk-ObjectARX/any-way-to-remove-password-from-a-dwg/m-p/3429797#M28889" target="_blank"&gt;http://forums.autodesk.com/t5/Autodesk-ObjectARX/any-way-to-remove-password-from-a-dwg/m-p/3429797#M28889&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I've not found corresponding method AutoCAD .NET API. IMHO you have to P/Invoke setSecurityParams method.&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2012 15:27:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/save-a-password-protected-drawing-without-password-with-vb-net/m-p/3450500#M55674</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2012-05-09T15:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: Save a password protected drawing without password with VB.NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/save-a-password-protected-drawing-without-password-with-vb-net/m-p/3451134#M55675</link>
      <description>&lt;P&gt;Try this code (minimum testing with AutoCAD 2012 x86):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using System;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;

// This line is not mandatory, but improves loading performances
[assembly: CommandClass(typeof(Rivilis.ClearPassword))]

namespace Rivilis
{

    // This class is instantiated by AutoCAD for each document when
    // a command is called by the user the first time in the context
    // of a given document. In other words, non static data in this class
    // is implicitly per-document!
    public class ClearPassword
    {
        [StructLayout(LayoutKind.Sequential)]
        // From dbsecurity.h
        public struct SecurityParams
        {
            public uint cbSize;
            public uint ulFlags;    // see enum above for flag values
            // data relevant to password protection
            public string wszPassword;
            public uint ulProvType;
            public string wszProvName;
            public uint ulAlgId;        // SECURITYPARAMS_ALGID_RC4
            public uint ulKeyLength;
            // data relevant to digital signatures
            public string wszCertSubject;
            public string wszCertIssuer;
            public string wszCertSerialNum;
            public string wszComment;
            public string wszTimeServer;
        };
        [DllImport("acdb18.dll", CallingConvention = CallingConvention.ThisCall,
            EntryPoint = "?setSecurityParams@AcDbDatabase@@QAE_NPBUSecurityParams@@_N@Z")]
        static extern private bool setSecurityParamsX32(IntPtr db, ref SecurityParams pSecParams, bool bSetDbMod = true);
        [DllImport("acdb18.dll", CallingConvention = CallingConvention.ThisCall, 
            EntryPoint = "?setSecurityParams@AcDbDatabase@@QEAA_NPEBUSecurityParams@@_N@Z")]
        static extern private bool setSecurityParamsX64(IntPtr db, ref SecurityParams pSecParams, bool bSetDbMod = true);

        static public bool setSecurityParams(Database db, ref SecurityParams parms, bool bSetDbMod = true)
        {
            if (IntPtr.Size == 4) return setSecurityParamsX32(db.UnmanagedObject, ref parms, bSetDbMod);
                     else         return setSecurityParamsX64(db.UnmanagedObject, ref parms, bSetDbMod);
        }

        [CommandMethod("ClearPWD", CommandFlags.Modal)]
        public void ClearPWD()
        {
            Database db = HostApplicationServices.WorkingDatabase;
            SecurityParams parms = new SecurityParams();
            parms.cbSize = (uint)Marshal.SizeOf(parms);
            parms.ulFlags = 0; // Clear security flag
            setSecurityParams(db, ref parms);
        }
    }
}
&lt;/PRE&gt;
&lt;P&gt;For VB.NET you can convert C# code: &lt;A href="http://www.developerfusion.com/tools/convert/csharp-to-vb/" target="_blank"&gt;http://www.developerfusion.com/tools/convert/csharp-to-vb/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2012 21:27:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/save-a-password-protected-drawing-without-password-with-vb-net/m-p/3451134#M55675</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2012-05-09T21:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Save a password protected drawing without password with VB.NET</title>
      <link>https://forums.autodesk.com/t5/net-forum/save-a-password-protected-drawing-without-password-with-vb-net/m-p/3470384#M55676</link>
      <description>&lt;P&gt;Hello Alexander,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you! It works very fine in AutoCAD Architecture 2011.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Udo&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2012 07:24:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/save-a-password-protected-drawing-without-password-with-vb-net/m-p/3470384#M55676</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-24T07:24:23Z</dc:date>
    </item>
  </channel>
</rss>

