Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/28/2025 in all areas

  1. Nikon, I'd consider adding a check that a suitable text was selected, quick and dirty like this: ;;Loop till a mtext is selected. (while (not (equal (assoc 0 (entget (setq MyEnt (car (entsel "Select Mtext"))))) '(0 . "MTEXT") )) (princ "\nNo, Please ") ) Though of course if no mtext can be selected or the user changes their mind escape is the only way out so be wary of variables and error functions if needed. If the text strings are always short (under 250 characters) your code can be shortened to something like this I think. The second ssget you can use a wildcard "*TEXT" to get all text types. (defun c:test ( / ) ;;Loop till a mtext is selected. (while (not (equal (assoc 0 (entget (setq MyEnt (car (entsel "Select Mtext"))))) '(0 . "MTEXT") )) (princ "\nNo, Please ") ) ;;get text string. Assuming the search text is less than 250 characters else use another method (setq MyText (cdr (assoc 1 (entget myent)))) ;;get a selection set. Again assuming text strings less then 250 characters. (princ "\nNow select texts to search: ") (setq MySS (ssget (list (cons 0 "MTEXT")(cons 1 (strcat "*" MyText "*"))))) ;; do what you want here with MySS (princ) ) a slight different take on yours for longer texts which should work for LT too (defun c:test ( / MyText MySS FinalSS acount) ;;Loop till a mtext is selected. (while (not (equal (assoc 0 (entget (setq MyEnt (car (entsel "Select Mtext"))))) '(0 . "MTEXT") )) (princ "\nNo, Please ") ) (setq MyText (cdr (assoc 1 (entget myent)))) ;; selected text string ;;Get the texts to search. (princ "\nNow select texts: ") (setq MySS (ssget (list (cons 0 "*TEXT")))) ;; Loop through texts adding to selection set where text is found (setq acount 0) (setq FinalSS (ssadd)) (while (< acount (sslength MySS)) (setq MyEnt (entget (ssname MySS acount))) (if (or (wcmatch (strcase (cdr (assoc 1 MyEnt))) (strcat "*" (strcase Mytext) "*" )) ;; last 250 characters (if (cdr (assoc 3 MyEnt))(progn (wcmatch (strcase (cdr (assoc 3 MyEnt))) (strcat "*" (strcase Mytext) "*" )) ;; first 250 characers (wcmatch (strcase (cdr (assoc 3 MyEnt))) (strcat "*" (strcase Mytext) "*" )) ;; Middle 250 characters )) ; end if, end progn assoc 3 ) ; endor (progn ;; found (setq FinalSS (ssadd (ssname MySS acount) FinalSS) ) ) (progn ;; not found ) ) ; end if (setq acount (+ acount 1)) ) ; end while ;; do what you want here with found texts FinalSS )
    2 points
  2. Create all dcl files in a folder that's part of your support path. I assume the dcl name follows the lisp name so if your lsp is named "MyLsp_01.lsp" your dcl is name "MyLsp_01.dcl". All my lsp's are saved in c:\temp\lisp\. So when you write your dcl the code would be something like : (if (and (setq fn "c:\temp\lisp\MyLsp_01.dcl") (setq fp (open fn "w")) (write-line (strcat ....) fp)) I believe there is a max to how long a string can be so I always put the lines in a list and write them seperately. After you close your filepointer use command (GC) , that is garbage collection and flushes your cache. Your vlx migh be too fast and try to load your dcl before it was saved. when loading dcl , you could use something like (if (setq dcl-fn (findfile "MyLsp_01.dcl")) ...
    1 point
  3. Did you google ? There are plenty of examples out there. They usually dimension all segments but they could be simply modified to do only start and end segments. "dimension polylines autocad lisp"
    1 point
  4. Findstring may be your friend, its a window cmd you type cmd down left to go to command mode of windows. I have a bat file setup so type "fnd Ahgetvalsm" it goes to my lisp directory then runs this command. Findstring ahgetvalssm *.lsp It looks through all my lsp files for a match so in your case look into *.dcl for a dialog name if it comes up with two then you have a problem. Yes no quick way to get each dialog name. As suggested by @Steven P you could open every file lsp & dcl and reading a line at a time, look for "dialog" and save that line file name to a list when found. I guess then can run bat files from lisp so use Findstring.
    1 point
  5. Select all the text and mtext at once, you can use a wildcard in 'ssget',* (defun c:selecttxt ( / MySS) (setq MySS (ssget "_X" (list '(0 . "*TEXT")))) )
    1 point
  6. As suggested I forgot about this , use a check layer. Can be called very simply. ((= MHState "Adoptable") (princ "\nYou selected Adoptable.")(chklayer "Adoptable pits" 1 "Dashed") (setq MHS 1)) checks for the layer name and color. (defun chklay (lay col lt / ) (if (not (tblsearch "LAYER" lay)) (command "-layer" "m" lay "c" col lay "lt" lt lay "") (setvar 'clayer lay) ) (princ) )
    1 point
×
×
  • Create New...