Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/23/2025 in all areas

  1. I'll update all of this to also allow you to enter the initial reference number from the keyboard, as @Nikon wanted. I'll post it soon.
    2 points
  2. Hi In this new version, it's possible to enter the text before the first text you want to insert from the keyboard or, as before, select it on the screen. Additionally, it will now increment numeric, alphabetic, or alphanumeric text strings without any restrictions (except for non-alphanumeric characters, of course). @leonucadomi As for your suggestion to extend the code's functionality to block attributes, I may do something about this in the future. However, I'm sure there must be simpler routines that would do the job just as well. There are several block experts on this forum who will probably have something to say about this. But if not, I'll try to do it myself. ;************************ G L A V C V S ************************* ;************************** F E C I T *************************** (defun c:txtIncrem (/ tam capa ind para a c cl txsel le l s dameTexto obtcad ent loc tipC nC ps add errores error0 ) (defun errores (mens) (setq *error* error0) (prin1) ) (defun dameTexto (cad / v r l daleVuelta) ;;; WRITE HERE THE CODE YOU NEED TO CUSTOMIZE THE TEXT YOU WANT TO ENTER OR CREATE (defun daleVuelta (a) (cond ((and (> a 64) (< a 91)) (if (> (setq a (+ a 1)) 90) (setq a -65) a)) ((and (> a 96) (< a 123)) (if (> (setq a (+ a 1)) 122) (setq a -97) a)) ((and (> a 47) (< a 58)) (if (> (setq a (+ a 1)) 57) (setq a -48) a)) ) ) (foreach v (reverse (vl-string->list cad)) (if (or (not r) (minusp r)) (setq l (cons (abs (setq r (daleVuelta v))) l)) (setq l (cons v l)) ) ) (vl-list->string (if (minusp r) (cons (if (= r -48) 49 (car l)) l) l)) ) (setq error0 *error* *error* errores ) (princ (setq s "Select PREVIOUS number text or type it... ")) (while (not para) (setq l (grread T 13 2)) (if (not (listp (cadr l))) (if (member (car l) '(2 3 11 25)) (cond ((or (= (cadr l) 13) (= (car l) 25)) (if (and c (not (wcmatch c "*.*"))) (setq ind c para T) (if (not c) (setq para T)) ) ) ((> (cadr l) 31) (setq c (if c (strcat c (chr (cadr l))) (chr (cadr l)))) (prompt (strcat "\r" s c)) ) ((= (cadr l) 8) (if (setq c (if c (substr c 1 (- (strlen c) 1)))) (prompt (strcat "\r" s c)) ) ) ) ) (if (= (car l) 3) (if (and (setq e (nentselp (cadr l))) (= (cdr (assoc 0 (setq le (entget (setq e (car e)))))) "TEXT")) (if (not (wcmatch (setq ind (cdr (assoc 1 le))) "*.*")) (setq capa (cdr (assoc 8 le)) a (cdr (assoc 40 le)) cl (cdr (assoc 62 le)) para T) (princ "\n*** The selected object is not valid. Please, try again... ***") ) ) ) ) ) (setq para nil) (if (not capa) (while (not para) (if (and (setq e (car (entsel "\nLAYER/HEIGHT: Select a sample text object (ENTER or RIGHT CLICK to type it)... "))) (setq l (entget e)) ) (if (= (cdr (assoc 0 l)) "TEXT") (setq capa (cdr (assoc 8 l)) a (cdr (assoc 40 l)) para T) (princ "\n*** The selected object is not a TEXT. Please, try again... ***") ) (if (not capa) (if (setq capa (getstring "\nType Layer name: ")) (if (tblsearch "layer" capa) (if (not (setq a (getreal "\nType Height: "))) (setq capa (princ "\n*** A valid height has not been specified. Please, type it again... ***") capa nil) (setq para T) ) (setq capa (princ "\n*** Specified layer does not exist. Please, type it again... ***") capa nil) ) ) ) ) ) ) (setq tx (dameTexto ind)) (while (and (setq l (grread T (if s 4 13) (if s 2 0))) (member (car l) '(5 3))) (prompt (strcat "\rSelect text to modify or insert new text \"" tx "\" (RIGHT CLICK for exit)")) (setq tam (* (getvar "pickbox") (/ (GETVAR "VIEWSIZE") (CADR (GETVAR "SCREENSIZE")))) para nil) (if (setq s (ssget "_C" (list (- (car (setq p (cadr l))) tam) (- (cadr p) tam)) (list (+ (car p) tam) (+ (cadr p) tam)) (list (cons 0 "TEXT")) ) ) (cond ((= (car l) 3) (entmod (subst (cons 1 tx) (assoc 1 (setq le (entget (ssname s 0)))) le)) (setq tx (dameTexto tx)) ) ;;; HERE MORE CASES ?... ) (cond ((= (car l) 3) (entmake (list '(0 . "TEXT") (cons 8 capa) (cons 62 (if cl cl 256)) (cons 40 a) (cons 1 tx) (cons 10 (list (car p) (cadr p) 0.0)) ) ) (setq tx (dameTexto tx)) ) ;;; HERE MORE CASES ?... ) ) ) (princ) )
    1 point
  3. I think the file that keeps your vlisp config is saved in : c:\Users\[*your-user-name*]\AppData\Roaming\Autodesk\AutoCAD 2017\R21.0\enu\VLIDE.DSK your autocad version is probably different , like ...\Autocad 2015\Rxx.0\enu\VLIDE.DSK maybe (setq dsk-filename (findfile "VLIDE.DSK")) will work. In my case it returns "C:\\temp\\lisp\\VLIDE.DSK" , I have write acces there but just put it there as backup / to study. This folder is at the top of my support path but I doubt it's the one loaded / saved on exit by the editor. Anyways , first warning : before you go crazy like a dragon and experiment , make sure you first make a backup , maybe more than one. In this file your have 2 lines : - one beginning with : (*edit-file-history* "C:/Temp/Lisp/_Cad-tutor/xxx.lsp" "C:/Temp/Lisp/_Cad-tutor/yyy.lsp" .......) - and multiple sections for every file open : (editor :CAPTION "xxx.lsp" :FILENAME "C:/Temp/Lisp/_Cad-tutor/xxx.lsp" :POINT 26786 :APEX 2162692 :SIZE 42468643 :STATE :MINIMIZED :RO nil :FGC nil :BGC nil :LXC T :LEX-ID :AL :CLV nil :TW 8 :LM 10 :CONTEXT :AUTOLISP ) (editor :CAPTION "yyy.lsp" :FILENAME "C:/Temp/Lisp/_Cad-tutor/yyy.lsp" :POINT 3528 :APEX 4259848 :SIZE 37946548 :STATE :MINIMIZED :RO nil :FGC nil :BGC nil :LXC T :LEX-ID :AL :CLV nil :TW 8 :LM 10 :CONTEXT :AUTOLISP ) etc etc... So ... the other first thing you could / should to is to check if you have / AutoCad has acces rights in the folder bladiebla...\enu\VLIDE,DSK I'm not sure I recommend trying to edit this file , but there it is , a possible way to get a grip on your digital Gremlin.
    1 point
  4. Just a comment in this situation these two do the same task. (vlax-put-property (vlax-put Another "Textgap" 'Textgap
    1 point
  5. If 'oldGap' is '(cdr (assoc 0 entData)))' then it will always be different from 0.425 because oldGap= "DIMENSION" If you want to get the current value of "TextGap" from the object contained in 'dim' you should call '(vlax-get-property (vlax-ename->vla-object dim) "TextGap")' But not '(cdr (assoc 0 entData))'
    1 point
  6. if this is on a company computer / network this may be caused by not having write access to the right folder , or , if your profile (registry) is reset (wiped) every time / morning you log in. Last one is easy enough to test. After you log in and open a lisp file , close AutoCad and start it again and see if your lisp files are still there or that AutoCad suddenly developed Alzheimer. You could also check your shortcut on your desktop. If it contains a /P parameter, it may start up with a fixed profile. First thing I always do is make my AutoCad local again. If you start AutoCad from your windows start button , this probably won't have a startup profile attached to it. So lots of options to explore before begging IT and bend over.
    1 point
×
×
  • Create New...