Jump to content

Recommended Posts

Posted

Might be a silly question but is there a way I can add a textbox in the CUI so the user can type in text height and then this input will be read by the other lisps?

Posted (edited)

You can have lisp in a CUI I have set a variable then load a lisp using that variable.

Simple answer

^c^C^p(setvar 'textsize (getreal "\nEnter text height "))(load "mylisp")

 

There is a textbox input trying to remember it someone else will post. It is a built in function.

 

Or can do something like this, another DCL example is at Afralisp.

^c^c^p(if (not AH:getvalsm)(load "Multi Getvals.lsp"))(setq ans (AH:getvalsm (list "Enter text height " "height" 5 4 "2.5")))(load "mylisp")

image.png.2ba9ba402995041b4a8dbfda11ac7520.pngMulti GETVALS.lsp

Edited by BIGAL
  • Thanks 1
  • 3 weeks later...
Posted

Thank you so much! Managed to create a dropdown list that you select between existing and proposed and sets a variable to "Existing" or "Proposed" and amended the lisp to read the Global Variable! This is so handy, but feels it can be a pain to maintain but definitely sped up my workflow thank you!

Posted

Hi @CivilTechSource,

 

Here is the an example how you can do it on different approach. In AutoCAD exist "blackboard", where you can store the desired value where you can than use that value in the other open drawings (more about blackboard: About Sharing Data Between Namespaces (AutoLISP)).

 

In this example, I have a "text size values.txt" file with different heights. It can be update with other height values.

 

1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0

 

So, after run this function, you will first choose the file with values (in this case "text size values.txt"), than pick the desired value and add it to blackboard.

 

(prompt "\nCall function: (getValueFromListBlackboard)")
(princ)

;; Add any value from list to the "blackboard"

(defun getValueFromListBlackboard ( / *dcl_id* *file_name*  *op* *lst* *textSize* *path* *file* *line* *rval*)
  
  (setq *path* (getfiled "Open the txt file with list of values"" "txt" 0)
	*file* (open *path* "r")
	)
  
  (if *file*
    
    (progn
      
      (while (setq *line* (read-line *file*))
	(setq *lst* (append *lst* (list *line*)))
	
	)
      
      (close *file*)
      
      )
    )
  
  (setq *file_name* (vl-filename-mktemp "textHeight.dcl")
	*op* (open *file_name* "w")
	)
  
  (write-line "textHeight

  :dialog {

  label = \"Select Text Heights\";
	:list_box {
	   key = \"tx\";
	   multiple_select = true;
	   height = 20;
	   width = 30;
}
   :row {

    :button {

    	label = \"Pick text height\";
    	key = \"bth\";
    	fixed_width = true;

    	}

    :button {

        label = \"Cancel\";
        key = \"cancel\";
        mnemonic = \"C\";
        alignment = centered;
        fixed_width = true;
        is_cancel=true;

        }
    }
}"
    *op*)
  
  (close *op*)
  
  (setq *dcl_id* (load_dialog *file_name*))
  
  (if (not (new_dialog "textHeight" *dcl_id*))
    (exit)
    )
  
  (action_tile "cancel" "(done_dialog 0)")
  
  (start_list "tx")
  
  (mapcar 'add_list *lst*)
  
  (end_list)
  
  (defun return_value ()
    
    (setq *rval* (nth (atoi (get_tile "tx")) *lst*))
    
    )
  
  (action_tile "bth" "(return_value) (done_dialog 1)")
  
  (start_dialog)
  
  (unload_dialog *dcl_id*)
  
  (vl-file-delete *file_name*)
  
  (vl-bb-set '*textSize* *rval*)

  (vl-bb-ref '*textSize*)
  
  )

 

After you pick the desire height, you can change it in all open drawings for any text. In this case, I made a little lisp for that and I need it to call every time in different drawing (except if you don't want to make it in support file search path or to be autoloaded every time when AutoCAD is started).

 

(defun c:CTH ( / data)
  
  (setq data (entget (car (entsel "\nSelect the text:"))))
  
  (entmod (subst (cons 40 (atof (vl-bb-ref '*textSize*))) (assoc 40 data) data))
  
  )

 

An example video of how it works you can see below.

 

 

Maybe in this you can get some idea how to make it work in your case. Also, you can add "getValueFromListBlackboard" to CUI and make it easier to call.

 

Best regards.

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