Jump to content

Recommended Posts

Posted

Hi,

 

I have programmed in LISP a DCL box a which allows the user to pick a point on a polyline. (This is part of a larger LISP routine)


image.png.648b511aaad58890b8a28563fd95a32e.png

 

;;;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
;;;Subfunction to Select Route (Polyline)
;;;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
(defun route ()
	(while
		(progn
			(setvar 'errno 0)
			(setq ob (entsel (strcat "\nSelect Pipeline or Cable Route: ")))
			(cond
				((= 7 (getvar 'errno))
					(princ "\nMissed, try again.")
				)
				((= 'ename (type (car ob)))
					(cond
						((/= "LWPOLYLINE" (cdr (assoc 0 (entget (car ob)))))
							(cond
								((= "POLYLINE" (cdr (assoc 0 (entget (car ob)))))
									(progn
										(command "_.CONVERTPOLY" "_Light" ob "")
										(princ "\nPOLYLINE is converted to a LWPOLYLINE please select again: ")
									)
								)
								((/= "POLYLINE" (cdr (assoc 0 (entget (car ob)))))
									(princ "\nPlease select a LWPOLYLINE: ")
								)
							)
						)
					)
				)
			)
		)
	)
	(princ)
)

;;;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
;;; Pick Point Box DCL to Pick a Point on Route over which the Barge moves
;;;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

(defun PickPointBox ( title subtitle txt / obj ob pt dcl_id fn fname)
	(setq fname (vl-filename-mktemp "dcl.dcl"))
	(setq fn (open fname "w"))
	(write-line
		(strcat
			"temp : dialog { label = \"" title "\";: boxed_column { fixed_width = true; width = 45; label = \"" subtitle "\";: spacer { height = 1; }: row { fixed_width = true;: text { label = \"" txt "\";}"
			": button {label = \"Pick <\";key = \"pnt\";width = 12;alignment = right;}: spacer { width = 1; }: edit_box { key = \"result\";edit_width = 20;alignment = right;}}: spacer { height = 1; }}"
			": row { fixed_width = true;: button { key = \"accept\"; label = \"OK\";is_default = true; fixed_width = true; alignment = left;}}}"
		)		
		fn
	)
	
	(close fn)

	(setq p3 2)
	(while (>= p3 2)
		(setq dcl_id (load_dialog fname))
		(if (not (new_dialog "temp" dcl_id))
			(exit)
		)
		
		;Set tiles
		(set_tile "result" "No point selected yet!")
		(mode_tile "result" 1)
		
		;;;--- If an action event occurs, do this function
		(action_tile "pnt" "(done_dialog 3)")
		(action_tile "accept" "(done_dialog 1)")
		
		(setq p3 (start_dialog))	
		(cond
			((= p3 3)
			;(progn
				(route)
				(setq obj (vlax-ename->vla-object (car ob)))
				(setvar "osmode" 3)
				(setq pt (getpoint "\nPick Point on Route: \n"))
				(if (= nil (vlax-curve-getParamAtPoint obj pt))
					(setq pt (getpoint "\nSelected Point not on Route, please Pick Point on Route again: \n"))
				)
				(setvar "osmode" 0)
				
				; Update tile value
				(set_tile "result" "Point is selected!")
			)
		)
	)
	(unload_dialog dcl_id)
	(vl-file-delete fname)
	pt
)

;;;----------------------------------------------------------------------------------------------------------------------------
;;; Main Function
;;;----------------------------------------------------------------------------------------------------------------------------
	
(defun C:TEST ( / p1 )

	(vl-load-com)
	;;; Set Variables
	(setq snaps (getvar "OSMODE"))
	(setq echo (getvar "CMDECHO"))
	
	(setvar "CMDECHO" 0)
	(setvar "OSMODE" 0)
	(setvar "TILEMODE" 1)
		
	;;To prevent that the user selects OK before a point is picked a while
	(while (= p1 nil)
		(setq p1 (PickPointBox "Specify Barge Start Block Position" "Pick a Point on Route over which the Barge moves" "Pick a Point:"))
	)	
	
	(print p1)
	
	;;;--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	(setvar "CLAYER" "0")

	; Restore Variables
	(setvar "OSMODE" snaps)
	(setvar "CMDECHO" echo)
	(princ)
)



I want to show the user, after the point is picked and before OK is hit, the result in the "greyed out" Textbox.

For now this is (set_tile "result" "Point is selected!").
I don't get any errors during execution, but the tile is not updated...

 

What am I doing wrong here?


 

Posted

The dcl come out as one line. not saying that's the problem but its hard to read.

 

https://autolisp-exchange.com/Tutorials/MyDialogs.htm#MyPickButton

look how they update the dcl here.

 

(write-line "MyPickButton : dialog {" fo)
(write-line "  key = \"Title\";" fo)
(write-line "  label = \"\";//Title$ from lsp file" fo)
(write-line "  spacer;" fo)
(write-line "  : row {" fo)
(write-line "    : column {" fo)
(write-line "      fixed_width = true;" fo)
(write-line "      : row {" fo)
(write-line "        : column {" fo)
(write-line "          spacer;" fo)
(write-line "          : image_button {" fo)
(write-line "            key = \"select_pick\";" fo)
(write-line "            width = 3.59;" fo)
(write-line "            height = 1.66;" fo)
(write-line "            fixed_width = true;" fo)
(write-line "            fixed_height = true;" fo)
(write-line "            aspect_ratio = 1;" fo)
(write-line "            color = -15;" fo)
(write-line "          }" fo)
(write-line "          spacer;" fo)
(write-line "        }" fo)
(write-line "        : column {" fo)
(write-line "          spacer;" fo)
(write-line "          : text {" fo)
(write-line "            key = \"Prompt\";" fo)
(write-line "            label = \"\";" fo)
(write-line "            width = 31.09;" fo)
(write-line "            fixed_width = true;" fo)
(write-line "            vertical_margin = none;" fo)
(write-line "          }" fo)
(write-line "          spacer;" fo)
(write-line "        }" fo)
(write-line "      }" fo)
(write-line "    }" fo)
(write-line "  }" fo)
(write-line "  : boxed_column {" fo)
(write-line "    label = \"Object Information\";" fo)
(write-line "    width = 34.26;" fo)
(write-line "    fixed_width = true;" fo)
(write-line "    : paragraph {" fo)
(write-line "      : text_part {" fo)
(write-line "        key = \"Text1\";" fo)
(write-line "        label = \"\";//Text1$ from lsp file" fo)
(write-line "      }" fo)
(write-line "      : text_part {" fo)
(write-line "        key = \"Text2\";" fo)
(write-line "        label = \"\";//Text2$ from lsp file" fo)
(write-line "      }" fo)
(write-line "      : text_part {" fo)
(write-line "        key = \"Text3\";" fo)
(write-line "        label = \"\";//Text3$ from lsp file" fo)
(write-line "      }" fo)
(write-line "    }" fo)
(write-line "    spacer;" fo)
(write-line "  }" fo)
(write-line "  spacer;" fo)
(write-line "  ok_only;" fo)
(write-line "}" fo)

 

Posted
  On 1/12/2023 at 12:56 PM, mhupp said:

The dcl come out as one line. not saying that's the problem but its hard to read.

 

https://autolisp-exchange.com/Tutorials/MyDialogs.htm#MyPickButton

look how they update the dcl here.

 

(write-line "MyPickButton : dialog {" fo)
(write-line "  key = \"Title\";" fo)
(write-line "  label = \"\";//Title$ from lsp file" fo)
(write-line "  spacer;" fo)
(write-line "  : row {" fo)
(write-line "    : column {" fo)
(write-line "      fixed_width = true;" fo)
(write-line "      : row {" fo)
(write-line "        : column {" fo)
(write-line "          spacer;" fo)
(write-line "          : image_button {" fo)
(write-line "            key = \"select_pick\";" fo)
(write-line "            width = 3.59;" fo)
(write-line "            height = 1.66;" fo)
(write-line "            fixed_width = true;" fo)
(write-line "            fixed_height = true;" fo)
(write-line "            aspect_ratio = 1;" fo)
(write-line "            color = -15;" fo)
(write-line "          }" fo)
(write-line "          spacer;" fo)
(write-line "        }" fo)
(write-line "        : column {" fo)
(write-line "          spacer;" fo)
(write-line "          : text {" fo)
(write-line "            key = \"Prompt\";" fo)
(write-line "            label = \"\";" fo)
(write-line "            width = 31.09;" fo)
(write-line "            fixed_width = true;" fo)
(write-line "            vertical_margin = none;" fo)
(write-line "          }" fo)
(write-line "          spacer;" fo)
(write-line "        }" fo)
(write-line "      }" fo)
(write-line "    }" fo)
(write-line "  }" fo)
(write-line "  : boxed_column {" fo)
(write-line "    label = \"Object Information\";" fo)
(write-line "    width = 34.26;" fo)
(write-line "    fixed_width = true;" fo)
(write-line "    : paragraph {" fo)
(write-line "      : text_part {" fo)
(write-line "        key = \"Text1\";" fo)
(write-line "        label = \"\";//Text1$ from lsp file" fo)
(write-line "      }" fo)
(write-line "      : text_part {" fo)
(write-line "        key = \"Text2\";" fo)
(write-line "        label = \"\";//Text2$ from lsp file" fo)
(write-line "      }" fo)
(write-line "      : text_part {" fo)
(write-line "        key = \"Text3\";" fo)
(write-line "        label = \"\";//Text3$ from lsp file" fo)
(write-line "      }" fo)
(write-line "    }" fo)
(write-line "    spacer;" fo)
(write-line "  }" fo)
(write-line "  spacer;" fo)
(write-line "  ok_only;" fo)
(write-line "}" fo)

 

Expand  


Yeah I know....this is not the only DCL I use in my main LISP routine. I have 5 or 6 DCL's....this is why I try to program them in LISP and not as separate DCL files
If I write each DCL row in the main LISP routine, the total amount of rows is huge.


I will check you link thanx!
 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...