AutoCAD commands from modeless forms

Started by ScottBolton, December 31, 2015, 08:59:35 AM

Previous topic - Next topic

ScottBolton

Hello, and Happy New Year to those east of me!

I have a modeless form with an OptionList. As each option is pressed I want to insert different blocks into the drawing.

Using Modeless.lsp as a guide I used this code:

Code (autolisp) Select
(defun c:bTscore/Form1/key#OnSelChanged (ItemIndexOrCount Value /)
  (dcl-Form-Enable bTscore/Form1 nil)
  (c:test)
  (dcl-Form-Enable bTscore/Form1 T)
  )


If I use,

Code (autolisp) Select
(defun c:test ()
  (command "_insert" "block1" '(0 0 0) 1 1 0)
  )


I get the following error: ; error: invalid AutoCAD command: nil

And if I use,

Code (autolisp) Select
(defun c:test ()
  (entmake '((0 . "INSERT") (100 . "AcDbEntity") (8 . "0") (62 . 250) (100 . "AcDbBlockReference") (2 . "block1") (10 0.0 0.0 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0)))
  )


AutoCAD crashes with a fatal error.

What am I doing wrong?

Tharwat

Hi,

Close AutoCAd then change the property of EventInvoke to 1-Asynchronous to the button or the tool you use to insert the block.
I hope this would work.

ScottBolton