Entmake crashing when called from palette

Entmake crashing when called from palette

JamesMaeding
Advisor Advisor
757 Views
2 Replies
Message 1 of 3

Entmake crashing when called from palette

JamesMaeding
Advisor
Advisor

I have narrowed things down a bit from previous posts, so am starting a new one.

I did a clean example project using VS 2013 express, and acad 2015 to replicate the issue reliably.

Its actually a useful example project for anyone wanting to make a program with a palette.

 

Unzip the attached file, start the solution with VS 2013, and run in debug.

My debug path has acad 2015, but anyone could modify that and the references to use any acad version.

Once acad opens, load the LispNeeded.lsp, and run TestPal command.

Click the button on the palette.

Then zoom a bit to see the circle, then regen the drawing.

Click the button again and you get the elock error.

 

I badly need to know if this is some fundamental incompatibility with palettes, which are modeless, or fixable.

I have tons of code that uses entmake so would prefer to port that as I have time, not all now.

Thanks for any help, including the ADN guys.


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

0 Likes
Accepted solutions (1)
758 Views
2 Replies
Replies (2)
Message 2 of 3

Jeff_M
Consultant
Consultant
Accepted solution

James, Palettes are modeless. Therefor you need to Lock the document when performing tasks from them. Adding a Using {} block around your code allows it to run without error.

 

            using (DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
            {
                ResultBuffer args = new ResultBuffer();
                args.Add(new TypedValue(5005, "C:TestEntmake"));
                args.Add(new TypedValue(5005, "abc"));
                int stat = 0;
                ResultBuffer ret = ProgPal.InvokeLisp(args, ref stat);
                Debug.Print("done");
            }

 

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 3

JamesMaeding
Advisor
Advisor

Thanks Jeff!

I knew in my head it was a locking issue, but thought doc locks only applied to transactions, and I am doing old school (as in Maximizing AutoLisp book) entmakes.

You have no idea how happy I am the lisp calls are working now. I might even be nice to Autodesk the rest of the day now Smiley Happy


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

0 Likes