Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. This hopefully will make a list of sizes needed. Limited testing, it needs a check for odd numbers added but just did it quick. Odd numbers will need one less even number size and two other sizes to make answer. But its a start. Some one may have a program already. Just test with even numbers. It may want a even odd defuns as a simple answer. ; use 2 3 4 5 6 only say 50 = 8x6 a 2 (defun c:wow ( / len 6s 5s 4s 3s 2s 6d 5d 4d 3d 2d) (setq len (getint "\nEnter length ")) (setq 6s 0 5s 0 4s 0 3s 0 2s 0) (setq 6d (/ len 6)) (if (>= 6d 1) (progn (setq 6s (fix 6d)) (setq len (- len (* 6s 6))) ) ) (setq 5d (/ len 5)) (if (>= 5d 1) (progn (setq 5s (fix 5d)) (setq len (- len (* 5s 5))) ) ) (setq 4d (/ len 4)) (if (>= 4d 1) (progn (setq 4s (fix 4d)) (setq len (- len (* 4s 4))) ) ) (setq 3d (/ len 3)) (if (>= 3d 1) (progn (setq 3s (fix 3d)) (setq len (- len (* 3s 4))) ) ) (setq 2d (/ len 2)) (if (>= 2d 1) (progn (setq 2s (fix 2d)) (setq len (- len (* 2s 4))) ) ) (princ (setq lst (list 6s 5s 4s 3s 2s))) (princ) )
  3. This is read an Excel example it just reads an open spreadsheet, and shows the result of a read cells. You could make a list of the cells. For your task you will probably need to use OBDX as you may have different dwg names, OBDX will allow you to change multiple dwgs. ; https://www.cadtutor.net/forum/topic/98627-block-definition-modification-adding-2-attributes/ ; Excel link by AlanH Aug 2025 (defun wow ( / myxl) ; thanks to Lee-mac for this defun ; 58 is Colon ; thanks to Lee-mac for this defun ; www.lee-mac.com ; 44 is comma 9 is tab 34 is space 58 is colon (defun csv->lst58 ( str / pos ) (if (setq pos (vl-string-position 58 str)) (cons (substr str 1 pos) (csv->lst58 (substr str (+ pos 2)))) (list str) ) ) ; get range (defun AH:getrangexl ( / lst1 myrange lst1) (setq lst1 '()) (setq myrange (vlax-get-property (vlax-get-property (vlax-get-property myxl "ActiveSheet") 'UsedRange) 'address)) (setq lst1 (csv->lst58 myrange)) (setq st (vl-string-subst "" "$" (vl-string-subst "" "$" (nth 0 lst1) ))) (setq end (vl-string-subst "" "$" (vl-string-subst "" "$" (nth 1 lst1) ))) (setq row1 (cadr (columnrow st))) (setq endrow (cadr (columnrow end))) (setq endcol (car (columnrow end))) ) ; Alpha2Number - Converts Alpha string into Number ; Function By: Gilles Chanteau from Marseille, France ; Arguments: 1 ; Str$ = String to convert ; Syntax example: (Alpha2Number "ABC") = 731 ;------------------------------------------------------------------------------- (defun Alpha2Number (Str$ / Num#) (if (= 0 (setq Num# (strlen Str$))) 0 (+ (* (- (ascii (strcase (substr Str$ 1 1))) 64) (expt 26 (1- Num#))) (Alpha2Number (substr Str$ 2)) ) ) ) ; ColumnRow - Returns a list of the Column and Row number ; Function By: Gilles Chanteau from Marseille, France ; Arguments: 1 ; Cell$ = Cell ID ; Syntax example: (ColumnRow "ABC987") = '(731 987) ;default to "A1" if there's a problem ;------------------------------------------------------------------------------- (defun ColumnRow (Cell$ / Column$ Char$ Row#) (setq Column$ "") (while (< 64 (ascii (setq Char$ (strcase (substr Cell$ 1 1)))) 91) (setq Column$ (strcat Column$ Char$) Cell$ (substr Cell$ 2) ) ) (if (and (/= Column$ "") (numberp (setq Row# (read Cell$)))) (list (Alpha2Number Column$) Row#) '(1 1) ) ) ;; Thanks to fixo (defun getcell2 (row column / ) (setq cells (vlax-get-property (vlax-get-property myxl "ActiveSheet") "Cells")) (setq cell (vlax-get (vlax-variant-value (vlax-get-property cells "Item" row column)) 'value)) ) (defun openxl ( / ) (setq myxl (vl-catch-all-apply 'vlax-get-or-create-object '("Excel.Application"))) (if (vl-catch-all-error-p myxl) (progn (prompt "\nError: Could not start Excel.") (exit) ) ) (if (= (vlax-get-property (vlax-get-property myXL 'WorkBooks) 'count) 0) (vlax-invoke-method (vlax-get-property myXL 'WorkBooks) 'Add) ) (vla-put-visible myXL :vlax-true) (vlax-put-property myxl 'ScreenUpdating :vlax-true) (vlax-put-property myXL 'DisplayAlerts :vlax-true) (princ) ) ; starts here (openxl) (AH:getrangexl) ; ignore 1st line (setq row (+ row1 1)) (repeat (- endrow 1) (setq dwgname (getcell2 row 1)) (setq bhd_inst (getcell2 row 2)) (setq bhd_line (getcell2 row 3)) (setq bhd_type (getcell2 row 4)) (princ (strcat"\n" dwgname " " bhd_inst " " bhd_line " " bhd_type)) (setq row (1+ row)) ;*********************************** ; do your thing here ;*********************************** ) (if (not (vlax-object-released-p myXL))(progn(vlax-release-object myXL)(setq myXL nil))) (princ) ) (wow)
  4. Today
  5. This is another way of setting a default option from a prompt. (initget "Prefix Suffix") (setq rep (cond ((getkword "\nAdd Text @ [Prefix/<Suffix>]: ")) ("Suffix") ) ) This will prompt the user "Add Text @ [Prefix/<Suffix>]:" just visually using < > to mark the default answer. if the user hits enter on the prompt the kword isn't set so rep defaults to "Suffix" Using cond instead of if's & wrapping it with getkword means the user doesn't have to type out exactly Prefix or Suffix . to then trigger other if's later in the lisp.
  6. There has been some other program requests ignoring dynamic for moment that take say 13 and work out the beams to make a 13m length. It looks like your doing that or is that why you want a look up table, so get 1-1-2-3 etc You can normally get at any property in a dynamic block so you could skip the select length and enter a length value then the block would be updated. I can see what your using. So using the great program by Lee-mac Dynamic block.lsp you can set say the correct visibilty. Just a question would you be happy using a row function much easier than trying to do some 50+ visibility states. 50 = 8 x 6m + 1 x 2m length so how would that be done as a look up ? 6-6-6-6-6....... Much easier to just make as a row of 6 plus a 2. Same with setting correct end. Have a look at video. Do windows.mp4
  7. Yesterday
  8. If you make a Text menu item then can have sub menu in a pop up and set the text height and style to use then call text, so could have multiple Text select.
  9. BIGAL

    Read/Write Binary Files

    I looked at the file and its plain ascii text, are you sure need to write a binary file ? I used to have DEBUG so could look at a file and see if its plain text or binary. Can you post a file that has more than one line please. Just a comment in Acad and Bricscad the start up suite is contained in the registry.
  10. Just fixed this by using flip action .
  11. Forgot to add I only populated 2m,3m and 14m on the middle drop down to test the movements and visibilities . the other sizes won’t do anything when selected .
  12. @ESan I'm not sure what you mean exactly. The structure of an IF statement is: (IF <function or variable evaluates as True> <THEN perform statement or function and return value> <ELSE if not True, perform the statement or function and return value>) NOTE: the IF function doesn't return T or NIL by itself, it returns the results of the statement or function in the THEN or ELSE parts. Example with extra commenting: (defun C:IF () (setq i (getint "\nEnter a Number or ENTER for nothing: ")) (if i ;<-- IF "i" evaluates to not Nil or T (true) ;THEN perform the following. NOTE all must evaluate to a single return, hence why (progn) is used to do multiple actions. (progn (princ (strcat "\nYou entered the number " (itoa i) ". ")); Use i in print to command line T ; Return T - Otherwise (princ) doesn't return anything. ) ; ELSE if "i" evaluates to NIL, perform the following. NOTE all must evaluate to a single return, hence why (progn) is used to do multiple actions. (progn (Princ "\n You did not enter anything. "); Print to the command line that nothing was given. nil ; Return NIL - Otherwise (princ) doesn't return anything. ) ) )
  13. @CivilTechSource I'm not as good at the whole CAD customization as some or maybe all of the guys in this thread but here is what I do at my office. 1) I get everyone to add a line to their Support File Search Path. The line I get them to add is located on our server so everyone has access to it. For example my line is "G:\Support_Files\Autolisp\_LoadOnStart" where the G:\ is a network drive and the Autolisp folder contains all our Autolisps. 2)I add the same folder into the Trusted Locations section. Or in this case I would just this line. "G:\Support_Files\Autolisp\..." The 3 periods at the end means also include every folder here after. 3) Once thats all setup then AutoCAD should start loading all acad.lsp & acaddoc.lsp or acadlt.lsp & acadltdoc.lsp when you start CAD or open a file. 4) I created an acadltdoc.lsp file and put my load, autoload or system variables in there. Here is a small snippet of what I load when users open a file.... Here is what I do for system variables and to make sure they are the same across the company. Doing this has helped and has decreased the amount of times I get asked why something isnt working. I have more variables then written here. This is just an example. ;;Set system variables that need to be set for Cassidy & Co CAD Standards (defun-q MYSTARTUP () (SETVAR "REGENMODE" 1) (SETVAR "GRIDMODE" 0);Turns off the grid (SETVAR "SNAPMODE" 0);Turns off snap to grid (SETVAR "MIRRTEXT" 0);Text will mirror (SETVAR "BINDTYPE" 1);Changes Xref Bind types. ie Setting to 1 will remove the xref files name from the layer name. (SETVAR "DIMASSOC" 1);Sets dims to be non-associated to objects (SETVAR "VISRETAIN" 1) (SETVAR "FILEDIA" 1);Yes (SETVAR "ATTDIA" 1);Yes (SETVAR "ATTREQ" 1);Yes (SETVAR "INSBASE" (list 0.0 0.0 0.0));Yes (SETVAR "SAVETIME" 10) (SETVAR "XREFNOTIFY" 2) (SETVAR "TRANSPARENCYDISPLAY" 1) (SETVAR "FIELDEVAL" 31) (PRINC) ) For LISP Routines I do this..... (setq S::STARTUP (append S::STARTUP MYSTARTUP)) (load "G:/Support_Files/Autolisp/SubFunctions.lsp") (load "G:/Support_Files/Autolisp/_LoadOnStart/TipV1-1.lsp") ;;Areas (autoload "G:/Support_Files/Autolisp/Area Calcs/Areas2AttributeV1-2.lsp" '("A2A")) (autoload "G:/Support_Files/Autolisp/Area Calcs/Areas2FieldV1-3.lsp" '("A2F")) The LOAD section will directly load the Lisps as the file loads. The AUTOLOAD section will load the lisp when the command at the end is written. For example if A2A or A2F typed out then the lisp will load and run the command.
  14. @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.
  15. leonucadomi

    increase or decrease value of attdef...help

    EXCELLENT MASTER , THANK YOU
  16. That is really handy to know! Would it be wise to create a Textbox in the CUI where the user can input a number eg. text height and then all lisps that run can use the text height specified globally?
  17. Does the first set of code not automatically check for a nil option? From my understanding, the if function has a T and nil outcome and needs both to work. If the statement is true, carry out the first (T) option, if not, carry out the second (nil) option.
  18. Ah, I wasn't 100% sure if it was or not. When I was testing this out, my command was just "OK". I thought I would change it to something more appropriate for clarity. Does the if function not automatically evaluate the T and nil outcomes? Using eval in place of just the variable does fix the issue when printing to the command line, however it does not work when asking it to perform an action, such as changing the users layer if inp does not equal1. If 1 is entered, it will show the correct evaluated option in the command line, but carry out the nil value regardless- changing the users layer as well. I might be trying to understand the if function in a situation where it is not realistically used. But I am not sure I know enough to know that either
  19. I did not know that was a feature, sorry about that!!
  20. rsdonna

    TCOUNT for multileaders

    This one is great! I'd love to see the updated one when its ready. I didn't realize I had tried it with the other version, but this one works great. Thanks again
  21. oh posted at the same time as pkenewell :-)
  22. 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) )
  23. If you want to use an IF statement with a variable that could be something or NIL, simply use this construct: (defun C:IF () (setq i (getint "\nEnter a Number or ENTER for nothing: ")) (if i ;<-- If not nil (progn (princ (strcat "\nYou entered the number " (itoa i) ". ")) T ) (progn (Princ "\n You did not enter anything. ") nil ) ) ) Conversely if you want to check for a NIL condition: (defun C:IF () (setq i (getint "\nEnter a Number or ENTER for nothing: ")) (if (not i) ;<-- If nil (progn (Princ "\n You did not enter anything. ") nil ) (progn (princ (strcat "\nYou entered the number " (itoa i) ". ")) T ) ) )
  24. SLW210

    TCOUNT for multileaders

    Yes, that had some issues, I think I have that sorted, but not ready to repost. Still working on adding the DCL to it. It happens to me all of the time. No worries!
  25. Please use Code Tags for your code in the future. (<> in the editor toolbar)
  26. I have recently updated a batch of blocks changing all labels from text to attributes, the idea being to stop them mirroring. After competing this task I find that the attribute text still mirrors. I think it is because the attributed blocks are nested. Is there any way to stop this? The attached block shows the issue. jam2.dwg
  27. Hi This is a pretty complex block attached. All the parts are spaced out at mo while I am getting things working, once done they are all moved in line. We make beams 2,3,4,5&6m lengths. To make up 7m we use 4+3, to make up 8 we use 5+3, 9-5+4, 10-6+4, ....13-6+4+3 etc etc. i have defined the available viz states Issue is we terminate the beam ends in 1 of 3 ways also we run beams lengths upto 50m at times. Only 1 viz state allowed in autocad (although i did see a link containing a block with multiple viz states but i think that involves some pretty high end programming skills), so I have been playing with using dummy parameters. It works well (attached). My issue is that I need to create many many hundreds of lines of data to encompass the full range I am looking for . jam1.dwg
  28. After being stuck on this subject for a while, I know the answer is "don't use variables for the actions of an if statement" but I am still bothered as to WHY it does not work. I assume it has to do with the way the if function evaluates, but I cannot figure it out myself. I apologize in advance for the long read. For example, I created a short routine to give a positive or negative response dependent on whether or not the user input equals 1: (defun c:if (/ inp) (setq inp (getint "\nValue: ")) (if (= 1 inp) (print "You Did It!!!!!!!!!") (print "You FAILED") ) (princ) ) This routine works- I provide the action for the T or nil outcome within the if statement. However, if I assign variables instead: (defun c:if (/ inp yes no) (setq inp (getint "\nValue: ") yes (print "You Did It!!!!!") no (print "You FAILED") ) (if (= 1 inp) yes no) (princ) ) The routine doesn't know what to do with itself regardless of user input. It returns the nil outcome twice regardless of whether or not the user input value equals 1. I do not understand why it skips to the nil outcome if the statement is true.
  1. Load more activity
×
×
  • Create New...