Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. LOL! Only for items that look difficult in painful in lisp, where there’s a possible built in function. This drawing took 0.03673760 seconds to process. if the drawing is indeed correct, have a look here for how to run python https://github.com/CEXT-Dan/PyRx arc2.dwg
  3. Thanks, I replaced cadr with caddr, everything is fine.
  4. That sounds to me that you are trying to pull us to the dark side, sounds pretty tempting, would you walk us through?
  5. Agree with @GLAVCVS, with cadr you're getting the X coordinate, not Y coordinate.
  6. sorry ı dont know how to use this code in acad. I'm trying
  7. Today
  8. Is the coordinate order set to Y, X, Z? This could be the error. Try changing cadr to caddr in the line '(setq yval (cadr (assoc 10 edata)))'
  9. Did you have a look at my drawing? Python converted those arcs to ellipses in milliseconds. If you can run python, then it would be pretty easy to make it callable from lisp
  10. Hi everyone, I’m trying to get the text from an Attribute Definition (ATTDEF) inside a dynamic block using AutoLISP, and then change that text. Unfortunately, I haven’t been able to make it work. Here is what I tried: (defun getblockentities (blk / ent enx rtn) (if (setq ent (tblobjname "block" blk)) (while (setq ent (entnext ent)) (setq enx (entget ent)) (if (= "INSERT" (cdr (assoc 0 enx))) (getblockentities (cdr (assoc 2 enx))) (progn (setq text (vlax-ename->vla-object ent)) (if (car text) (setq tlist (append tlist (list text))) ) ) ) ) ) ) And then I tried to collect attributes like this: (setq attlist (vlax-invoke textObj 'GetAttributes)) (foreach att attlist (if (not (eq (vla-get-tagstring att) nil)) (progn (setq text (vla-get-tagstring att)) (setq tlist (append tlist (list text))) ) ) ) But with this approach I couldn’t retrieve the attribute text. Is there another method to get (and later modify) the text string of an attribute inside a dynamic block? Thanks in advance for any guidance.
  11. Unfortunately, I can’t share the LISP code itself, but I can explain the underlying logic.I use a helper function that processes each entity type. When it encounters a block, it gathers the block’s contents into a list; once the top-level selection is done, it feeds that list back into the same function to process all nested entities.”
  12. Yesterday
  13. Hello everyone Sorting by Y coordinate from bottom to top does not work. The numbers are not arranged in increasing order. How can this be fixed? (defun to3 (n) (setq str (rtos n 2 3)) (if (not (wcmatch str "*.*")) (setq str (strcat str ".000"))) (while (< (strlen (substr str (+ 2 (vl-string-search "." str)))) 3) (setq str (strcat str "0")) ) str ) (defun c:INCTEXT_Y (/ inc startval cnt sel txtlist sorted i ent edata yval newval strval) (setq inc 2.8) (setq startval 6.4) (setq cnt 1) (setq sel (ssget '((0 . "TEXT")))) (if sel (progn ;; Making a list: (entity, Y-coord) (setq txtlist nil) (setq i 0) (while (< i (sslength sel)) (setq ent (ssname sel i)) (setq edata (entget ent)) (setq yval (cadr (assoc 10 edata))) (setq txtlist (cons (list ent yval) txtlist)) (setq i (1+ i)) ) ;; Sorting by Y-coordinate from bottom to top ; (setq sorted (vl-sort txtlist '(lambda (a b) (> (cadr a) (cadr b))))) ; top to bottom? (setq sorted (vl-sort txtlist '(lambda (a b) (< (cadr a) (cadr b))))); bottom to top? ;; Changing values (foreach txt sorted (setq newval (+ startval (* cnt inc))) (setq strval (to3 newval)) (setq ent (car txt)) (setq edata (entget ent)) (setq edata (subst (cons 1 strval) (assoc 1 edata) edata)) (entmod edata) (setq cnt (1+ cnt)) ) (princ " The values of all selected texts are increased progressively.") ) (princ " Single texts are not selected.") ) (princ) )
  14. leonucadomi

    help with routines some don't work...

    THANKS
  15. If its part of your language and not some type of random ascii your using. with a fresh install of windows the language probably needs to be updated in the settings.
  16. Lee you are the bestest!
  17. AutoCAD 2022 is the first version for Windows 11, AutoCAD 2016 with update is first version for Windows 10. Your profile shows AutoCAD 2022. Not that any of that matters, as AutoCAD has nothing to do with your issue as far as I can tell. What program are you using to modify the LISP routines? Windows Notepad also can set options in SaveAs.
  18. Steven P

    Block insert LISP

    That's strange, it worked when I tested it here just now... though Angel_2 was inserted 180 degrees the wrong way - try this fix for that (something to look at later for me for a better fix) (defun c:blockinsert ( / ent MyEnt acount EntCoords MyBlock MyBlockName Ang1 Ang2) ;; Initial Values (setq MyBlockName "Stalb") ;; Change this to your block name ;;Sub functions (defun mAssoc ( key lst / result ) ;; Lee Mac: CadTutor forum (foreach x lst (if (= key (car x)) (setq result (cons (cdr x) result)) ) ) (reverse result) ) (defun LM:getvisibilitystate ( blk / vis ) ;; Lee Mac (if (setq vis (LM:getvisibilityparametername blk)) (LM:getdynpropvalue blk vis) ) ) (defun LM:setdynprops ( blk lst / itm ) ;; Lee Mac (setq lst (mapcar '(lambda ( x ) (cons (strcase (car x)) (cdr x))) lst)) (foreach x (vlax-invoke blk 'getdynamicblockproperties) (if (setq itm (assoc (strcase (vla-get-propertyname x)) lst)) (vla-put-value x (vlax-make-variant (cdr itm) (vlax-variant-type (vla-get-value x)))) ) ) ) (defun SetAng ( Ang1 Ang2 MyEnt / ) ;; From Lee Macs LISPs. Change 'cons' "Angle", "Angle1" to suit dynamic block (lm:setdynprops (vlax-ename->vla-object MyEnt) (list (cons "Angel_1" Ang1) (cons "Angel_2" Ang2))) ; Ang in radians ) (defun AddBlock ( BName Pt XScale YScale ZScale / ) ;; Adds block to the drawing (setq NewBlock (entmakex (list '(0 . "INSERT") (cons 2 BName) (cons 10 Pt) (cons 41 XScale) (cons 42 YScale) (cons 43 ZScale) (cons 50 0); ))) ; end setq entmakex, list NewBlock ) ;; End sub functions (setq Ent (car(entsel "Select LW Polyline"))) (setq MyEnt (entget Ent)) (if (or (equal (cdr (assoc 0 MyEnt)) "LWPOLYLINE") ) ; end or (progn (setq EntCoords (massoc 10 MyEnt)) (setq acount 0) (while (< acount (length EntCoords)) ;;Insert (setq MyBlock (AddBlock MyBlockName (nth acount EntCoords) 1 1 1) ) ;;Ang1 (if (= acount 0) ; First point (progn (setq ang1 (angle (nth acount EntCoords) (nth (+ acount 1) EntCoords) )) ; = ang2 ) ; end progn (progn (setq ang1 (angle (nth acount EntCoords) (nth (- acount 1) EntCoords) )) ) ; end progn ) ; end if ;;Ang2 (if (= acount (- (length EntCoords) 1)) ; last point (progn (setq ang2 (angle (nth acount EntCoords) (nth (- acount 1) EntCoords) )) ; = ang1 ) (progn (setq ang2 (angle (nth acount EntCoords) (nth (+ acount 1) EntCoords) )) ) ) ; end if (SetAng Ang1 Ang2 (entlast)) ;; Sets dynamic block angle (setq acount (+ acount 1)) ) ; end while ) (progn (princ "Polyline not selected") ) ; end progn ) ; end if polyline (princ) ; exit quietly )
  19. BIGAL

    Block insert LISP

    Try this. Not sure what you want for attribute values. Can ask once then will be added correctly. Maybe 3 getstring after pick pline. ; https://www.cadtutor.net/forum/topic/98666-block-insert-lisp/ ; arrows by AlanH Aug 2025 (defun c:wow ( / plent co-ord isclosed x obj ang) ;; Set Dynamic Block Property Value - Lee Mac ;; Modifies the value of a Dynamic Block property (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) ;; val - [any] New value for property ;; Returns: [any] New value if successful, else nil (defun LM:setdynpropvalue ( blk prp val ) (setq prp (strcase prp)) (vl-some '(lambda ( K ) (if (= prp (strcase (vla-get-propertyname k))) (progn (vla-put-value K (vlax-make-variant val (vlax-variant-type (vla-get-value K)))) (cond (val) (t)) ) ) ) (vlax-invoke blk 'getdynamicblockproperties) ) ) (setq plent (entsel "\nPick pline")) (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))) (setq isclosed (cdr (assoc 70 (entget (car plent))))) (setq x 0) (command "-insert" "Stalb" (nth x co-ord) 1 1 0 "" "" "") (setq obj (vlax-ename->vla-object (entlast))) (setq ang (angle (nth x co-ord) (nth (+ x 1) co-ord))) (LM:setdynpropvalue obj "Angel_1" ang) (if (= isclosed 1) (progn (setq ang (angle (nth 0 co-ord) (last co-ord) )) (LM:setdynpropvalue obj "Angel_2" ang) ) ) (repeat (- (length co-ord) 2) (command "-insert" "Stalb" (nth (setq x (1+ x)) co-ord) 1 1 0 "" "" "") (setq obj (vlax-ename->vla-object (entlast))) (setq ang (angle (nth x co-ord) (nth (+ x 1) co-ord))) (LM:setdynpropvalue obj "Angel_1" ang) (setq ang (angle (nth x co-ord) (nth (- x 1) co-ord))) (LM:setdynpropvalue obj "Angel_2" ang) ) (command "-insert" "Stalb" (nth (setq x (1+ x)) co-ord) 1 1 0 "" "" "") (setq obj (vlax-ename->vla-object (entlast))) (setq ang (angle (nth x co-ord) (nth (- x 1) co-ord))) (LM:setdynpropvalue obj "Angel_2" ang) (if (= isclosed 1) (progn (setq ang (angle (nth x co-ord) (nth 0 co-ord) )) (LM:setdynpropvalue obj "Angel_1" ang) ) ) (princ) )
  20. Notepad ++ can set the save mode it has numerous options including Ansi and UTF-8.
  21. Last week
  22. Ivan N

    Block insert LISP

    I made the block again, changed rotations to Angle_1 and Angle_2. Changed in .lsp file too. The script inserts blocks but the angels are not changed. Am am attaching the file, with polyline and inserted block.
  23. Ivan N

    Block insert LISP

    I made the block again, changed rotations to Angle_1 and Angle_2. Changed in .lsp file too. The script inserts blocks but the angels are not changed. Am am attaching the file, with polyline and inserted block. Test.dwg
  24. leonucadomi

    help with routines some don't work...

    I already found the solution, at least temporarily. what I have to do is the original routine (ansi code), modify it if required, but also add an ansi character, example ;ñ only then it lets me save as in ANSI mode and the characters are no longer deleted or changed.
  25. GLAVCVS

    help with routines some don't work...

    I don't think it has anything to do with it. And if it does, it can probably be fixed by configuring the OS.
  26. leonucadomi

    help with routines some don't work...

    I don't know if it has to do with the fact that the autocad I use is the 2013 version.
  27. GLAVCVS

    help with routines some don't work...

    Hi Start by checking which ANSI setting you have on your new OS. Control Panel → Region → Administrative tab → Change system locale button. The system locale should appear in Spanish and the option 'Version beta: Use UTF-8...' should be unchecked.
  28. Steven P

    help with routines some don't work...

    perhaps not the fix you want, but avoid "ñ", do a find and replace, maybe to 'n' ? I would copy the original file to a temporary or archive folder and make the change to the original - so the LISPs will still work until you can work out how to get the correct characters working. Just checking my default text editor is UTF-8 also What do other text editors do and what encoding do they use?
  29. leonucadomi

    help with routines some don't work...

    If I just open and close nothing happens but if I modify my file and save it, even though I use save as ANSI, it still saves it to UTF-8 and deletes characters, and then the routine doesn't work.
  1. Load more activity
×
×
  • Create New...