Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/30/2024 in all areas

  1. The (command "layout" "s" (entlast) ) needs to be changed but isn't a terminal error in the routine - on my system - it will keep going for me. I think the error that the OP has starts at the (ssget "w".... ) line, if the zoom isn't showing the window nothing is selected. (waiting for the OP to come back and show what they have worked out or to ask for more guidance)
    1 point
  2. @quocphuoc This code has a multitude of problems and honestly does not make much sense when I tried to break it down. For Example: you are experiencing your first error with the LAYOUT command. (command "LAYOUT" "s" (entlast)) you need to have a STRING here representing a layout name to set: (command "LAYOUT" "s" "MyLayoutName") There are some viewport creation routines out there for Free that will do what you want. This code will not get you what you want, and will not even run without many errors. Try this one revised by Roy_043: https://www.theswamp.org/index.php?topic=47145.msg523226#msg523226 Another from Lee Mac: Here is one for Free from the App Store: https://apps.autodesk.com/ACD/en/Detail/Index?id=2430986909281925511&appLang=en&os=Win32_64
    1 point
  3. I set my temp file to d:\acadtemp much shorter and easier to find. Re temp files SV$, AC$hsdkjdsksj DWL1 & dwl2 to mention a few. The Vlmktmp are meant to be auto removed on closing CAD. Anyway here is cleanup.lsp, you may be horrified how much junk you have in that temp directory.Multi toggles.lsp save multi toggles to a support path as its auto loaded. cleanup temp.lsp
    1 point
  4. @Jozef13 ;; Change this (setq blockname (cdr (assoc 2 (entget blkobj)))) ;; To this (setq blockname (getpropertyvalue blkobj "BlockTableRecord/Name")) ;; Then change this (setq sel (ssget (list (cons 0 "INSERT") (cons 2 blockname)))) ;; To this (if (setq sel (ssget (list '(0 . "INSERT") (cons 2 (strcat "`*U*," blockname))))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex sel))) (or (= blockname (getpropertyvalue e "BlockTableRecord/Name")) (ssdel e sel)) ) )
    1 point
  5. Like this: Those first lines of the main function that asks for user input, feel free to change the order of those lines (per 2 or 3 lines) You get an extra option: "X" is from left to right, "-X" is from right to left. Dito for Y. Command INC and follow the instructions in the command line. Test dwg as attachment ;; @FILE increment a selected attribute on multiple blocks, sorted by X or Y coordinate of the block insert. (vl-load-com) ;; http://www.lee-mac.com/attributefunctions.html#alsetattributevaluerc ;; Set Attribute Value - Lee Mac ;; Sets the value of the first attribute with the given tag found within the block, if present. ;; blk - [ent] Block (Insert) Entity Name ;; tag - [str] Attribute TagString ;; val - [str] Attribute Value ;; Returns: [str] Attribute value if successful, else nil. (defun LM:setattributevalue ( blk tag val / enx ) (if (and (setq blk (entnext blk)) (= "ATTRIB" (cdr (assoc 0 (setq enx (entget blk)))))) (if (= (strcase tag) (strcase (cdr (assoc 2 enx)))) (if (entmod (subst (cons 1 val) (assoc 1 (reverse enx)) enx)) (progn (entupd blk) val ) ) (LM:setattributevalue blk tag val) ) ) ) (defun c:inc ( / sel i blkobj blockname start_inc val increase_by sort_by a sel_att x_coords y_coords sortedi blk ip) ;; FEEL FREE TO CHANGE THE ORDER OF THESE COMMANDS. ;; start increment by number: (setq start_inc (getint "\nStart increment by number: ")) ;; increase by how much: (setq increase_by (getint "\nIncrease by how much: ")) ;; sort by X or Y? (setq sort_by (strcase (getstring "\nSort by X (left to right), Y (bottom to top) -X (right to left) or -Y (top to bottom) : "))) ;; select attribute (setq a (nentsel "\nSelect attribute: ")) (setq sel_att (cdr (assoc 2 (entget (car a))))) (setq blkobj (cdr (assoc 330 (entget (car a))))) ;; get the block (setq blockname (cdr (assoc 2 (entget blkobj)))) ;; get the blockname (princ "\nBlock: ") (princ blockname) (princ " - attribute: ") (princ sel_att) ;; Do this last. We only know the blockname after we pick the attribute. ;; select blocks (princ "\nSelect blocks: ") (setq sel (ssget (list (cons 0 "INSERT") (cons 2 blockname) ))) ;; ;; read coordinates of the blocks (setq i 0) (setq x_coords (list)) (setq y_coords (list)) (repeat (sslength sel) (setq blk (ssname sel i)) (setq ip (cdr (assoc 10 (entget blk)))) ;; insert point (setq x_coords (append x_coords (list (nth 0 ip)))) (setq y_coords (append y_coords (list (nth 1 ip)))) (setq i (+ i 1)) ) (setq sortedi (list)) ;; sortedi will be the order of the blocks. (if (= sort_by "X") (setq sortedi (vl-sort-i x_coords '<)) ) (if (= sort_by "-X") (setq sortedi (vl-sort-i x_coords '>)) ) (if (= sort_by "Y") (setq sortedi (vl-sort-i y_coords '<)) ) (if (= sort_by "-Y") (setq sortedi (vl-sort-i y_coords '>)) ) ;; now loop over the blocks, in order of sortedi (setq val start_inc) (foreach i sortedi (setq blk (ssname sel i)) (LM:setattributevalue blk sel_att (itoa val)) ;; increase (setq val (+ val increase_by)) ) (princ) ) (Edited the code 13-12-2023) increment_xy.dwg
    1 point
  6. Some good examples pBe Here's another method which avoids the double iteration (since we don't care which text object is removed): (defun c:delduptxt ( / e i l s v ) (if (setq s (ssget "_:L" '((0 . "TEXT")))) (repeat (setq i (sslength s)) (setq i (1- i) e (ssname s i) v (cdr (assoc 1 (entget e))) ) (if (member v l) (entdel e) (setq l (cons v l))) ) ) (princ) )
    1 point
  7. (defun C:RSHX () (vl-load-com) (vlax-for item (vla-get-textstyles (vla-get-ActiveDocument (vlax-get-acad-object)) ) (if (not (vl-filename-extension (setq fname (vla-get-fontfile item))) ) (setq fname (strcat fname ".shx")) ) (cond ((findfile fname) nil) ((findfile (strcat (getenv "WINDIR") "\\FONTS\\" fname)) nil ) (t (vla-put-fontfile item "ltypeshp.shx") (princ "\nChange ") (princ fname) (princ " on ltypeshp.shx") ) ) ) (princ) ) (princ "\nRSHX , purge unreferenced shape files")
    1 point
×
×
  • Create New...