All Activity
- Past hour
-
Add several lisp files to the startup at once
Lee Mac replied to Nikon's topic in AutoLISP, Visual LISP & DCL
Oh I'm not mad, I just think you're blinkered into using the Startup Suite. As I've suggested throughout this thread, I would use the acaddoc.lsp. In my acaddoc.lsp, I have the following basic code: ( (lambda ( d ) (foreach x (vl-directory-files d "*.lsp" 1) (if (/= "acaddoc.lsp" (strcase x t)) (load (strcat d "\\" x) nil) ) ) ) "C:\\YourLISPFolder" ) Then, whatever .lsp files I place in "C:\\YourLISPFolder" are automatically loaded on startup - no need to change the Startup Suite, no need to modify the acaddoc.lsp any further - just drop a file into the folder. - Today
-
LISP to automatically redefine MTEXT width and Height
Steven P replied to Someone_Pro's topic in AutoLISP, Visual LISP & DCL
There is also Lee Macs Box Text function for another option... -
LISP to automatically redefine MTEXT width and Height
Steven P replied to Someone_Pro's topic in AutoLISP, Visual LISP & DCL
I think this one does dynamic columns as well: mtxtWdtHt (defun c:mtxtWdtHt ( / textss ) (setq textss (ssget '((0 . "MTEXT")) ) ) (roundtxtsizes 42 41 textss) (roundtxtsizes 43 46 textss) (princ) ) (defun roundtxtsizes ( width1 width2 textss / ent1 acount oldwidth newwidth) ;;Rounds UP ;;Sub Functions (defun getfroment (ent listorstring entcodes / acount acounter mytext newtext stringtext) ;;get dotted pairs list (setq entlist (entget ent)) ;;; (setq textent (entget (car (entsel)))) (if ( = (cdr (assoc 0 entlist)) "RTEXT") (progn (setq mytext (getrtext entlist)) ) ; end progn (progn (setq enttype (cdr (assoc 0 entlist))) (setq acount 0) (while (< acount (length entlist)) (setq acounter 0) (while (< acounter (length entcodes)) (setq entcode (nth acounter entcodes)) (if (= (car (nth acount entlist)) entcode ) (progn (setq newtext (cdr (nth acount entlist))) (if (numberp newtext)(setq newtext (rtos newtext))) ;fix for real numbers (setq mytext (append mytext (list (cons (car (nth acount entlist)) newtext) )) ) );end progn );end if (setq acounter (+ acounter 1)) );end while (setq acount (+ acount 1)) );end while ;;get string from dotted pair lists (if (= listorstring "astring") ;convert to text (progn (if (> (length mytext) 0) (progn (setq acount 0) (setq temptext "") (while (< acount (length mytext)) (setq temptext (cdr (nth acount mytext)) ) (if (= (wcmatch temptext "LEADER_LINE*") nil)()(setq temptext "")) ;;Fix for Multileader 'Leader_Line' Text (if (= stringtext nil) (setq stringtext temptext) (setq stringtext (strcat stringtext temptext )) );end if (setq acount (+ acount 1)) );end while );end progn );end if (if (= stringtext nil)(setq stringtext "")) (setq mytext stringtext) );end progn );end if );end progn ); end if mytext ) (defun LM:roundup ( n m ) ;; Lee Mac ((lambda ( r ) (cond ((equal 0.0 r 1e-8) n) ((< n 0) (- n r)) ((+ n (- m r))))) (rem n m)) ) ;;End Sub functions ;;Set up. (setq acount 0) ;;update text widths (while (< acount (sslength textss) ) (setq ent1 (ssname textss acount)) (setq oldwidth (cdr (nth 0 (getfroment ent1 string (list width1))) )) (setq newwidth (LM:roundup (atof oldwidth) 2.5 ) ) (entmod (subst (cons width2 newwidth)(assoc width2 (entget ent1)) (entget ent1))) (entupd ent1) (setq acount (+ acount 1)) );end while (princ) ) -
LISP to automatically redefine MTEXT width and Height
pkenewell replied to Someone_Pro's topic in AutoLISP, Visual LISP & DCL
@Someone_Pro I found this at AutoCAD Tips: https://autocadtips1.com/2011/08/13/autolisp-text-box-width/ Command: TXTBOXWIDTH (defun mip-mtext-wrap-BB (en / el SetHandles CheckHandles sclst) (vl-load-com) ;;; Argument: the ename of an mtext ;;; Shrinkwrap the bounding box of selected MText objects ;;; http://discussion.autodesk.com/forums/message.jspa?messageID=5734567 ;;; ShrinkwrapMText v2a.lsp - Joe Burke - 10/13/2007 - Version 2a ;;;;;http://discussion.autodesk.com/forums/thread.jspa?threadID=448625 ;;;; USE: ;;; (mip-mtext-wrap-BB (car(entsel))) ;;; !!!! AutoCAD 2010 2011 2012 ;;; http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/MTEXT-Column-property/m-p/2690952 ;;;Need to change the column type from dynamic to not add the dxf group of 75 with 0 ;;; http://www.theswamp.org/index.php?topic=28243.0 (defun GetAnnoScales (e / dict lst rewind res) ;;; Argument: the ename of an annotative object. ;;; Returns the annotative scales associated with the ;;; ename as a list of strings. ;;; Example: ("1:1" "1:16" "1:20" "1:30") ;;; Returns nil if the ename is not annotative. ;;; Can be used to test whether ename is annotative or not. ;;; Works with annotative objects: text, mtext, leader, mleader, ;;; dimension, block reference, tolerance and attribute. ;;; Based on code by Ian Bryant. (if (and e (setq dict (cdr (assoc 360 (entget e)))) (setq lst (dictsearch dict "AcDbContextDataManager")) (setq lst (dictsearch (cdr (assoc -1 lst)) "ACDB_ANNOTATIONSCALES") ) ;_ end of setq (setq dict (cdr (assoc -1 lst))) ) ;_ end of and (progn (setq rewind t) (while (setq lst (dictnext dict rewind)) (setq e (cdr (assoc 340 lst)) res (cons (cdr (assoc 300 (entget e))) res) rewind nil ) ;_ end of setq ) ;_ end of while ) ;_ end of progn ) ;_ end of if (reverse res) ) ;end (defun CheckHandles (e / dict lst rewind nlst d42 d43 n p ptlst) ;;; Argument: the ename of annotative mtext object. ;;; Returns T if the object has only one scale or ;;; the handles for all scales are proportionally the ;;; same and all scales use the same insertion point. (if (and e (setq dict (cdr (assoc 360 (entget e)))) (setq lst (dictsearch dict "AcDbContextDataManager")) (setq lst (dictsearch (cdr (assoc -1 lst)) "ACDB_ANNOTATIONSCALES") ) ;_ end of setq (setq dict (cdr (assoc -1 lst))) ) ;_ end of and (progn (setq rewind t) (while (setq lst (dictnext dict rewind)) (setq nlst (cons lst nlst) rewind nil ) ;_ end of setq ) ;_ end of while (cond ((= 1 (length nlst))) (t ;; lst is nil so reuse it. (foreach x nlst ;Horizontal width. Can be zero, a null text string. (setq d42 (cdr (assoc 42 x)) ;Vertical height cannot be zero so a divide ;by zero error can't happen. d43 (cdr (assoc 43 x)) n (/ d42 d43) lst (cons n lst) ;Insertion point p (cdr (assoc 11 x)) ptlst (cons p ptlst) ) ;_ end of setq ) ;_ end of foreach (and (vl-every '(lambda (x) (equal n x 1e-4)) lst) (vl-every '(lambda (x) (equal p x 1e-4)) ptlst) ) ;_ end of and ) ) ;_ end of cond ) ;_ end of progn ) ;_ end of if ) ;end (defun SetHandles (lst / oldlst charwidth ht pat) ;;; ;Argument: an entget list. ;;; ;Code 42 is the smallest width of the handles. ;;; ;If 41 is larger than 42 then the handles can be shrunk ;;; ;horizontally given a single line mtext object. ;;; ;;; ;Code 46 is the current height of the handles in 2007/2008. ;;; ;Substitute the actual height from the code 43 value. ;;; ;;; ;Used to determine number of objects modified. (setq lst (entget (cdr(assoc -1 lst)) '("ACAD"))) ;;; (setq oldlst lst) (setq charwidth (* (cdr (assoc 42 lst)) 1.05) ;_1.035 ht (cdr (assoc 43 lst)) lst (subst (cons 41 charwidth) (assoc 41 lst) lst) lst (subst (cons 46 ht) (assoc 46 lst) lst) lst (if (assoc 75 lst) ;;; 75 - òèï êîëîíîê (subst (cons 75 0) (assoc 75 0) lst) (append lst (list(cons 75 0))) ) ) ;_ end of setq ;;;Code 46 is the current height of the handles in 2007/2008. ;;;Substitute the actual height from the code 43 value. (if (and (setq pat (assoc -3 lst)) (eq "ACAD" (caadr pat)) ) ;_ end of and (progn (if (assoc 46 lst) ;;;Code 46 is the current height of the handles in 2007/2008. ;;; Remove extended data regarding height if found. (setq pat '(-3 ("ACAD"))) (progn (setq pat (cons -3 (list (subst (cons 1040 ht) (assoc 1040 (cdadr pat)) (cadr pat)) ;_ end of subst ) ;_ end of list ) ;_ end of cons ) ;_ end of setq ) ;_ end of progn ) ;_ end of if (setq lst (subst pat (assoc -3 lst) lst)) ) ) ;_ end of if (setq lst (entmod lst)) ) ;end SetHandles (if (= (cdr (assoc 0 (setq EL (entget en '("*"))))) "MTEXT") (progn (cond ((and (setq sclst (GetAnnoScales en))(CheckHandles en)) ;_ end of and (vl-cmdf "._chprop" en "" "_Annotative" "_No" "") ;(SetHandles (entget ename)) (SetHandles el) (vl-cmdf "._chprop" en "" "_Annotative" "_Yes" "") (foreach x sclst (vl-cmdf "._objectscale" en "" "_Add" x "") ) ;_ end of foreach ) ((not (GetAnnoScales en)) (SetHandles el) ) (t nil) ) ;_ end of cond ) ;_ end of progn ) ;_ end of if ) ;_ end of defun (defun C:TxtBoxWidth (/ ss i) (and (setq ss (ssget "_:L" '((0 . "MTEXT")))) (repeat (setq i (sslength ss)) (mip-mtext-wrap-BB (ssname ss (setq i (1- i)))) ) (setq ss nil) ) ) -
Steven P started following LISP to automatically redefine MTEXT width and Height
-
LISP to automatically redefine MTEXT width and Height
Steven P replied to Someone_Pro's topic in AutoLISP, Visual LISP & DCL
Not quite what you want but I have this line on opening a file: (setvar "MTEXTCOLUMN" 0) ;;Dynamic columns OFF Just in case someone has been using columns. Just a setting, won't alter existing texts Might be an edit - have a memory of making something up EDIT: Strip MText (SMT) clears columns... need to look at how -
LISP to automatically redefine MTEXT width and Height
Nikon replied to Someone_Pro's topic in AutoLISP, Visual LISP & DCL
There is a good program for MLEADER and MTEXT, author KoMon reset_mleader_mtext.fas -
pkenewell started following LISP to automatically redefine MTEXT width and Height
-
LISP to automatically redefine MTEXT width and Height
pkenewell replied to Someone_Pro's topic in AutoLISP, Visual LISP & DCL
Here is one I did a while back for the WIDTH only. (I'll see if I can add the height as well.) NOTE: This doesn't work well with Annotative MTEXT, and it will not work if the columns are set to "dynamic"; must be set to "No Columns". (see screenshot). (defun c:MTWID (/ _StrParse d dw obj ss tls txt wid) (vl-load-com) (vla-StartUndoMark (setq d (vla-get-activedocument (vlax-get-acad-object)))) (defun _StrParse (str del / pos) (if (and str del) (if (setq pos (vl-string-search del str)) (cons (substr str 1 pos) (_StrParse (substr str (+ pos 1 (strlen del))) del)) (list str) ) ) ) (princ "\nSelect MTEXT Objects: ") (if (setq ss (ssget '((0 . "MTEXT")))) (repeat (setq n (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq n (1- n)))) txt (vla-get-textstring obj) dw (vla-get-width obj) ) (if (> (length (setq tls (_strparse txt "\\P"))) 1) (setq txt (apply 'strcat (cons (car tls)(mapcar '(lambda (x)(strcat " " x)) (cdr tls))))) ) ;; get the width of the longest text string (setq wid (apply 'max (mapcar '(lambda (x / y)(setq y (textbox (list (cons 1 x))))(- (car (cadr y)) (car (car y)))) tls))) (vla-put-textstring obj txt) (vla-put-width obj wid) ) ) (redraw) (vla-endundomark d) (princ) ) If someone can figure our a way to scale properly with annotative text and turn off columns programmatically, then it would be good to add. -
Add several lisp files to the startup at once
Nikon replied to Nikon's topic in AutoLISP, Visual LISP & DCL
There is an easier way (m-r @Lee Mac don't get mad ). Create a separate folder for files that need to be added to the startup. And in the "Load/Upload Applications" window, click "Add..." and open this folder. Select all the files in the folder and click the "Open" button. All files will be uploaded to the Startup Suite. A good idea comes after -
If I understand correctly, you can't do this with standard AutoCAD tools. You need to associate each label with its perimeter and its neighboring boundary. To do this, you'll need to break each perimeter down into individual polylines. Each perimeter section shared by two labels must be a separate polyline. Start by figuring out how to achieve this.
-
LISP to automatically redefine MTEXT width and Height
Someone_Pro replied to Someone_Pro's topic in AutoLISP, Visual LISP & DCL
Thank you! But my goal is a lisp that would automatically set up the width and height to match the text shown without any input from me. -
Add several lisp files to the startup at once
GLAVCVS replied to Nikon's topic in AutoLISP, Visual LISP & DCL
I've edited the code so that, upon completion of the command, the "ListaLisp.lsp" file opens with Notepad. Try again. PS: "ListaLisps.lsp" file must have been created. Otherwise, the subsequent messages would not have appeared. -
Add several lisp files to the startup at once
ronjonp replied to Nikon's topic in AutoLISP, Visual LISP & DCL
@Nikon My 2c .. place all your lisp files in a subfolder under "MYDOCUMENTS". Then you don't have to worry about permissions, AutoCAD version or usernames. (strcat (getvar "MYDOCUMENTSPREFIX") "\\LISP") Then add this to your support paths and DONE! -
Add several lisp files to the startup at once
Nikon replied to Nikon's topic in AutoLISP, Visual LISP & DCL
My deep respect to all those who responded and guided me on the right path. I didn't expect the question to be difficult. Regarding the latest code GLAVCVS, here are the messages: Access AutoCAD directory and such an entry in the command line: *** 4 files LOADED *** *** New SupportPath: C:\Program Files\Autodesk\AutoCAD 2021\Support\StartUPSupp Files from the StartUPSupp folder were uploaded to this drawing, but I did not find the "ListaLisps" file.Isp" in the "Documents" folder. -
MUTHUKUMAR1983 started following LISP to automatically redefine MTEXT width and Height
-
LISP to automatically redefine MTEXT width and Height
MUTHUKUMAR1983 replied to Someone_Pro's topic in AutoLISP, Visual LISP & DCL
use this one for width of mtext WD.VLX -
Yes, that's true! I was wrong. I think you understood the tag syntax very well. I'm attaching an image of what the second floor should actually look like.
-
LISP to automatically redefine MTEXT width and Height
Someone_Pro posted a topic in AutoLISP, Visual LISP & DCL
Hello all. I'm looking for a Lisp that enables me to just select an MTEXT -or Just apply it to the entire plan- And it automatically redefines MTEXT width and Height to be tight around the text as shown in the picture. Please let me know if you have any questions. -
You can enable VLIDE in newer releases by setting LISPSYS=0. https://help.autodesk.com/view/ACD/2024/ENU/?guid=GUID-1853092D-6E6D-4A06-8956-AD2C3DF203A3
-
Lee Mac started following Hijack command - extract and alter output from vanilla commands
-
Hijack command - extract and alter output from vanilla commands
Lee Mac replied to darn halo's topic in AutoLISP, Visual LISP & DCL
No - you cannot intercept and modify the output of standard commands, only redefine them. -
@all poster . I got to use Vlide at my 2024 . Not know how, but it work. Thans all you.
-
Add several lisp files to the startup at once
GLAVCVS replied to Nikon's topic in AutoLISP, Visual LISP & DCL
Code does almost everything Or at least it tries to: –Unlocks access privileges to "Support" (if necessary) –Checks the privileges with which AutoCAD is running –Adds to 'SupportPath' the directory of the lisp files to be loaded –Writes to acadDoc.lsp (yes, no longer acad.lsp). –And if something goes wrong, it will probably give you an explanation of what you need to do. That said: I haven’t included a complaints form -
Add several lisp files to the startup at once
GLAVCVS replied to Nikon's topic in AutoLISP, Visual LISP & DCL
Lisp, Lisp, Lisp.... and only Lisp -
Add several lisp files to the startup at once
GLAVCVS replied to Nikon's topic in AutoLISP, Visual LISP & DCL
Last attempt ;************************ G L A V C V S ************************* ;************************** F E C I T *************************** (defun c:LoadFolder (/ sh hwd carp slf pth lstAA a arch nmarch nmarchLL cno cns sl r l admin? ttpp acadAdmin? sustCad) (defun ttpp (cp / c w) (and (vl-file-directory-p cp) (setq w (vlax-get-or-create-object "WScript.Shell")) (findfile (setq c (strcat (getenv "windir") "\\System32\\icacls.exe "))) (vlax-invoke-method w 'run (strcat c "\"" cp "\"" " /q /c /t /grant " (cond ((getenv "userdomain")) ((getenv "computername"))) "\\" (getenv "username") ":(OI)(CI)F /T") 0 :vlax-true ) ) (and w (vlax-release-object w)) ) (defun acadAdmin? (/ arch ruta ruta1 f sh) (if (findfile (setq ruta1 (strcat (getenv "TEMP") "\\acAdmin.si")) ) (vl-file-delete ruta1) ) (if (setq arch (open (setq ruta (strcat (getenv "TEMP") "\\ea.bat")) "w") ) (progn (write-line "@echo off net session >nul 2>&1 if %errorlevel% == 0 ( echo SI> \"%temp%\\acAdmin.si\" )" arch ) (close arch) (setq sh (vlax-create-object "WScript.Shell")) (vlax-invoke sh 'Run ruta 0 :vlax-true) (vlax-release-object sh) (vl-file-delete ruta) (if (findfile ruta1) (progn (vl-file-delete ruta1) T ) ) ) ) ) (defun sustCad (tx a n / c i r) (while (/= (setq c (substr tx (setq i (if i (1+ i) 1)) 1)) "") (setq r (strcat (if r r "") (if (= c a) n c))) ) ) (setq sl (getvar "SECURELOAD")) (SETVAR "SECURELOAD" 0) (if (setq admin? (acadAdmin?) sh (vla-getinterfaceobject (vlax-get-acad-object) "shell.application") hwd (vl-catch-all-apply 'vla-get-hwnd (list (vlax-get-acad-object))) carp (vlax-invoke-method sh 'browseforfolder (if (vl-catch-all-error-p hwd) 0 hwd) "Folder to load" 0 "") ) (if (setq slf (vlax-get-property carp 'self) pth (vlax-get-property slf 'path) pth (vl-string-right-trim "\\" (vl-string-translate "/" "\\" pth)) ) (if (setq lstAA (vl-directory-files pth "*.lsp")) (foreach a lstAA (if (not arch) (setq arch (open (setq nmarchLL (strcase (strcat (VL-REGISTRY-READ "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders" "Personal" ) "\\ListaLisps.lsp" ) ) ) "w" ) ) ) (load (strcat (setq cno (strcat pth "\\" a)))) (write-line (strcat "(load \"" (sustCad cno "\\" "\\\\") "\")") arch) ) ) ) (if (not Admin?) (vl-catch-all-apply (alert "Acad.exe not have Administrator privileges.\nThis requeriment is necessary to run this command.\n\nExiting...") (exit) ) ) ) (if arch (progn (close arch) (startapp "notepad" nmarch) (princ (strcat "\n*** " (itoa (length lstAA)) " files LOADED ***")) (if (not (wcmatch (strcase pth) (setq cns (VLAX-get-property (setq prf (VLAX-get-property (vla-get-preferences (vlax-get-acad-object)) "files")) "SupportPath")))) (progn (vlax-put prf "SupportPath" (strcat cns ";" pth)) (princ (strcat "\n*** New SupportPath: " pth)) ) ) (setq nmarch (if (setq a (findfile "acadDoc.lsp")) a (strcat (vl-filename-directory (findfile "acad.exe")) "\\Support\\acadDoc.lsp")) nmarchLL (strcase (sustCad nmarchLL "\\" "\\\\")) ) (if a (if (setq arch (open nmarch "r")) ;;; (progn (while (and (not r) (setq l (read-line arch))) (setq r (wcmatch (strcase l) "(LOAD *LISTALISPS.LSP\")" ))) (close arch)) (progn (while (and (not r) (setq l (read-line arch))) (setq r (wcmatch (strcase l) (strcat "(LOAD \"" nmarchLL "\")") ))) (close arch)) (alert (princ (strcat "It was not possible to write to \"acadDoc.lsp\". Open the file yourself and write: (load \"" nmarchLL "\")"))) ) ) (cond ((and a (not r)) (if (setq arch (open nmarch "a")) (progn (write-line (strcat "(load \"" nmarchLL "\")") arch) (close arch) (alert "\"acadDoc.lsp\" has been successfully modified"))) ) (a (vlax-invoke-method (vlax-create-object "wscript.shell") 'popup "\"acadDoc.lsp\" is correct.\nNo modifications were necessary" 0 "Checking \"acadDoc.lsp\"..." 0) ) ;;; (nmarch (if (setq arch (open nmarch "w")) (progn (write-line "(LOAD \"LISTALISPS.LSP\")" arch) (close arch)))) (nmarch (if (setq arch (open nmarch "w")) (progn (write-line (strcat "(load \"" nmarchLL "\")") arch) (close arch) (alert "\"acadDoc.lsp\" has been successfully modified")) (if (= (vlax-invoke-method (vlax-create-object "wscript.shell") 'popup "It appears that it is not possible to write to the \"Support\" directory.\nWould you like me to try to unlock access permisions?" 0 "Access AutoCAD directory" 4 ) 6 ) (progn (ttpp (vl-filename-directory nmarch)) (if (setq arch (open nmarch "w")) (progn (write-line (strcat "(load \"" nmarchLL "\")") arch) (close arch) (alert "DONE!!!\n\n\"acadDoc.lsp\" has been successfully modified")) (vlax-invoke-method (vlax-create-object "wscript.shell") 'popup "The attempt didn't work.\nYou'll need to troubleshoot the problem manually:\n\nDo the following:\nStart StartSuite, find \"ListaLisps.lsp\" file in \"Documents\" folder and select it to load every time you start it.\n\nThis will resolve the issue" 0 "Access AutoCAD directory" 0 ) ) ) ) ) ) (T (alert "Ocurrió lo inesperado")) ) (if arch (startapp "notepad" nmarch)) ) ) (SETVAR "SECURELOAD" sl) (princ) ) -
Add several lisp files to the startup at once
Steven P replied to Nikon's topic in AutoLISP, Visual LISP & DCL
Looking at Omega-Thunder, he used the Registry editor, and not LISP via AutoCAD, you'd need to ask perhaps in a Windows forum how to amend the registry from a text file. The registry is a powerful tool - get it wrong and you might be needing to reinstall your software - so be careful. Via LISP the methods you can use are detailed above, remembering of course that LISP via AutoCAD is mostly for manipulating lines on the screen, not for controlling windows, or the workings of your CAD package. Might be you have to consider the end result and work out if you can do what you ultimately want another way using the above. (Note: Adding to Lee Mac, experience in the area, the commentators on this thread... and those who haven't commented but I know read most threads add up to 10s of thousands of posts, many many years of LISPs, and if they are suggesting other solutions then perhaps... perhaps... that is the way to go) -
Add several lisp files to the startup at once
Nikon replied to Nikon's topic in AutoLISP, Visual LISP & DCL
There is no ignoring, I just didn't know that "The Startup Suite cannot be automated via LISP". (Lee Mac Posted November 4, 2014) I just found out about it today. Hasn't anything changed in Autocad since 2014? -
Add several lisp files to the startup at once
Lee Mac replied to Nikon's topic in AutoLISP, Visual LISP & DCL
...or just ignore us