AutoCAD 2010/2011/2012

AutoCAD 2010/2011/2012

Posts: 3
Registered: ‎06-22-2012
Message 1 of 2 (82 Views)

How to set the Drawinglimits?

82 Views, 1 Replies
07-04-2012 07:30 AM

In VB i had:

        Dim newLimits(0 To 3) As Double

        newLimits(0) = x1 - (x2 - x1)

        newLimits(1) = y1 - (y2 - y1)

        newLimits(2) = x2 + (x2 - x1)

        newLimits(3) = y2 + (y2 - y1)

        AcadDoc.Limits = newLimits


Now i thougt this works in this way:

        /// <summary>
        ///     Testfunktion für Limits
        /// </summary>
        private static void Test()
            var acDoc = Application.DocumentManager.MdiActiveDocument;
            var acDb = acDoc.Database;
            acDb.Limmin = new Point2d(10, 50);
            acDb.Limmax = new Point2d(10, 50);

But this is not working

I get the following Error: eLockViolation

I think this is from the Transaction and OpenMode.ForWrite - but where do i get such a transaction and the database open for writing.

*Expert Elite*
Posts: 9,608
Registered: ‎06-29-2007
Message 2 of 2 (81 Views)

Re: How to set the Drawinglimits?

07-04-2012 08:27 AM in reply to: straussm



eLockViolation means your document is not locked for your changes, you have to lock it first


   Dim tDoc as ApplicationServices.Document

   Dim tDocLock as ApplicationServices.DocumentLock

   tDoc = ApplicationServices.Application.DocumentManager.MdiActiveDocument

   tDocLock = tDoc.LockDocument

   ' your changes here, then unlock the document



Good luck, - alfred -

Ingenieur Studio HOLLAUS ...
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.