mstb Posted June 7, 2020 Posted June 7, 2020 hello everybody I want to get tag , prompt , value of block attributes with lisp. but it is impossible with entget ? excuseme for my bad english Quote
dlanorh Posted June 7, 2020 Posted June 7, 2020 3 hours ago, mstb said: hello everybody I want to get tag , prompt , value of block attributes with lisp. but it is impossible with entget ? excuseme for my bad english You will have to expand on what you want. Do you have to use entget or will Visual lisp do equally as well? Do you want all Attributes for a selected block reference or all attributed blocks in the block table? If it is the block table option you are restricted to the default value string if any. Quote
rlx Posted June 7, 2020 Posted June 7, 2020 think OP wants something like this (an oldie from Fixo i believe) (vl-load-com)(defun C:demo (/ blockdata blockdef blockname blockref en ent tmp) (if (setq ent (entsel "\n >> Select a block instance >>")) (progn (setq en (car ent) blockref (vlax-ename->vla-object en) blockname (vla-get-effectivename blockref) blockdef (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) blockname) ) (if (equal :vlax-true (vla-get-hasattributes blockref)) (progn (foreach attrib (vlax-invoke blockref 'GetAttributes) (vlax-for item blockdef (if (equal (vla-get-objectname item) "AcDbAttributeDefinition") (progn (if (equal (vla-get-tagstring attrib) (vla-get-tagstring item)) (progn (setq tmp (list (vla-get-promptstring item) (vla-get-tagstring attrib) (vla-get-textstring attrib))) (setq blockdata (cons tmp blockdata)) ) ) ) ) ) ) (setq blockdata(reverse blockdata) ) (foreach lst blockdata (princ (strcat "\n Prompt: " (car lst) " *** Tag: " (cadr lst) " *** Value: " (last lst))) ) ) ) ) (princ "\n >> Nothing selected. Try again...") ) (princ) ) (prompt "\n >> Type DEMO to execute..." ) (prin1) found it here 1 Quote
mstb Posted June 7, 2020 Author Posted June 7, 2020 2 hours ago, rlx said: think OP wants something like this (an oldie from Fixo i believe) (vl-load-com)(defun C:demo (/ blockdata blockdef blockname blockref en ent tmp) (if (setq ent (entsel "\n >> Select a block instance >>")) (progn (setq en (car ent) blockref (vlax-ename->vla-object en) blockname (vla-get-effectivename blockref) blockdef (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) blockname) ) (if (equal :vlax-true (vla-get-hasattributes blockref)) (progn (foreach attrib (vlax-invoke blockref 'GetAttributes) (vlax-for item blockdef (if (equal (vla-get-objectname item) "AcDbAttributeDefinition") (progn (if (equal (vla-get-tagstring attrib) (vla-get-tagstring item)) (progn (setq tmp (list (vla-get-promptstring item) (vla-get-tagstring attrib) (vla-get-textstring attrib))) (setq blockdata (cons tmp blockdata)) ) ) ) ) ) ) (setq blockdata(reverse blockdata) ) (foreach lst blockdata (princ (strcat "\n Prompt: " (car lst) " *** Tag: " (cadr lst) " *** Value: " (last lst))) ) ) ) ) (princ "\n >> Nothing selected. Try again...") ) (princ) ) (prompt "\n >> Type DEMO to execute..." ) (prin1) found it here Thank you very much Quote
mstb Posted June 7, 2020 Author Posted June 7, 2020 4 hours ago, dlanorh said: You will have to expand on what you want. Do you have to use entget or will Visual lisp do equally as well? Do you want all Attributes for a selected block reference or all attributed blocks in the block table? If it is the block table option you are restricted to the default value string if any. Thank you very much Quote
dlanorh Posted June 7, 2020 Posted June 7, 2020 3 hours ago, rlx said: think OP wants something like this (an oldie from Fixo i believe) (vl-load-com)(defun C:demo (/ blockdata blockdef blockname blockref en ent tmp) (if (setq ent (entsel "\n >> Select a block instance >>")) (progn (setq en (car ent) blockref (vlax-ename->vla-object en) blockname (vla-get-effectivename blockref) blockdef (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) blockname) ) (if (equal :vlax-true (vla-get-hasattributes blockref)) (progn (foreach attrib (vlax-invoke blockref 'GetAttributes) (vlax-for item blockdef (if (equal (vla-get-objectname item) "AcDbAttributeDefinition") (progn (if (equal (vla-get-tagstring attrib) (vla-get-tagstring item)) (progn (setq tmp (list (vla-get-promptstring item) (vla-get-tagstring attrib) (vla-get-textstring attrib))) (setq blockdata (cons tmp blockdata)) ) ) ) ) ) ) (setq blockdata(reverse blockdata) ) (foreach lst blockdata (princ (strcat "\n Prompt: " (car lst) " *** Tag: " (cadr lst) " *** Value: " (last lst))) ) ) ) ) (princ "\n >> Nothing selected. Try again...") ) (princ) ) (prompt "\n >> Type DEMO to execute..." ) (prin1) found it here It is indeed "Fixo" as I recognise the photo. Sadly missed. Quote
rlx Posted June 7, 2020 Posted June 7, 2020 sadly never had the pleasure of 'meeting' him but his legacy lives on for years to come. Quote
pBe Posted June 7, 2020 Posted June 7, 2020 (edited) Quote 11 hours ago, mstb said: ..but it is impossible with entget ?.. Similar to what fixo had, thru the block definition. (defun getAttdefData ( bn / ent enx lst ) (if (setq ent (tblobjname "block" bn)) (while (setq ent (entnext ent)) (if (= "ATTDEF" (cdr (assoc 0 (setq enx (entget ent))))) (setq lst (cons (mapcar '(lambda (n)(cdr (assoc n enx))) '(2 1));<-- add more att prop here TEXTSTYLE HEIGHT etc. lst ) ) ) ) ) lst ) This is way faster than VL. I have not personally met Fixo, our correspondents was limited to emails, asking me from time to time to test a code he's woking on, eventually the messages became more about life and christimas greeting and the like. For the longest time he was egging me to learn .NET and was even kind enough to share his code snippets thru Dropbox. I miss his enthusiasm most of all. The man is truly a legend. pBe Edited June 7, 2020 by pBe 1 Quote
dlanorh Posted June 7, 2020 Posted June 7, 2020 1 hour ago, pBe said: I have not personally met Fixo, our correspondents was limited to emails, asking me from time to time to test a code he's woking on, eventually the messages became more about life and christimas greeting and the like. For the longest time he was egging me to learn .NET and was even kind enough to share his code snippets thru Dropbox. I miss his enthusiasm most of all. The man is truly a legend. pBe Quote
lido Posted June 8, 2020 Posted June 8, 2020 This is the version that I use (short and fast): (defun GetAtt (/ b ls_prt ls_tag ls_val) (if (setq b (entsel "\nSelect block: ")) (progn (setq b (vlax-ename->vla-object (car b))) (if (= (vla-get-objectname b) "AcDbBlockReference") (progn (vlax-for item (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vla-get-name b)) (if (= (vla-get-objectname item) "AcDbAttributeDefinition") (setq ls_prt (cons (vla-get-promptstring item) ls_prt) ;;PROMPT List ls_tag (cons (vla-get-tagstring item) ls_tag) ;;TAG List ls_val (cons (vla-get-textstring item) ls_val) ;;VALUE List ;; Other block attribute properties... ) ) ) (if ls_prt (list ls_prt ls_tag ls_val)(prompt "\nSelected block has no attributes.")) ) (prompt "\nSelected entity is not block.") ) ) (prompt "\nNothing selected.") ) ) ;;GetAtt Quote
rlx Posted June 8, 2020 Posted June 8, 2020 never was the most clever dragon at dragon school but wont just double click on one of the attributes not open the enhanced attribute editor and give you all this info? Quote
pBe Posted June 8, 2020 Posted June 8, 2020 (edited) 16 minutes ago, lido said: This is the version that I use (short and fast): Sorry to burst your bubble Lido, that version is not short and definitely NOT fast. (GETATTDEFDATA "AblockName")......2078 / 6.99 <fastest> (_VLDATA AVlaObject).............14516 / 1.00 <slowest> Edited June 8, 2020 by pBe Quote
pBe Posted June 8, 2020 Posted June 8, 2020 6 minutes ago, rlx said: never was the most clever dragon at dragon school but wont just double click on one of the attributes not open the enhanced attribute editor and give you all this info? That is true. But we need to honor the OP Quote I want to get tag , prompt , value of block attributes with lisp. Quote
rlx Posted June 8, 2020 Posted June 8, 2020 8 minutes ago, pBe said: That is true. are you referring to the school part or the editor part? I was only wondering , once OP has this info what he (or she) is going to do with it. If its just one block, using a lisp seems like overkill. Use it on all the blocks in a dwg or all dwgs in a folder would be more interesting but still I wonder what's next That VL can be very slow I found out recently. Was making an app to redefine blocks with option for cur->all (current dwg to all open dwgs) , cur->dbx / cur->dbx folder etc etc. and I was surprised , and not in a good way , how slow it was. Its fine for a couple of blocks and a few drawings but for mass production gonna go old school and just use a script or core console and just use insert ...=... and be done with it. Quote
pBe Posted June 8, 2020 Posted June 8, 2020 10 minutes ago, rlx said: are you referring to the school part or the editor part? The dragon at the school of course 1 Quote
lido Posted June 8, 2020 Posted June 8, 2020 1 hour ago, pBe said: Sorry to burst your bubble Lido, that version is not short and definitely NOT fast. (GETATTDEFDATA "AblockName")......2078 / 6.99 <fastest> (_VLDATA AVlaObject).............14516 / 1.00 <slowest> @pBe Neither of the two functions belongs to me. By the way, where does the "_VLDATA" function come from? Quote
pBe Posted June 8, 2020 Posted June 8, 2020 (edited) 27 minutes ago, lido said: @pBe Neither of the two functions belongs to me. Don't mean anything by it lido. At least now you know right? 27 minutes ago, lido said: ..By the way, where does the "_VLDATA" function come from? It this bit off the code you posted: (defun _VLDATA (b / ls_prt ls_tag ls_val) (vlax-for item (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vla-get-name b)) (if (= (vla-get-objectname item) "AcDbAttributeDefinition") (setq ls_prt (cons (vla-get-promptstring item) ls_prt) ;;PROMPT List ls_tag (cons (vla-get-tagstring item) ls_tag) ;;TAG List ls_val (cons (vla-get-textstring item) ls_val) ;;VALUE List ;; Other block attribute properties... ) ) ) ) I merely gave it a function name. [ Tested on a Dynamic Block with 8 Attributes ] Although I would take VL approach if I have to use ODBX. Edited June 8, 2020 by pBe Quote
devitg Posted July 30, 2020 Posted July 30, 2020 On 6/7/2020 at 1:53 PM, pBe said: Similar to what fixo had, thru the block definition. This is way faster than VL. I have not personally met Fixo, our correspondents was limited to emails, asking me from time to time to test a code he's woking on, eventually the messages became more about life and christimas greeting and the like. For the longest time he was egging me to learn .NET and was even kind enough to share his code snippets thru Dropbox. I miss his enthusiasm most of all. The man is truly a legend. pBe Quote Hi pBe, It is sad to say that FIXO had passed away a few years ago , He was one of my teachers, and a good friend at the distance, He from St Petersburg, I from Cordoba Argentina. If you see his avatar he show a tv Screen with the Argentina Flag, it was from a former Football World Cup, maybe Germany. Quote
hosyn Posted July 31, 2020 Posted July 31, 2020 (edited) 19 hours ago, devitg said: i am getting so sad for hearing that, so many times i was looking for his post, i suspect to bad event for him, he was great, in initial years at (maybe 2008~2010) once i attend to this furrom often put post for helping me We dont remmember you fixo great lisp coder Edited July 31, 2020 by hosyn 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.