Jump to content

Update edit_box tile value in a DCL box (created in LISP)


Recommended Posts

Posted

Hi,

I have created a sub function with a DCL box (written in lisp) which let the user select a point on a polyline

1607868955_PickPoint.PNG.92fa9e4c89766e6a63ed6e236d320e57.PNG

With the (hidden) edit_box, I want to inform the user if point was selected.
After the Point is selected, the function returns to the DCL Box to confirm the selected Point with the OK button.
At this point I want to change the value of the edit_box to either "The point is selected!" or the coordinate that is picked (x y z)
But I can't figure out how to update the tile

This my test code:

;;;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
;;;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 (< 1 p3)
		(setq dcl_id (load_dialog fname))
		(if (not (new_dialog "temp" dcl_id))
			(exit)
		)
		(set_tile "result" "No point selected yet!")
		(mode_tile "result" 1)
		(action_tile "pnt" "(done_dialog 3)")
		(action_tile "accept" "(done_dialog 1)")
		(setq p3 (start_dialog))
	
		(if (= 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)
				(set_tile "result" "Point is selected!") ; I thought this tile would be updated after the Point is selected?			
			)
		)
	)
	(unload_dialog dcl_id)
	(vl-file-delete fname)
	pt
)

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

	(vl-load-com)
	;;; Set Variables
	(setq snaps (getvar "OSMODE"))
	(setq echo (getvar "CMDECHO"))
	(setq curlay (getvar "CLAYER"))
	(setq angledir (getvar "ANGDIR"))
	(setq anglebase (getvar "ANGBASE"))
	(setq txtstyle (getvar "TEXTSTYLE"))
	(setq curtable (getvar "CTABLESTYLE"))
	
	(setvar "ATTREQ" 0)
	(setvar "CMDECHO" 0)
	(setvar "OSMODE" 0)
	(setvar "ANGDIR" 0)
	(setvar "ANGBASE" 0)
	(setvar "TILEMODE" 1)
	
	
	(setq p1 (PickPointBox "Specify Barge Start Block Position" "Pick a Point on Route over which the Barge moves" "Pick a Point:"))
	
	;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)
	(setvar "TEXTSTYLE" txtstyle)
	(setvar "CTABLESTYLE" curtable)
	(setvar "ATTREQ" 1)
	(princ)

)


 

I thought this command would update the tile after the Point is selected, but this is not responding at all

(set_tile "result" "Point is selected!")


What am I missing here?

 

Posted

DCL do not support say a pick point so you must close the dcl, then pick point, then reopen the dcl. I would make the dcl part a defun so can call it again and change the set_tile.

 

You need a IF around this. So after picking a point set PTPICK to say "YES".

(if (= PTPICK "NO")
(set_tile "result" "No point selected yet!")
(set_tile "result" "Point has been selected")
)

 

Will have to think about it lunch time now.

Posted

not sure if this is what you mean

;;;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
;;;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: "))
            )
           )
         )
        )
      );;; main cond
    );;; progn
  );;; while
  (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 fp fname)
  (setq fname (vl-filename-mktemp "dcl.dcl"))
  (setq fp (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;}}}") fp)
  (close fp)
  (setq p3 2)
  (while (< 1 p3)
    (setq dcl_id (load_dialog fname))
    (if (not (new_dialog "temp" dcl_id))(exit))
    ;;;*******************************************
    (if pt
      (set_tile "result" (vl-princ-to-string pt))
      (set_tile "result" "No point selected yet!")
    )
    ;;;*******************************************
      
    (mode_tile "result" 1)
    (action_tile "pnt" "(done_dialog 3)")
    (action_tile "accept" "(done_dialog 1)")
    (setq p3 (start_dialog))
    (if (= 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)
        (set_tile "result" "Point is selected!") ; I thought this tile would be updated after the Point is selected?
      )
    )
  )
  (unload_dialog dcl_id)
  (vl-file-delete fname)
  pt
)

;;;----------------------------------------------------------------------------------------------------------------------------------------
;;; Main Function
;;;----------------------------------------------------------------------------------------------------------------------------------------
	
(defun C:TEST ( / intval snaps echo txtstyle curtable pt)
  (vl-load-com)
  ;;; Set Variables
  (setq snaps (getvar "OSMODE")) (setq echo (getvar "CMDECHO")) (setq curlay (getvar "CLAYER")) (setq angledir (getvar "ANGDIR"))
  (setq anglebase (getvar "ANGBASE")) (setq txtstyle (getvar "TEXTSTYLE")) (setq curtable (getvar "CTABLESTYLE"))
  (setvar "ATTREQ" 0) (setvar "CMDECHO" 0) (setvar "OSMODE" 0) (setvar "ANGDIR" 0) (setvar "ANGBASE" 0) (setvar "TILEMODE" 1)
  (setq p1 (PickPointBox "Specify Barge Start Block Position" "Pick a Point on Route over which the Barge moves" "Pick a Point:"))
  ;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) (setvar "TEXTSTYLE" txtstyle) (setvar "CTABLESTYLE" curtable) (setvar "ATTREQ" 1)
  (princ)
)

 

:xmas:

 

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...