AldLuj28 Posted June 17, 2015 Posted June 17, 2015 Hi there.. im new in the forum and in coding in AutoLisp... so im looking for a form in which i can extract a specific attribute from all blocks that are in a DWG and then this list write it in a txt file Quote
Tharwat Posted June 17, 2015 Posted June 17, 2015 Welcome to the forum Are you a ware of the command attout ? Quote
AldLuj28 Posted June 17, 2015 Author Posted June 17, 2015 (edited) Yeah im aware of it im trying to do something like this: (defun C:AELD (/ objBlock strValue) (setq AllBlocks (ssget "X" (list (cons 0 "INSERT")))) (repeat (sslength AllBlocks) (setq objBlock (vlax-ename->vla-object (CDR (CAR (entget (ssname AllBlocks)))))) (foreach objAttribute (vlax-invoke objBlock "getattributes") (if (= (strcase (vla-get-tagstring objAttribute)); (strcase "DeviceID")) (progn (setq strValue (vla-get-textstring objAttribute)) ) ) ) (princ strValue) ) ) but it throws me an error : too few arguments Edited June 17, 2015 by rkmcswain added [CODE] tags Quote
Tharwat Posted June 17, 2015 Posted June 17, 2015 Things like this ? (defun c:Test (/ ss sn i e) ;; Tharwat 18.06.2015 ;; (if (setq ss (ssget '((0 . "INSERT") (66 . 1)))) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (while (/= (cdr (assoc 0 (setq e (entget sn)))) "SEQEND") (if (not (eq (cdr (assoc 1 e)) nil)) (print (cdr (assoc 1 e))) ) (setq sn (entnext sn)) ) ) ) (princ) ) Quote
AldLuj28 Posted June 17, 2015 Author Posted June 17, 2015 Yeah something like that but i want that all the blocks are selected automacally.. cause i need a specific attribute from all blocks Quote
Tharwat Posted June 17, 2015 Posted June 17, 2015 cause i need a specific attribute from all blocks Just add "_X" after the ssget function. Quote
AldLuj28 Posted June 17, 2015 Author Posted June 17, 2015 Ok, but if i want to ... find only the attribute named "DevicedID1" that is part from all the blocks, what i need to add.. and one thing more to write this string in a text i can use (setq fil(open "file" "w")? Quote
Tharwat Posted June 17, 2015 Posted June 17, 2015 Try this ... (defun c:Test (/ ss fl on sn i e) ;; Tharwat 18.06.2015 ;; (if (and (setq ss (ssget "_X" '((0 . "INSERT") (66 . 1)))) (setq fl (getfiled "Specify name of txt file" (getvar 'dwgprefix) "txt" 1 ) ) (setq on (open fl "w")) ) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (while (/= (cdr (assoc 0 (setq e (entget sn)))) "SEQEND") (if (and (eq (cdr (assoc 0 e)) "ATTRIB") (eq (strcase (cdr (assoc 2 e))) "DEVICEDID1") ) (write-line (cdr (assoc 1 e)) on) ) (setq sn (entnext sn)) ) ) ) (if on (close on) ) (princ) ) Quote
AldLuj28 Posted June 17, 2015 Author Posted June 17, 2015 (edited) Thanks ..finally i made it work... i changed some stuff ... and the result its this totally functional : (defun c: PROMISE (/ ss fl on sn i e) (if (and (setq ss (ssget "_X" '((0 . "INSERT") (66 . 1)))) (setq on (open "C:\\Temp\\Emblemas.txt" "w")) ) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (while (/= (cdr (assoc 0 (setq e (entget sn)))) "SEQEND") (if (not (eq (cdr (assoc 1 e)) nil)) (if(not(eq (cdr (assoc 1 e)) "")) (princ (strcat "," (cdr (assoc 1 e))) on) ) ) (setq sn (entnext sn)) ) ) ) (if on (close on) ) (princ) ) Again thanks a lot for the help Edited June 17, 2015 by AldLuj28 Quote
Tharwat Posted June 18, 2015 Posted June 18, 2015 Ok, but if i want to ... find only the attribute named "DevicedID1" that is part from all the blocks, what i need to add.. and one thing more to write this string in a text i can use (setq fil(open "file" "w")? Thanks ..finally i made it work... i changed some stuff ... and the result its this totally functional : Firstly , what you have modified is not matching or following what you have asked in your previous post . Secondly , it is a very bad idea to remove the author name from my codes or anyone's codes/ works. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.