Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/29/2025 in Posts

  1. yes. you are right. thank so much
    1 point
  2. Hi I haven't looked into this in depth. But at first glance, it seems like you might have a problem with the variable 'n': it's in the main function and reappears in the auxiliary function 'taviz'. This wouldn't be a problem if 'n' were a local variable to 'taviz', but it isn't. Therefore, when 'taviz' is called from 'c:b', the value of 'n' is modified, which can cause objects to be processed multiple times or, conversely, not at all, as seems to be your case. Therefore: try changing this '(defun taviz (so)' to this '(defun taviz (so / n)'
    1 point
  3. gracias, ahora está bien, estudiaré los cambios)))
    1 point
  4. So you want the objects inside the block on non-0 layers or just the blocks? Normally you would want just the blocks on a layer and everything inside on Layer 0. If you could post a before and after example, a LISP solution should be possible.
    1 point
  5. I have ignored the set bylayer and continuous rather removing the nested blocks and moving objects to the top level with correct block name which I think was the original request, can do the other 2 steps when that works. Out of the 120 blocks after running code found 20 still as *Uxx" name so something not quite right. More searching and some blocks have name of Uxx the problem is that these blocks have an effective name of Uxx, so even if nesting is removed the block will still have an anonymous name. These blocks need a rename.
    1 point
  6. Only the changes I explained to you were necessary.
    1 point
  7. (defun c:Df2Column (/ col1 col2 n1 n2 p1 p2 p3 basept dy txt1 txt2 i ent1 ent2 l1 l2 ordena) (defun ordena (cj1 cj2 / e l n m c) (foreach cj (list cj1 cj2) (setq l (cons (vl-sort (while (setq e (ssname cj (setq n (if n (1+ n) 0)))) (setq c (cons (list (caddr (assoc 10 (entget e))) e) c)) ) '(lambda (a b) (> (car a) (car b))) ) l ) c nil n nil ) ) (setq l1 (cadr l) l2 (car l)) ) (princ "\nSelect the texts of the first column: ") (setq col1 (ssget '((0 . "TEXT,MTEXT")))) (if (not col1) (progn (princ "\nThe objects of the first column are not selected." ) (exit) ) ) (princ "\nSelect the texts of the second column: ") (setq col2 (ssget '((0 . "TEXT,MTEXT")))) (if (not col2) (progn (princ "\nThe objects of the second column are not selected." ) (exit) ) ) (if (/= (sslength col1) (sslength col2)) (progn (princ "\nThe number of objects in the columns does not match." ) (exit) ) ) (ordena col1 col2) (princ "\nSpecify the insertion point of the third column: ") (setq basept (getpoint)) ;; Defining the step by Y between the elements of the second column ;;; (setq ent2a (ssname col2 0)) ;;; (setq ent2b (ssname col2 1)) ;;; (setq y1 (cadr (cdr (assoc 10 (entget ent2a))))) ;;; (setq y2 (cadr (cdr (assoc 10 (entget ent2b))))) ;;; (setq dy (- y2 y1)) (setq i 0) (repeat (length l1);(sslength col1) (setq ent1 (cadr (nth i l1)));(ssname col1 i)) (setq ent2 (cadr (nth i l2)));(ssname col2 i)) (setq txt1 (cdr (assoc 1 (entget ent1)))) (setq txt2 (cdr (assoc 1 (entget ent2)))) (setq n1 (atof txt1)) (setq n2 (atof txt2)) (if (and n1 n2) (progn (setq p3 (list (car basept) (car (nth i l2)) 0.0)) ;(+ (cadr basept) (* i dy)) 0.0)) (entmakex (list (cons 0 "TEXT") (cons 8 (cdr (assoc 8 (entget ent2)))) (cons 10 p3) (cons 40 (cdr (assoc 40 (entget ent2)))) (cons 1 (if (> (- n1 n2) 0) (strcat "+" (rtos (- n1 n2) 2 3)) (rtos (- n1 n2) 2 3) ) ) ) ) ) ) (setq i (1+ i)) ) (princ) )
    1 point
  8. You have block inside a block not sure why. You need to recreate the block with the original name, use explode twice, then Block command selecting all objects use original name and insertion point. This was my attempt as a starting point, 1st step was objects are at Z= 1e-13. need to look at each block and check. If exploded block name becomes a "*Uxx" Code removed see latest post.
    1 point
  9. "my intention was to write something to decompress the ODS" as the ODS file is a zipped xml have you tried this in lisp. It will unzip the ODS to a directory. You need to copy ODS and rename to zip. Use vl file copy, must be a ZIP file. (vl-mkdir "c:\\CAD-TOOLS") (setq filename (getfiled "Select the File \"CAD-TOOLS-SEP-2022\"" "" "ZIP" 16)) ; unzip (startapp (strcat "powershell -command Expand-Archive -Path '" filename "' -DestinationPath 'C:/CAD-TOOLS' -FORCE")) (alert "programs unzipped to C:/CAD-TOOLS")
    1 point
  10. (defun c:test ( / *error* osm ) (defun *error* ( msg ) (if osm (setvar 'osmode osm)) ;; <--- Restoring OSMODE to the original value in the case of an error (if (not (member msg '("Function cancelled" "quit / exit abort"))) (princ (strcat "\nError: " msg)) ) (princ) ) (setq osm (getvar 'osmode)) ;; <--- Storing the current value of OSMODE (setvar 'osmode 0) ;; <--- Setting OSMODE to something new (rtos (getreal "\nPress Esc to exit, press Enter to force an error ...")) (setvar 'osmode osm) ;; <--- Restoring OSMODE to the original value (princ) ) Consider the above example from my tutorial - note the comments indicating where the original OSMODE value is stored and then restored.
    1 point
×
×
  • Create New...