This looked like fun to code.
P=
Code:
;___________________________________________________________________________________________________________|
;
; Written By: Peter Jamtgaard C.E., P.E., S.E. copyright 2023 All Rights Reserved
;___________________________________________________________________________________________________________|
; Abstract: This routines demonstrates several useful aspects of the use of DCL language and dialog boxes.
; This routine allows a user to select an attribute.
; The routine finds an existing dialog box or creates a dialog box on the fly.
; It displays the dialog with the tagstring as a label and the text string as the default value.
; When the dialog is OK the attribute value is updated.
;___________________________________________________________________________________________________________|
;
; Command Line Functions for manipulating dialog boxes
;___________________________________________________________________________________________________________|
;* C:AED
;* Test Function to edit an Attribute with a dialog
;* C:AttributeEditDialog
;* Test Function to edit an Attribute with a dialog
;___________________________________________________________________________________________________________|
;
; Functions for manipulating dialog boxes, like images and list boxes.
;___________________________________________________________________________________________________________|
; Function, Arguments and Description
;* (TextEditDCLCreator)
;* Function to create a text edit dialog control file
;* (TextEditDialog strQuestion strDefault )
;* Function to present a dialog edit box
;___________________________________________________________________________________________________________|
;
; Test Function to edit an Attribute with a dialog
;___________________________________________________________________________________________________________|
(defun C:AED ()(C:AttributeEditDialog))
(defun C:AttributeEditDialog (/ entSelection lstSelection objSelection strTagString strTextString)
(if (and (setq lstSelection (nentsel "\nSelect Attribute: "))
(setq entSelection (car lstSelection))
(setq objSelection (vlax-ename->vla-object entSelection))
(setq strTextstring (vla-get-textstring objSelection))
(setq strTagString (vla-get-tagstring objSelection))
(setq strTextString (TextEditDialog (strcat "Edit Attribute <" strTagstring ">") strTextString ))
)
(vla-put-textstring objSelection strTextString)
)
)
;___________________________________________________________________________________________________________|
;
; Function to create a text edit dialog control file
;___________________________________________________________________________________________________________|
(defun DCLCreator ( / fil strDirectory strDCLFullName strFullName)
(if (and (setq strFullName (findfile "AttributeEditDialog.lsp")) ;<- Name of LISP File
(setq strDirectory (vl-filename-directory strFullName))
(setq strDCLFullName (strcat strDirectory "\\TextEdit.dcl")) ;<- Name of DCL File
)
(progn
(setq fil (open strDCLFullName "w"))
(write-line "//////////////////////////////////// Header //////////////////////////////////// " fil)
(write-line "// Developer = \"Peter\"" fil)
(write-line "// Copyright = \"2023\"" fil)
(write-line "// DCLFileName = \"EditAttribute\"" fil)
(write-line "// DateCreated = \"2023/04/21 07:59:11\"" fil)
(write-line "// Revision = \"1.0.0.1\"" fil)
(write-line "//////////////////////////////////////////////////////////////////////////////// " fil)
(write-line "" fil)
(write-line "dialog01 : dialog {" fil)
(write-line " label = \" Edit Attribute\";" fil)
(write-line " : boxed_row {" fil)
(write-line " height = 1.0;" fil)
(write-line " width = 20.0;" fil)
(write-line " key = \"boxed_row01\";" fil)
(write-line " : text_part {" fil)
(write-line " fixed_width_font = true;" fil)
(write-line " height = 1.2;" fil)
(write-line " key = \"text_part01\";" fil)
(write-line " value = \" Tagstring\";" fil)
(write-line " width = 20.0;" fil)
(write-line " }" fil)
(write-line " : column {" fil)
(write-line " height = 1.0;" fil)
(write-line " width = 20.0;" fil)
(write-line " key = \"column01\";" fil)
(write-line " : edit_box {" fil)
(write-line " allow_accept = true;" fil)
(write-line " fixed_width_font = true;" fil)
(write-line " height = 1.0;" fil)
(write-line " key = \"edit_box01\";" fil)
(write-line " width = 20.0;" fil)
(write-line " }" fil)
(write-line " : spacer {" fil)
(write-line " height = 0.2;" fil)
(write-line " key = \"spacer01\";" fil)
(write-line " width = 20.0;" fil)
(write-line " }" fil)
(write-line " }" fil)
(write-line " }" fil)
(write-line " ok_cancel;" fil)
(write-line "}" fil)
(close fil)
)
)
T
)
;___________________________________________________________________________________________________________|
;
; Function to present a dialog edit box
;___________________________________________________________________________________________________________|
(defun TextEditDialog (strQuestion
strDefault
/
id
)
(or (findfile "TextEdit.dcl")
(TextEditDCLCreator )
)
(setq id (load_dialog "TextEdit.dcl"))
(new_dialog "dialog01" id)
(set_tile "text_part01" strQuestion)
(set_tile "edit_box01" strDefault)
(action_tile "edit_box01" "(setq strDefault $value)")
(mode_tile "edit_box01" 0)
(mode_tile "edit_box01" 2)
(if (= (start_dialog) 1)
strDefault
)
)
(princ "!")
(vl-load-com)