Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/17/2021 in all areas

  1. Once you know the differences between the two functions QUOTE and LIST then you will know the answer by yourself.
    1 point
  2. A quick and dirty, if happy post in your other forums where you have asked. (defun c:attex ( / blkname ss blk xy att str fo) (setq fo (open (setq fname "D:\\acadtemp\\attexport.csv") "w")) (setq blkname (cdr (assoc 2 (entget (car (entsel "\nPick block for name ")))))) (prompt "\nSelect blocks ") (setq ss (ssget (list (cons 0 "INSERT")(cons 2 blkname)))) (repeat (setq x (sslength ss)) (setq str "") (setq blk (ssname ss (setq x (1- x)))) (setq xy (cdr (assoc 10 (entget blk)))) (setq str (strcat blkname "," (rtos (car xy) 2 3) "," (rtos (cadr xy) 2 3))) (foreach att (vlax-invoke (vlax-ename->vla-object blk) 'getattributes) (setq str (strcat str "," (vla-get-textstring att))) ) (princ str) (write-line str fo) ) (close fo) (princ) ) (c:attex)
    1 point
  3. Here is my set of routines, I may have missed including some helper routines. I use it with a reactor to automatically export my symbol and ight fixture blocks and then I have an excel spreadsheet that reads the data files to create schedules. An example export is attached. (defun c:SAA_ExportKeynoteValues () (SAA_ExportKeynoteValues (list "#" "DOOR" "DTL" "E" "FLR1" "FUNCTION" "GLAZING" "KEYNOTE" "LOCATION" "MATERIAL" "MAT1" "MAT2" "MOD" "MOD1" "MOD2" "MODIFIER" "NOTES" "NUMBER" "SHT" "TYPE" "WIN" "WT" "WIDTH" "x" "HEIGHT" ) ;_list ) ;_SAA (princ) ) (defun SAA_ExportKeynoteValues (tagList / tagList ss i aList csvfilename) (if (setq ss (ssget "X" '((0 . "INSERT") (-4 . "<OR") (-4 . "<AND")(2 . "sym*") (8 . "A-Anno*") (-4 . "AND>") (-4 . "<AND")(2 . "p-light*")(8 . "A-Clng-Lfix")(-4 . "AND>") (-4 . "OR>") (66 . 1) ;66 filters for blocks with attributes (assumed meaning?) )) ) ;_ssget (progn ;; create header (in reverse order of txt export file) (setq aList (list "EXPORTDATE" "BLOCKNAME" "HANDLE" )) (foreach tag tagList (setq aList (cons tag aList))) (setq aList (list (SAA_List2String (reverse aList) "\t"))) ;; cycle through blocks and create list of attribute values (repeat (setq i (sslength ss)) (setq aList (cons (SAA_List2String (SAA_getKeynoteAttributeValues (vlax-ename->vla-object (ssname ss (setq i (1- i)))) tagList ) ;_SAA "\t" ) ;_SAA_List2String aList ) ;_list ) ;_setq ) ;_repeat (setq aList (reverse aList)) ;; write list to file (SAA_WriteList2File alist (setq csvfilename (strcat (getvar "dwgprefix")(vl-filename-base (getvar "dwgname")) "_queryExport.txt"))) (princ (strcat "\n" (vl-filename-base (getvar "dwgname")) "_queryExport.txt - values exported")) (saa_debugPrinc (strcat " to: " (strcat csvfilename))) ) ;_progn ) ;_if (princ) ) ;;;============================================================================== ;;; List to String - by Lee Mac (renamed) ;;; Concatenates each string in a supplied list, separated by a given delimiter ;;; lst - [lst] List of strings to concatenate ;;; del - [str] Delimiter string to separate each item ;;;============================================================================== (defun SAA_List2String ( lst del ) (if (cdr lst) (strcat (car lst) del (SAA_List2String (cdr lst) del)) (car lst) ) ) ;;;------------------------------------------------------------;; ;;; get block attributes based on order of attribute list provided ;;; blk - [vla] VLA Block Reference Object ;;; attList - list of string names for atributes ;;; return example: ("'10CE39" "sym-keynote02" "11.4" "Qty (2)" "NIL") ;;; Inspired by Lee-Mac routines ;;;------------------------------------------------------------;; (defun SAA_getKeynoteAttributeValues ( blk attList / varPrefix aList attValue) (setq varPrefix "SAA_getKeynoteAttributeValues_") ;; cycle through block attributes to save list of values (mapcar '(lambda ( att ) (if (member (vla-get-tagstring att) attList) ;; save attribute value to temporary variable name ;; will be part of a list in order of passed in attribute list (set (read (strcat varPrefix (vla-get-tagstring att))) (vla-get-textstring att)) ) ;_if ) ;_lambda (vlax-invoke blk 'getattributes) ) ;_mapcar ;; create list initial data - uses standard header format of "HANDLE" "BLOCKNAME" "EXPORTDATE" ;; defined in SAA_ExportKeynoteValues lisp (setq alist (list (strcat "'" (vla-get-Handle blk)) ;block handle (vla-get-effectivename blk) ;block name (menucmd "M=$(edtime, $(getvar, date),MO.dd.YY HH:MM)") ;date & time of export ) ;_list ) ;; cycle through passed in list of attribute values ;; create a list of block data & attribute values ;; matching format of ATTEXT row data (foreach att attList (setq attValue (read (strcat varPrefix att))) (if (eval attValue) (setq aList (append aList (list (eval attValue))) attValue nil ;clear variable ) ;_setq (setq aList (append aList (list "nil")) ) ;_setq ) ) ;_foreach ;; cycle through and clear passed in list of attribute values ;; as the temp variables are saved as global (foreach att attList (set (read (strcat varPrefix att)) nil) ) ;_foreach aList ;;;========================================================== ;;; Write List to File ;;; write each list item to separate line ;;;========================================================== (defun SAA_WriteList2File ( lst fname / out_file ) (if (setq out_file (open fname "w")) (progn (foreach row lst (princ (strcat row "\n") out_file)) (close out_file) T ) ) ) borica_rcp_queryExport.txt
    1 point
  4. Why not just load it with acad.lsp? As long as ACADLSPASDOC (System Variable) is set to it's initial value of 0 acad.lsp only loads when the first drawing is opened in a session. Don't use acaddoc.lsp to load it as it would load every time a drawing is opened which works well for most lisp routines.
    1 point
×
×
  • Create New...