Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/31/2025 in Posts

  1. @CivilTechSource You could do it that way, but I wouldnt . I would use the built in Styles and have the user select which style to use. If using AutoCAD you should expect the user to have a certain level of usability in the work space. If they dont have the level then do not make it easier for them, make them use CAD the way its intended. By doing that you are making sure that they learn CAD and also use the office CAD Standards how they are intended to be used.
    1 point
  2. first of all , if is a built in command so c:if I don't think works second , yes and no are variables not functions so you could use (setq yes "\nYes") and then use (eval yes) better would be : (defun c:whatif (/ inp yes no) (setq yes "Yes" no "No") (if (= (setq inp (getint "\nValue: ")) 1)(eval yes)(eval no)) ;;; or (if (= (setq inp (getint "\nValue: ")) 1)(princ "\nyes")(princ "\nNo")) (princ) )
    1 point
  3. Thanks for this, learned something new, much cleaner and easier. I tried your suggestion, but didn't work, I also did some more testing and the reading of the data is done properly, the appending of the new content is done properly, and then I think the problem occurs when creating safearray using value 17 or in other words using VisualLisp variant data type vlax-vbByte, which is unsupported according to this post. So the value that has been returned from vlax-variant-type performed on result of reading with (LM:ReadBinaryStream (findfile "../AppAutoLoad.app") nil) is 8209 which is value of vlax-vbArray(8192) combined with vlax-vbByte(17), but since the vlax-vbByte data type seems to be unsupported I guess that I can't recreate the variant of the same type (8209) anymore?
    1 point
  4. FWIW, you can change this: (mapcar 'ascii (MM:strToLst text)) To: (vl-string->list text) An untested suggestion: where the variant is concerned, rather than using hardcoded variant & safearray datatypes, try querying the types of the original variant & safearray using: vlax-variant-type vlax-safearray-type
    1 point
  5. Another go. (defun c:addval ( / lst lst2 att cnt lst3) (setq inc (getreal "\nEnter increment + or - ")) (setq ss (ssget '((0 . "TEXT,ATTDEF")))) (setq lst '() tnum 0 tatt 0) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (1- x))))) (setq objname (vlax-get obj 'objectname)) (if (= objname "AcDbText") (progn (setq newt (+ (atof (vlax-get obj 'textstring)) inc)) (cond ((< newt 10 ) (setq newt (strcat "00" (rtos newt 2 0)))) ((< newt 100) (setq newt (strcat "0" (rtos newt 2 0)))) (setq newt (rtos newt 2 0)) ) (vlax-put obj 'textstring newt) (setq tnum (1+ tnum)) ) (progn (setq newt (+ (atof (vlax-get obj 'tagstring)) inc)) (cond ((< newt 10) (setq newt (strcat "00" (rtos newt 2 0)))) ((< newt 100) (setq newt (strcat "0" (rtos newt 2 0)))) (setq newt (rtos newt 2 0)) ) (vlax-put obj 'tagstring newt) (setq tatt (1+ tatt)) ) ) ) (alert (strcat (rtos tnum 2 0) " text changed \n" (rtos tatt 2 0) " tags Changed")) (princ) )
    1 point
  6. @CivilTechSource Yes you can make the variable global by not clearing it in the lisp routine. If you aren't familiar with what I am taking about in a lisp you write at the top this.. (defun c:lisp ( / variable1 variable2) ) If you set a value to variable3 as long as it's not in the list like variable1 is then it's consider a global variable which can be used by multiple lisps. Typically I see people use something like global:variable1 to know which is which. Hope that helps.
    1 point
  7. You mention reading from Excel, its not a problem you can read cells from CAD, so if you have multiple blocks can be done. It would be simple to add to your defun say two columns in Excel Blocknames & dwgname with path. Need a sample Excel.
    1 point
  8. A suggestion use a "\n" in the (getreal "\nEnter Rise...) this will push a new line on the command line. If the F2b is a global variable then any lisp can read it, but that is not necessarily a good idea. Its easier to do a double lisp in the cui. So load the program and call a defun passing it the f2b value. ^C^C^P(setq F2B (getreal "Enter Rise for Front to Back slopes: "))(load "mylisp")(mylisp f2b) I use LDATA when I want values stored in a dwg they stay in the dwg and can be changed.
    1 point
  9. Rather then reading the file and then writing it back with new data added just open the file in append mode. aka add the data you want at the end. ;; Example usage: ;; (MH:AppendText "C:/path/to/your/file.txt" "This is a new line of text") (defun MH:AppendText (filename text / file) (vl-load-com) (setq file (open filename "A")) 'open file in append (if file (progn (write-line text file) (close file) (princ (strcat "\nText appended to " filename)) ) (princ (strcat "\nError: Could not open " filename)) ) (princ) ) also ZWCAD might now be able to use some of the Visualisp commands like vlax- and vl-
    1 point
×
×
  • Create New...