AutoCAD 2010/2011/2012

Reply
Member
straussm
Posts: 3
Registered: ‎06-22-2012
Message 1 of 2 (79 Views)

How to set the Drawinglimits?

79 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*
Alfred.NESWADBA
Posts: 9,217
Registered: ‎06-29-2007
Message 2 of 2 (78 Views)

Re: How to set the Drawinglimits?

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

Hi,

 

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

   '...do your changes here, then unlock the document

   tDocLock.Dispose

 

Good luck, - alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.