See the top rated post in this thread. Click here

Results 1 to 3 of 3

Thread: How to change TagString to (prompt) in DCL title

  1. #1
    Woo! Hoo! my 1st post
    Join Date
    2018-07
    Posts
    1
    Login to Give a bone
    0

    Default How to change TagString to (prompt) in DCL title

    please, I need a support how to change TagString to (prompt) in dcl Title.
    label = "Edit Attribute <TagString>";"

  2. #2
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    555
    Login to Give a bone
    1

    Default Re: How to change TagString to (prompt) in DCL title

    You would have to write a dcl each time you run program so get tagstring 1st, for more experienced coder now code the dcl in the master lisp so take advantage of vl-filename-mktemp
    (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
    If you have a dcl you can use this by Rlx to convert a dcl to lisp.

    Code:
    ; LispWrapperForDCL
    ; RLX - 25 Jan 2019 - just another luchtime fun
    
    (defun C:test ( / *error* src Sdes lsp Ddes row L tmp )
      
      (defun *error* ( m )
        (and (eq 'FILE (type Sdes)) (close Sdes))
        (and (eq 'FILE (type Ddes)) (close Ddes))
        (and (eq 'STR (type lsp)) (findfile lsp) (vl-file-delete lsp))
        (and m (princ m)) (princ)
      ); defun *error*
      
      (cond 
        ( (not (setq src (getfiled "Specify DCL file" (strcat (getenv "userprofile") "\\Desktop\\") "dcl" 16))) (prompt "\nDCL file not specified.") )
        ( (not (setq Sdes (open src "R"))) (prompt "\nUnable to open the DCL file for reading.") )
        (
          (not
            (princ ""
              (setq Ddes
                (open
                  (setq lsp
                    ( (lambda (s / i tmp) (setq i 0) (while (findfile (setq tmp (strcat s "_" (itoa i) ".lsp"))) (setq i (1+ i))) tmp)
                      (apply (function (lambda (a b c) (vl-string-translate "/" "\\" (strcat a b)))) (fnsplitl src)) 
                    )
                  ); setq lsp
                  "W"
                ); open
              ); setq Ddes
            ); princ
          ); not 
          (if lsp 
            (prompt (strcat "\nUnable to open '" lsp "' for writing."))
            (prompt "\nUnable to generate the '.lsp' file.")
          )
        )
        (t
          ;|
          (while (setq row (read-line Sdes)) 
            (write-line 
              (if (/= "" row) 
                (vl-list->string (append '(34) (apply 'append (subst '(92 34) '(34) (mapcar 'list (vl-string->list row)))) '(34)))
                row
              ); if
              Ddes
            ); write-line
          ); while 
          |;
          
          (while (setq row (read-line Sdes)) 
            (setq L
              (cons
                (if (/= "" row) 
                  (vl-list->string (append '(34) (apply 'append (subst '(92 34) '(34) (mapcar 'list (vl-string->list row)))) '(34)))
                  ; (vl-list->string (append '(34) (vl-string->list row) '(34)))
                  row
                ); if
                L
              )
            ); L
          ); while 
          (setq L (reverse L))
          
          
          (foreach x 
            '("(defun C:test_LispWrapperForDCL ( / *error* dcl des dch dcf )" 
              (defun *error* ( m )
                (and (< 0 dch) (unload_dialog dch))
                (and (eq 'FILE (type des)) (close des))
                (and (eq 'STR (type dcl)) (findfile dcl) (vl-file-delete dcl))
                (and m (princ m)) (princ)
              ); defun *error*
              "(and"
              (setq dcl (vl-filename-mktemp nil nil ".dcl")) 
              (setq des (open dcl "W"))
              "(progn"
              "(foreach x " L
              (write-line x des)
              "); foreach"
              "T"
              "); progn"
              (not (setq des (close des)))
              (setq dch (load_dialog dcl))
              (new_dialog "test" dch)
              (= 1 (setq dcf (start_dialog)))
              "); and"
              (*error* null) ; <- use "null" instead of "nil", else its buggy!
              (princ)
              "); defun"
            ); list
            (cond 
              ( (eq 'STR (type x)) 
                (and (setq tmp (vl-string->list x)) (not (apply '= (cons 32 tmp))) (write-line x Ddes) )
              )
              ( (= x 'L) (foreach x (append '("'(") (eval x) '(")")) (write-line x Ddes)) )
              ( (vl-consp x) 
                (princ "(" Ddes)
                (foreach x (list (car x) (cadr x) (caddr x))
                  (if x
                    (princ (strcat (strcase (vl-prin1-to-string x) t) " ") Ddes)
                  )
                ) 
                (mapcar '(lambda (x) (write-line (strcase (vl-prin1-to-string x) t) Ddes)) (cdddr x))
                (write-line ")" Ddes)
              )
            )
          ); foreach 
          
          ((lambda (L) (mapcar 'set L (mapcar 'close (mapcar 'eval L)))) '(Sdes Ddes))
          
          (
            (lambda ( fpath / shell )
              (if fpath
                (vl-catch-all-apply
                  (function
                    (lambda nil
                      (setq shell (vlax-get-or-create-object "Shell.Application"))
                      (vlax-invoke-method shell 'Open fpath)
                    )
                  )
                )
              )
              (vl-catch-all-apply 'vlax-release-object (list shell))
            )
            lsp
          )
          (load lsp)
          (if C:test_LispWrapperForDCL 
            (C:test_LispWrapperForDCL)
            (alert "Unable to define the generated lisp!")
          )
          (setq lsp nil)
          
        ); t
      )
      (*error* nil) (princ)
    ); defun
    Look at this example
    Attached Files Attached Files

  3. #3
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,106
    Login to Give a bone
    0

    Default Re: How to change TagString to (prompt) in DCL title

    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)
    Attached Files Attached Files
    AutomateCAD

Similar Threads

  1. Replies: 1
    Last Post: 2012-08-28, 11:54 PM
  2. Title Block with wrong prompt
    By nybecc in forum Dynamic Blocks - Technical
    Replies: 1
    Last Post: 2010-01-15, 07:58 AM
  3. Attribute textstrings by Tagstring
    By CADfunk MC in forum VBA/COM Interop
    Replies: 6
    Last Post: 2010-01-07, 10:29 AM
  4. DCL - Button that would pick a point in AutoCAD in DCL
    By katkinson0082914 in forum AutoLISP
    Replies: 3
    Last Post: 2006-06-09, 12:19 PM
  5. Cannot change "Title" Description on Title Block!
    By Cosmic Traveller in forum Inventor - General
    Replies: 4
    Last Post: 2005-11-30, 05:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •