• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Contributor
    Posts: 20
    Registered: ‎09-29-2006

    DBMOD = 32 ?

    159 Views, 3 Replies
    12-19-2012 11:36 PM

    Hi,

     

    Can anyone give me an example how to get the system variable DBMOD = 32 or (DBMOD AND 32)=32?

     

    Actually, I consider the drawing need really to be saved only if DBMOD is equal to 1,4 or 5. Is that right?

     

    Regards,

    Please use plain text.
    Moderator
    Alexander.Rivilis
    Posts: 1,167
    Registered: ‎04-09-2008

    Re: DBMOD = 32 ?

    12-20-2012 02:19 AM in reply to: glanard

    In order to set DBMOD variable you can P/Invoke acdbSetDbmod function:

    long __cdecl acdbSetDbmod(class AcDbDatabase *, long newDBMod);

     Example:

    using System;
    using System.Runtime.InteropServices;
    using Autodesk.AutoCAD.Runtime;
    using Autodesk.AutoCAD.ApplicationServices;
    using Autodesk.AutoCAD.DatabaseServices;
    [assembly: CommandClass(typeof(Rivilis.SetDbMod))]
    namespace Rivilis
    {
        public class SetDbMod
        {
            [System.Security.SuppressUnmanagedCodeSecurity]
            [DllImport("acdb16.dll", CallingConvention = CallingConvention.Cdecl,
               EntryPoint = "?acdbSetDbmod@@YAJPAVAcDbDatabase@@J@Z")]
            private static extern Int32 acdbSetDbmod16(IntPtr db, Int32 newDbMod);
            [System.Security.SuppressUnmanagedCodeSecurity]
            [DllImport("acdb17.dll", CallingConvention = CallingConvention.Cdecl,
               EntryPoint = "?acdbSetDbmod@@YAJPAVAcDbDatabase@@J@Z")]
            private static extern Int32 acdbSetDbmod17(IntPtr db, Int32 newDbMod);
            [System.Security.SuppressUnmanagedCodeSecurity]
            [DllImport("acdb18.dll", CallingConvention = CallingConvention.Cdecl,
               EntryPoint = "?acdbSetDbmod@@YAJPAVAcDbDatabase@@J@Z")]
            private static extern Int32 acdbSetDbmod18(IntPtr db, Int32 newDbMod);
            [System.Security.SuppressUnmanagedCodeSecurity]
            [DllImport("acdb19.dll", CallingConvention = CallingConvention.Cdecl,
               EntryPoint = "?acdbSetDbmod@@YAJPAVAcDbDatabase@@J@Z")]
            private static extern Int32 acdbSetDbmod19(IntPtr db, Int32 newDbMod);
    
            public static Int32 acdbSetDbmod(ref Database db, Int32 newDbMod)
            {
                switch (Autodesk.AutoCAD.ApplicationServices.Application.Version.Major)
                {
                    case 16: return acdbSetDbmod16(db.UnmanagedObject, newDbMod);
                    case 17: return acdbSetDbmod17(db.UnmanagedObject, newDbMod);
                    case 18: return acdbSetDbmod18(db.UnmanagedObject, newDbMod);
                    case 19: return acdbSetDbmod19(db.UnmanagedObject, newDbMod);
                    default: return (Int32)ErrorStatus.NotImplementedYet;
                }
            }
            //--------------------------------------
            // Clear DbMod for Active document
            // Очистка DBMOD для активного документа
            //--------------------------------------
            [CommandMethod("ClearCurDbMod")]
            static public void ClearCurDbMod()
            {
                Database db = Application.DocumentManager.MdiActiveDocument.Database;
                acdbSetDbmod(ref db, 0);
            }
    
            //--------------------------------------
            // Clear DbMod for All opened documents
            // Очистка DBMOD для всех документов
            //--------------------------------------
            [CommandMethod("ClearAllDbMod")]
            static public void ClearAllDbMod()
            {
                foreach (Document doc in Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager)
                {
                    Database db = doc.Database;
                    acdbSetDbmod(ref db, 0);
                }
            }
        };
    }

     This code is only for x86 AutoCAD. x64 is different with  EntryPoint string: 

    EntryPoint = "?acdbSetDbmod@@YAJPEAVAcDbDatabase@@J@Z"

     


    Пожалуйста не забывайте про Утвердить в качестве решения!Утвердить в качестве решения и Give Kudos!Баллы
    Please remember to Accept Solution!Accept as Solution and Give Kudos!Kudos

    Please use plain text.
    Contributor
    Posts: 20
    Registered: ‎09-29-2006

    Re: DBMOD = 32 ?

    12-20-2012 05:22 AM in reply to: Alexander.Rivilis

    Hi Alexander,

     

    Probably my question was not very clear :smileyembarrassed: (probably due to my poor english).

     

    I do not want to set the DBMOD variable.

    Futher more, I really don't see the interset to set this variable :smileysurprised:

     

    What I wanted to know is, in the reality as a simple user, in which case this variable can be found equal to 32.

    In the documentation, they talk about "field"?!

    I tried some tests modifying text's field, but this does not set the DBMOD to 32...

     

    Regards,

    Please use plain text.
    Moderator
    Alexander.Rivilis
    Posts: 1,167
    Registered: ‎04-09-2008

    Re: DBMOD = 32 ?

    12-20-2012 10:08 AM in reply to: glanard

    glanard wrote:

    What I wanted to know is, in the reality as a simple user, in which case this variable can be found equal to 32.

    In the documentation, they talk about "field"?!


    I do not know how a normal user can get value DBMOD = 32 without using the application.
    Also, I should clarify that the function acdbSetDbmod is undocumented and unsupported and could change or go away in any future release including an API compatible release , I was reminded the guys from Autodesk.


    Пожалуйста не забывайте про Утвердить в качестве решения!Утвердить в качестве решения и Give Kudos!Баллы
    Please remember to Accept Solution!Accept as Solution and Give Kudos!Kudos

    Please use plain text.