Is there a GATTE equivalent for LT2025

Is there a GATTE equivalent for LT2025

h_s_walker
Mentor Mentor
2,792 Views
52 Replies
Message 1 of 53

Is there a GATTE equivalent for LT2025

h_s_walker
Mentor
Mentor

Ok so we will do drawings, sometimes with many pages.

In our title block with have an attribute for the name of the client.

Originally it is blank, but quite often the project leader does not give us the client name until late in the game when we've done many layout tabs.

Now you can understand going into each layout just to put in the client name is a PITA.

So is there a gatte equivalent I can use for LT2025

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
Accepted solutions (3)
2,793 Views
52 Replies
Replies (52)
Message 21 of 53

h_s_walker
Mentor
Mentor

@dbroad LT2025 does support lisp, although not everything works in LT, that is why I'm posting here.

@cadffm I can't get any of them to work. When I try it doesn't do anything

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
Message 22 of 53

Moshe-A
Mentor
Mentor

@h_s_walker ,

 

Check this fix, specially how variable BNAME is set, '*' character must be added at end of string to address any title block name starting with "attribaxxxx". another 'issue' ... you did not mention the title block is dynamic so i fix this also.

 

works fine on my vanilla R2024 😀

 

enjoy

Moshe

 

 

; apply client

(defun c:applyClient (/ BNAME TAG client ss ctr ename subent sube)

 (setq BNAME "attriba*") ; const
 (setq TAG   "client")   ; const
 
 (if (and
       (/= (setq client (getstring t "\nClient name: ")) "")
       (setq ss (ssget "_x" (list '(0 . "insert") (cons '2 (strcat BNAME ",`*U*")) '(66 . 1))))
     )
  (progn
   (setq ctr 0)
   (foreach ename (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
    (setq subent (entnext ename) sube (entget subent))
    (while (/= (cdr (assoc '0 sube)) "SEQEND")
     (if (eq (strcase (cdr (assoc '2 sube))) (strcase TAG))
      (progn
       (entmod (subst (cons '1 client) (assoc '1 sube) sube))
       (setq ctr (1+ ctr))
      ); progn
     ); if
     (setq subent (entnext subent) sube (entget subent))
    ); while
   ); foreach
   
   (cond
    ((= ctr 0)
     (prompt "\nNo attributes found to update.")
    ); case
    ( t
     (prompt (strcat "\n" (itoa ctr) " attribute(s) update."))
    ); case
   ); cond
  ); progn
 ); if

 (princ)
); c:applyClient

 

 

 

 

0 Likes
Message 23 of 53

cadffm
Consultant
Consultant

Hi,

 

may I..

 


(cons '1 client) - quote numbers works, but is not needed, numbers evaluate to themselve
(cons 1 client)

 

(entmod (subst (cons '1 client) (assoc '1 sube) sube)) - can work and can also fail, if someone edited the multiline attributvalue by hand, this code will not change the value
(entmod (subst (cons '1 client) (assoc '1 (reverse sube)) sube))

 

and I added IF-effectivename, so that anonym blocks variants of bname blocks be processed only.

cadffm_0-1740786113200.png

 

(defun c:applyClient (/ BNAME TAG client ss ctr ename subent sube)

 (setq BNAME "attriba*") ; const
 (setq TAG   "client")   ; const
 
 (if (and
       (/= (setq client (getstring t "\nClient name: ")) "")
       (setq ss (ssget "_x" (list '(0 . "insert") (cons '2 (strcat BNAME ",`*U*")) '(66 . 1))))
     )
  (progn
   (setq ctr 0)
   (foreach ename (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
    (setq subent (entnext ename) sube (entget subent))
    (if (wcmatch (strcase (vla-get-EffectiveName (vlax-ename->vla-object ename)))(strcase BNAME))
    (while (/= (cdr (assoc '0 sube)) "SEQEND")
     (if (eq (strcase (cdr (assoc '2 sube))) (strcase TAG))
      (progn
       (entmod (subst (cons '1 client) (assoc '1 (reverse sube)) sube))
       (setq ctr (1+ ctr))
      ); progn
     ); if
     (setq subent (entnext subent) sube (entget subent))
    ); while
    ); if
   ); foreach
   
   (cond
    ((= ctr 0)
     (prompt "\nNo attributes found to update.")
    ); case
    ( t
     (prompt (strcat "\n" (itoa ctr) " attribute(s) update."))
    ); case
   ); cond
  ); progn
 ); if

 (princ)
)

 

@h_s_walker 

Does it work now?

Have your tried my basic solutions too and does they work as expected?

 

Come on! to keep one's fingers crossed 

All the codes(some, with edits) and workaround working in your given .dwg sample

 

 

Sebastian

0 Likes
Message 24 of 53

cadffm
Consultant
Consultant

Please test with short values,

Like 

Test Value

 

For looong  values, it's possible you need a more complicated code.

Sebastian

0 Likes
Message 25 of 53

Sea-Haven
Mentor
Mentor

This is what I did for a similar post it makes a dcl on the fly with tag names so you enter correct values leave any to not change blank. 

SeaHaven_0-1740799997759.png

 

 

; update a block atts in multiple layouts
; By AlanH March 2025

(defun c:upatts ( / ans atts bent bname lay lst lst2 obj ss x)

(setq obj (vlax-ename->vla-object (car (entsel "\nPick block object "))))
(setq bname (vlax-get obj 'name))
(setq atts (vlax-invoke obj 'Getattributes))

(setq lst '())
(foreach att atts
  (setq lst (cons (vlax-get att 'Tagstring) lst))
)
(setq lst2 '())
(foreach val lst
  (setq lst2 (cons "" lst2))
  (setq lst2 (cons 20 lst2))
  (setq lst2 (cons 21 lst2))
  (setq lst2 (cons val lst2))
)
(setq lst2 (cons "Please choose " lst2))

(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm lst2))

(foreach lay (layoutlist)
(setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 bname)(cons 410 lay))))
(setq x 0)
(setq bent (vlax-ename->vla-object (ssname ss 0)))
(setq atts (vlax-invoke bent 'Getattributes))
(repeat (length atts)
  (if (= (nth x ans) "")
  (princ)
  (vlax-put (nth x atts) 'textstring (nth x ans))
  )
  (setq x (1+ x))
)
)

(princ)
)

 

 

 

0 Likes
Message 26 of 53

Moshe-A
Mentor
Mentor

@cadffm 

 

(cons '1 client) - quote numbers works, but is not needed, numbers evaluate to themselve
(cons 1 client)

i know that but it is many years of habit and i can't help it 😀 think i took it from some one here long time ago, at least i consoled it does not harm the code.

 

(entmod (subst (cons '1 client) (assoc '1 sube) sube)) - can work and can also fail, if someone edited the multiline attributvalue by hand, this code will not change the value
(entmod (subst (cons '1 client) (assoc '1 (reverse sube)) sube))

well, generally i do not use Multiple attribute mode and i was not aware of that - thank you for that info.

 

and I added IF-effectivename, so that anonym blocks variants of bname blocks be processed only.

As i mentioned i have no AutoCAD LT, thought LT does not support ActiveX. can we now assume AutoLISP for LT is the same as full  AutoLISP?

 

 

 

Message 27 of 53

cadffm
Consultant
Consultant

I missing my last post, here is a shorter version:

 

Lisp in LT is limitted. 99% explaind with few words / two links

 

-No access to other programs, no vlax get or create

-Can't create objects what are not part of LT, like meshs, what is logical

- Can not create Xrecords and dictionaries

 

https://help.autodesk.com/view/ACDLT/2024/ENU/?guid=GUID-037BF4D4-755E-4A5C-8136-80E85CCEDF3E

 

https://help.autodesk.com/view/ACDLT/2024/ENU/?guid=GUID-D47983BA-1E5D-417D-85B8-6F3DE5F506BA

 

 

 

 

Sebastian

0 Likes
Message 28 of 53

komondormrex
Mentor
Mentor
Accepted solution

@h_s_walker 

check the following. hope it will work in lt.

 

;*************************************************************************************************************************************************************************
;
;	'other_gatte' custom command modifies value of selected by tag attribute in picked block to implement the same modifications
;	in the same blocks throughout all layouts of the drawing.
;
;	komondormrex, mar 2025
;
;*************************************************************************************************************************************************************************

(defun c:other_gatte (/ att_block insert tag_value_att_list tag_list value_list tag new_value tags_changed attribute_found)
	(while (not att_block)
		(setq insert (car (entsel "\nPick block with attributes: ")))
		(if (equal '(66 . 1) (assoc 66 (entget insert))) (setq att_block t))
	)
  	(setq tag_value_att_list (mapcar '(lambda (attribute) (list (vla-get-tagstring attribute) (vla-get-textstring attribute) attribute))
  				            (vlax-invoke (vlax-ename->vla-object insert) 'getattributes)
  				   )
  		  tag_list (mapcar 'car tag_value_att_list)
  		  value_list (mapcar 'cadr tag_value_att_list)
  	)
  	(while (and (setq tag (getstring (strcat "Select attribute, {Enter} to end ["
  						    				  (apply 'strcat (cdr (apply 'append (mapcar 'list (mapcar '(lambda (x) "/") tag_list) tag_list))))
  						    				  "]: "
									 )
  						  )
  		        )
  		        (/= "" tag)
  	       )
  	  	   (if (member (setq tag (strcase tag)) tag_list)
  		 	    (if (/= "" (setq new_value (getstring t
  		 				         					(strcat "\nEnter new value for \""
  		 				         					  	   	(vla-get-tagstring (last (assoc tag tag_value_att_list)))
  		 						 					      	"\" <"
  		 				         					 	   	(vla-get-textstring (last (assoc tag tag_value_att_list)))
  		 				         					 	   	"> :"
  		 			             					)
  		 				   					)
  		 				   )
  		 		 	)
  		 			(progn
  		 	    	 	   (vla-put-textstring (last (assoc tag tag_value_att_list)) new_value)
  		 			   (if (not (assoc tag tags_changed)) (setq tags_changed (append tags_changed (list (cons tag new_value)))))
  		 			)
  		 		)
  		   )
  	)
  	(vlax-map-collection (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
  	  '(lambda (layout) (if (/= "Model" (vla-get-name layout))
  				(vlax-map-collection (vla-get-block layout)
  				  '(lambda (object) (if (and (not (equal (vlax-ename->vla-object insert) object))
  							     			 (= "AcDbBlockReference" (vla-get-objectname object))
  							     			 (= (vla-get-effectivename (vlax-ename->vla-object insert)) (vla-get-effectivename object))
  										)
  						        		(mapcar '(lambda (tag) (if (vl-some '(lambda (attribute) (= tag (vla-get-tagstring (setq attribute_found attribute))))
  												     			   			 (vlax-invoke object 'getattributes)
  											   				   	   )
  											   					  (vla-put-textstring attribute_found (cdr (assoc tag tags_changed)))
  															   )
  									 			 )
  									 			 (mapcar 'car tags_changed)
  										)
  				   		     		)
  				  )
  				)
  		)
  	  )
  	)
  	(princ)
)

;*************************************************************************************************************************************************************************

 

 

updated

Message 29 of 53

Moshe-A
Mentor
Mentor

@cadffm 

 

Sorry maybe i am missing something here?

 

if it has no (vlax-) functions how did you recommend doing that?

 

(if (wcmatch (strcase (vla-get-EffectiveName (vlax-ename->vla-object ename)))(strcase BNAME))

 

 

0 Likes
Message 30 of 53

cadffm
Consultant
Consultant

Hi,

 

>>"if it has no (vlax-) functions"

Yes, you missunderstood my on mobile fast written sentence and didn't read my links.

 

I wrote "no access to other programs"

and my sample -  was function

vlax get or create 

known as "vlax-get-or-create"

but I mean all api methods to enter another program by api.

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/is-there-a-gatte-equivalent-for-lt20...

 

 

 

Sebastian

0 Likes
Message 31 of 53

Moshe-A
Mentor
Mentor

ok thanks you now it's clear

 

 

0 Likes
Message 32 of 53

Sea-Haven
Mentor
Mentor

@h_s_walker its your turn now need your comment about what did work. Most of us have no access to LT24+.

 

As mentioned VLAX- may not work but you can change those commands back to a (VLA-get-attributes obj) as an example

0 Likes
Message 33 of 53

h_s_walker
Mentor
Mentor

@cadffm your tweak to @Moshe-A is almost exactly what I need. One problem (which is probably easy to solve for you lisp gurus).

Sometimes we will be given a client name and we will use that and then later in the game the client will change.

Is there a tweak you can do to the code you posted here Re: Is there a GATTE equivalent for LT2025 - Page 3 - Autodesk Community  so it can change it even if there is already a client name there?

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
Message 34 of 53

cadffm
Consultant
Consultant

Please excuse Howard, but I'm getting desperate here and now.

Take the code, posted as last from me

If anything doesn't work, I'm sure the others will help you.

 

 

Sebastian

0 Likes
Message 35 of 53

cadffm
Consultant
Consultant

or start to share a sample what fails with this code and new attribute value.

 
 

 

 

Sebastian

0 Likes
Message 36 of 53

h_s_walker
Mentor
Mentor

@cadffm 

I was loading up one of our drawings, which I obviously cannot share, and it refuses to change the client name.

HOWEVER when I loaded up the drawing I created with all the information removed it will quite happily change the client name.

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
Message 37 of 53

cadffm
Consultant
Consultant

 

 

>>"I was loading up one of our drawings, which I obviously cannot share, and it refuses to change the client name."

 

1. Try it again with this file, re-open this dwg,

    unloack layers, load the latest applyclient code, run applyclient

 

2. If test1. faild, do the same as before

    Delete all problematic entries, save the file under a different name.
    Close the file, open this file, load applyclient and run it.
    Is the problem still there? Then share this DWG.

 

 

 

 
 

 

 

Sebastian

0 Likes
Message 38 of 53

h_s_walker
Mentor
Mentor

@cadffm I've just rebooted my machine. Loaded up a totally different drawing. The PLC you can see in the image below is part of the client name and as you can see from the text box in the image below it should say blah. Don't worry about the black scribble that's only part of the company name I work for.

h_s_walker_0-1741000699549.png

 

 

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
Message 39 of 53

h_s_walker
Mentor
Mentor

@komondormrex That's just about perfect. I'm sure I can easily show the other cad guys how to use it, and it will also help with changing other attributes which stay constant over each page.

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

Message 40 of 53

komondormrex
Mentor
Mentor

@h_s_walker wrote:

That's just about perfect. 


what is missing to be one?)

0 Likes