.NET

Reply
Valued Contributor
Posts: 72
Registered: ‎07-21-2009
Message 1 of 9 (529 Views)

Working with Session Flag

529 Views, 8 Replies
02-24-2011 10:16 AM

I am creating an AutoCAD plugin that gathers information from the current drawing and the user, inserts a block, selects an area of the drawing, creates a new drawing and copies the selected items to the new drawing.  The problem is that I need to use a function similar to zoomextents on the new drawing, which seems to conflict with the other operations I need to perform.

 

I found a proposed solution that suggested adding a Session flag to the CommandMethod, but that caused another error, earlier in execution when the drawing-specific functionality .  Is there any way to get all of this functionality to work with one CommandMethod?  The errors messages I received are:

w/out session flag: "Invalid execution context"

w/ session flag "eLockViolation"

 

Thank you in advance for your answers.

*Expert Elite*
arcticad
Posts: 1,285
Registered: ‎06-21-2004
Message 2 of 9 (506 Views)

Re: Working with Session Flag

02-24-2011 11:36 AM in reply to: vampirefromtheITcave2

In reguards to the eLockViolation

You need to lock the drawing first.

 

http://forums.autodesk.com/t5/NET/im-getting-eLockViolation/m-p/2690906#M19370

---------------------------



(defun botsbuildbots() (botsbuildbots))
*Expert Elite*
chiefbraincloud
Posts: 750
Registered: ‎02-13-2008
Message 3 of 9 (492 Views)

Re: Working with Session Flag

02-24-2011 12:01 PM in reply to: vampirefromtheITcave2

Use both the Session flag (to fix the Invalid Execution Context) and a Document Lock (to fix the eLockViolation).

 

Once you apply the Session flag to a command, you are then responsible for making sure the appropriate documents are locked.

Dave O.                                                                  Sig-Logos32.png
Valued Contributor
Posts: 72
Registered: ‎07-21-2009
Message 4 of 9 (444 Views)

Re: Working with Session Flag

02-25-2011 06:29 AM in reply to: vampirefromtheITcave2

I fixed all of the lock errors and have the Session flag in the CommandMethod, but I'm getting the invalid exectution context error again.  It happens when the code tries to open the newly created document.

Valued Contributor
Posts: 72
Registered: ‎07-21-2009
Message 5 of 9 (370 Views)

Re: Working with Session Flag

02-28-2011 06:46 AM in reply to: vampirefromtheITcave2

I'm still stuck on this.  Does anyone have any other ideas?  Thank you in advance.

*Expert Elite*
arcticad
Posts: 1,285
Registered: ‎06-21-2004
Message 6 of 9 (361 Views)

Re: Working with Session Flag

02-28-2011 08:59 AM in reply to: vampirefromtheITcave2

Can you post a complete code example with an example of the error?

---------------------------



(defun botsbuildbots() (botsbuildbots))
Valued Contributor
Posts: 72
Registered: ‎07-21-2009
Message 7 of 9 (349 Views)

Re: Working with Session Flag

02-28-2011 12:43 PM in reply to: vampirefromtheITcave2

Unfortunately I am not able to include all of the code, but the code that is not functioning properly is in forum code.txt in the secondfunction (createDriveFile).  The line where the code fails is marked with a comment.  It is the line where the file should be opened.

Valued Mentor
Posts: 358
Registered: ‎03-31-2005
Message 8 of 9 (341 Views)

Re: Working with Session Flag

02-28-2011 01:27 PM in reply to: vampirefromtheITcave2

This line does not look correct (Dim newDWG = Application.DocumentManager.Open(filePath, False)).

 

My guess is you intended newdwg to be an ApplicationServices.Document.  Try this:

Dim newDWG as ApplicationServices.Document = Application.DocumentManager.Open(filePath, False).


 

Valued Contributor
Posts: 72
Registered: ‎07-21-2009
Message 9 of 9 (308 Views)

Re: Working with Session Flag

03-01-2011 06:24 AM in reply to: vampirefromtheITcave2

I tried the more specific declaration, but the problem seems to be with the open command being called here, although it is called from session mode.  I got the exact same error with this change.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community