.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i got an eLockViolation-Error when starting a form out of a palette

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Juergen.Becker
1046 Views, 4 Replies

i got an eLockViolation-Error when starting a form out of a palette

Hi,

 

I'm creating a palette with a usercontrol in it. The usercontrol contains a button for starting a Userform.

When I start the userform from the commandline its works.

When I start the userform with the usercontrol-button in the palette i always get an eLockViolation error.

 

I think the document must be locked and I can't understand why. What must I do to unlock the document.

 

Many thanks for your help

Jürgen

4 REPLIES 4
Message 2 of 5

 

using (DocumentLock m_doclock= Application.DocumentManager.MdiActiveDocument.LockDocument()) 
 {
   // Place your's code, which modify drawing
 }

 Read about application context in AutoCAD

 

 
Message 3 of 5
HomeBoyLV
in reply to: Juergen.Becker

The Short of it is that AutoCad locks the document before executing you code from the command. If you execute the command from a userform, you are responsible for locking the document.

 

What I do is create a command line version of the command first, and then use SendStringToExecute to execute the command. This solves a ton of potential problems like context switch to another document during the executing of your command, and mimics AutoCad functionality.

 

Bottom line, study up on Application Context and Document context. AutoCad helps manages context switches for you when you execute in the document context, but you are responsible for managing that if you execute in the application context, which can be a major challenge.

 

HomeBoy Out

Message 4 of 5

Thanks.

 

This ist exactly what I neede. It works.

 

Regards Jürgen

Message 5 of 5
Juergen.Becker
in reply to: HomeBoyLV

Hi,

 

I'm sure that AutoCAD locks the drawing, when we make start an command which is written in .Net wthin a specific drawing.

 

When we are using palettes AutoCAD doesn't know which drawing is meant, so we must lock it.

 

Regards Juergen

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost