Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Contributor
r-t-design
Posts: 18
Registered: ‎03-23-2004
Message 1 of 4 (278 Views)

dialog causes lockup

278 Views, 3 Replies
03-25-2012 12:44 PM

new to the dialog boxes. Been trying a routine and failing. Can't figure out why.
The routine opens the dialog, which should allow me to pick 1 out of 3 blocks to instert and to define the scale of the block, text to be inputed, and the text style to be used. The idea was planed to first define defaults for the dialog. Once the dialog is opened I could change or except the defaults. It should then insert the selected block and print the text. If the lisp file is executed a second time it should use the last values used as the defaults. So far all I can do is call up the dialog box, change my inputs or leave them as default, but once I select OK autocad locks up.

 

tree.dsl file

tree : dialog {
label = "Tree Style Insert";
  : row {
	: boxed_column {
	label = "Type of Tree to Insert";
		: radio_column {
			: radio_button {
				label = "Pine";
				key = "pine";
				mnemonic = "P";
			}
   	     		: radio_button {
				label = "Oak";
				key = "oak";
				mnemonic = "O";
			}
			: radio_button {
				label = "Juniper";
				key = "juniper";
				mnemonic = "J";
			}
		}
	}
	: boxed_column {
		: edit_box {
			label = "Scale of Tree";
			key = "scl";
			mnemonic = "S";
			edit_width = 7;
		}
		: edit_box {
			label = "Text for Tree";
			key = "txt";
			mnemonic = "T";
			edit_width = 7;
		}
		: edit_box {
			label = "Text Style";
			key = "ts";
			mnemonic = "X";
			edit_width = 7;
		}
	}
  }
  ok_cancel;
}

 

tree.lsp file

 

(defun c:tree (/ dcl_id)
  (setq dcl_id (load_dialog "tree.dcl"))
  (if  (not (new_dialog "tree" dcl_id))
    (exit)
  )
  (if (= loop nil)(setdef)(setdef2))
  (action_tile "accept" "(setvals) (done_dialog)")
  (start_dialog)
  (princ)
)

;;; Sets defaults ;;;
(defun setdef ()
  (setq tree "pine"
	tscl 12
	ttxt 12  ;(strcat "12" (chr 34))
	tts "DIM")
  (set_tile "pine" "1")
  (set_tile "scl" (rtos 12 2 0))
  (set_tile "txt" "12");(strcat "12" (chr 34)))
  (set_tile "ts" "DIM")
  (princ)
)

;;;  ReDefine Defaults ;;;
(defun setdef2 ()
  (setq txt (strcat "12" (chr 34)))
  (if (= tree "pine")(set_tile "pine" "1"))
  (if (= tree "oak")(set_tile "oak" "1"))
  (if (= tree "juniper")(set_tile "juniper" "1"))
  (set_tile "scl" (rtos tscl 2 0))
  (set_tile "txt" ttxt)
  (set_tile "ts" tts)
  (princ)
)

;;; Sets values and inserts ;;;
(defun setvals ()
  (action_tile "pine" "(setq tree $key)")
  (action_tile "oak" "(setq tree $key)")
  (action_tile "juniper" "(setq tree $key)")
  (setq tscl (atof (get_tile "scl")))
  (setq ttxt (get_tile "txt"))
  (setq tts (get_tile "ts"))
  (command "insert" tree "s" tscl pause "")
  (command "text" "s" tts pause "" ttxt)
  (setq loop 1)
  (princ)
)

 



as a note, tree.lsp file in in c:/program files/autocad.../lispfile folder, which is called to in autocad. it is where all my lisp files are stored and autoloaded from. and the tree.dcl file is in the Express folder. I originally saved it in the Lispfile folder, but for some reason it would not load from there, but did load once I saved it to the Express folder. But now it crashed all the time. I even tried putting tree.lsp file in the Express folder, but did not change the results. Still crashed.

Mentor
devitg
Posts: 1,704
Registered: ‎03-14-2004
Message 2 of 4 (270 Views)

Re: dialog causes lockup

03-25-2012 04:18 PM in reply to: r-t-design
Please upload a the sample dwg , in ACAD2008 or less
Valued Mentor
martti.halminen
Posts: 334
Registered: ‎12-31-2009
Message 3 of 4 (261 Views)

Re: dialog causes lockup

03-26-2012 12:19 AM in reply to: r-t-design

Looks like you are missing quotation marks in the line

	ttxt 12  ;(strcat "12" (chr 34))

 

SET_TILE expects strings, not integers.

 

--

 

Contributor
r-t-design
Posts: 18
Registered: ‎03-23-2004
Message 4 of 4 (244 Views)

Re: dialog causes lockup

03-26-2012 10:47 AM in reply to: r-t-design

Yes I missed that one.  Final line reads (setq ttxt "12\"").  thanks for that

 

Here is a sample of the tree dwg.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.