Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/26/2023 in all areas

  1. @mhuppFWIW ;; This (setq atts (vlax-safearray->list (vlax-variant-value (vla-getattributes blk)))) ;; Returns the same as this (setq atts (vlax-invoke blk 'getattributes)) ;; At least in AutoCAD
    2 points
  2. (defun c:t1 ( / ss l mid-pt ss->el) (defun mid-pt (e / x) (setq x (entget e))(mapcar '* (mapcar '+ (cdr (assoc 10 x)) (cdr (assoc 11 x))) '(0.5 0.5 0.5))) (defun ss->el (ss / i l) (setq i 0)(repeat (sslength ss)(setq l (cons (ssname ss i) l) i (1+ i))) l) (if (setq ss (ssget (list (cons 0 "Line")))) (setq l (vl-sort (ss->el ss) '(lambda (a b) (< (cadr (mid-pt a)) (cadr (mid-pt b))))))) (setq ss (ssadd) i -2) (while (setq e (nth (setq i (+ i 2)) l))(ssadd e ss)) (command "chprop" ss "" "color" "red" "") ) load code , start with t1 or (c:t1) , select the lines with window or crossing (no problem selecting the leaders also because they are filtered out anyway so don't worry , be happy) et voila...
    1 point
  3. @elli0t Find attached lisp and result dwg the new command is LAST-CELL sum table last cell.LSP sum Tables last cell.dwg
    1 point
  4. Build a selection set of blocks with attributes. for each block step thought each attribute and save the "type" and "manufacturer_code" if type is a matches a predefined list '("Base Cabinets" "Wall Cabinets" "Tall Cabinets") then get a bounding box of the current block. calculate the mid point and create text with the "manufacturer_code" at the mid point. ;;----------------------------------------------------------------------------;; ;; Pull Manufacturer_Code for cabinets and input them center of block (defun C:CAB-Label (/ Drawing ss blk atts att typ man minpt maxpt MPT) (vl-load-com) (setq i 0) (vla-startundomark (setq Drawing (vla-get-activedocument (vlax-get-acad-object)))) (prompt "\nSelect Blocks: ") (while (setq ss (ssget '((0 . "INSERT") (66 . 1)))) ;allows user to make multiple selections (setvar 'cmdecho 0) (foreach blk (mapcar 'vlax-Ename->Vla-Object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))) (setq atts (vlax-invoke blk 'getattributes)) (setq typ "" man "") (foreach att atts (cond ((= (vla-get-tagstring att) "Type") (setq typ (vla-get-textstring att)) ) ((= (vla-get-tagstring att) "Manufacturer_Code") (setq man (vla-get-textstring att)) ) ) ) (if (member typ '( "Base Cabinets" "Wall Cabinets" "Tall Cabinets")) ;update list for other blocks (progn (vla-GetBoundingBox blk 'minpt 'maxpt) (setq MPT (mapcar '/ (mapcar '+ (vlax-safearray->list minpt) (vlax-safearray->list maxpt)) '(2 2 2))) (entmake (list '(0 . "TEXT") (cons 10 MPT) (cons 11 MPT) (cons 40 (getvar 'textsize)) (cons 1 man) '(62 . 1) '(72 . 1) '(73 . 2))) (setq i (1+ i)) ) ) ) ) (prompt (strcat "\n" (itoa i) " Cabinets labeled")) ;message at the end (vla-endundomark Drawing) (setvar 'cmdecho 1) (princ) )
    1 point
  5. Try applying a 90% Transparency to your rectangular block. Then use either HIDDEN or CONCEPTUAL Visual Style
    1 point
  6. Yeah, it's doable. It takes a few steps. The basic idea: - 2 lisp files; "parent_lisp.lsp" and "batch_execute.lsp" - Open a drawing, , load parent_lisp.lsp, execute BOF (batch open files) - "batch_execute.lsp" should be included in the files that get auto loaded any time a drawing is opened, see: https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/Automatically-load-AutoLISP-routines.html now, "batch_execute.lsp" holds a variable (setq specified_folder "C:\\Data\\desktop\\lisp\\CADTUTOR\\batch_execute\\") If the drawing is saved in that folder, then a function gets executed. Else it's ignored. Obviously set this specified_folder to your folder. don't forget each \ must get doubled to \\, and finish with \\. When you no longer need this batch auto execute, then remove "batch_execute.lsp" from the list of auto loaded lisp files. I tried it, it works. You might try it for a limited number of dwg's. You may get a RAM overload or something. ------- "parent_lisp.lsp" ;; @file this file opens all drawings in a specified folder. (vl-load-com) (setq specified_folder "C:\\Data\\desktop\\lisp\\CADTUTOR\\batch_execute\\") ;; don't forget the \\ at the end ;; substring, like php substr (defun substring ( str idx len ) (substr str (if (< idx 0) (+ 1 (strlen str) idx) (1+ idx)) len) ) (defun open_file (FileName ReadOnly / ) (vla-Open (vla-get-Documents (vlax-get-Acad-Object) ) FileName (if ReadOnly :vlax-true :vlax-false ) ) ) ;; command BOF, for Batch Open Files (defun c:bof ( / path allfiles FileName) ;; path of the drawings that need to be opened, and the batch function executed on each drawing (setq path specified_folder) ;; find all the drawings in that folder ;; @see https://www.cadtutor.net/forum/topic/50837-list-of-drawings-in-a-folder/ (setq allfiles (vl-directory-files path "*.DWG" 0)) (princ allfiles) (foreach FileName allfiles (open_file (strcat path FileName) ReadOnly) (Command "DELAY" "2000") ; Pause a couple seconds ) ) "batch_execute.lsp": ;; @file this file is to be auto loaded when a drawing opens: see (1). Then check the folder in which the drawings are saved. ;; If that folder is the specified foler (setq specified_folder ...), then execute a function. ;; Then close the drawing ;; (1) https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/Automatically-load-AutoLISP-routines.html (vl-load-com) (setq specified_folder "C:\\Data\\desktop\\lisp\\CADTUTOR\\batch_execute\\") ;; don't forget the \\ at the end (defun auto_execute ( / dwg_path) (setq dwg_path (getvar "DWGPREFIX")) (if (= specified_folder dwg_path) (do_batch_function) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; as an example, do_batch_function will write the filename of the dwg on the drawing, on x,y = 0,0 ;; https://www.cadtutor.net/forum/topic/18257-entmake-functions/ (defun drawText (pt hgt str) (entmakex (list (cons 0 "TEXT") (cons 10 pt) (cons 40 hgt) (cons 1 str)))) (defun do_batch_function ( / ) (drawText (list 0.0 0.0) 2.5 (getvar "dwgname")) (command "QSAVE") ;;(command "CLOSE") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (auto_execute)
    1 point
×
×
  • Create New...