AutoCAD 2010/2011/2012

AutoCAD 2010/2011/2012

Reply
Member
3 Posts
0 Kudos
Registered: ‎06-22-2012
Post 1 of 2

How to set the Drawinglimits?

83 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*
9,785 Posts
1,210 Kudos
Registered: ‎06-29-2007
Post 2 of 2

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