Jump to content

Need to create LSP for Attribute block change value


Cheezee

Recommended Posts

Good day,

 

Can someone help me how to create .lsp for changing the value globally in attribute value.

for example drawing see image

 

I have 20-30 sheet with typical block Attribute. Using script can do the job, but script need command to replace the block Attribute Tag Value. Using Find command is out the of the option because of pop-up window

 

I need to change the Attribute tag Value(L-782-LT-141-05-N23) into L-781-XX-141-03-U.

 

Pls help

Kind regard

Cheezee

Link to comment
Share on other sites

Good day,

 

Can someone help me how to create .lsp for changing the value globally in attribute value.

for example drawing see image

 

I have 20-30 sheet with typical block Attribute. Using script can do the job, but script need command to replace the block Attribute Tag Value. Using Find command is out the of the option because of pop-up window

 

I need to change the Attribute tag Value(L-782-LT-141-05-N23) into L-781-XX-141-03-U.

 

Pls help

Kind regard

Cheezee

 

have you tried LeeMac's routine?

 

Global Attribute Editor & Extractor

Link to comment
Share on other sites

have you tried LeeMac's routine?

 

Global Attribute Editor & Extractor

 

 

I can't use LeeMac's Global Attribute Editor & extractor due to interface, what I need is replacement of command FIND in autocad

which .lsp is handy to do

like for example

Old string = L-782-LT-141-05-N23

New string = l-781-XX-141-03-U

but this Strings are in block attribute, using the other text change .LSP are not applicable when it comes block attribute value change

Link to comment
Share on other sites

To clarify you want to change the TAG name this is part of the block definition use Bedit and it will change all blocks. FIND will change the attribute Value in all blocks.

 

 

 

Thank you all of you, for quick response

 

 

Yes, Using FIND command in autocad can change the Attribute value in all blocks but im doing script and FIND command is not practical approach(got error)

Using Bedit will take more time, shifting from one dwg file to another one.

 

 

The scenario of my drawing composing of 20-30 sheet with different file name in example D-ELE-A300.dwg, D-ELE-A301.dwg, D-ELE-A302.dwg and so on.

In each drawing file, I have many Block Attribute that I want to change the Attribute value from L-782-LT-141-05-N23 into l-781-XX-141-03-U.

Link to comment
Share on other sites

Ok here is a lisp to change a certain blocks attribute value in this case 3 attributes you can hard code the program if its always the same otherwise you can pass a varaible for both the new valus and the tag name, this can be done in a script. I would mhave thought Lee-macs attribute editor would do what you want though interface problem ? Ask Lee here nicely if you have problems running.

 

open dwg1

(load "Issued")

close Y

open dwg2 etc

 

; changes to issued for construction
: thanks to lee mac for original code
(vl-load-com)
; 1.  Get current date in mm/dd/yy format.
(defun ddmmyy (/ x today)
    (setvar "cmdecho" 0)
    (setq x (getvar "CDATE"))                 ; get current date
    (setq today ( rtos x 2 4))                    ; convert to a string
    (setq date (strcat (substr today 7 2) "."    (substr today 5 2) "." (substr today 3 2) ))
)

(setq oldtag1 "DRAWING_STATUS") ;attribute tag name
(setq newstr1 "ISSUED FOR CONSTRUCTION")
(setq oldtag2 "REV_NO")  ;attribute tag name
(setq newstr2 "0")
(setq ss1 (ssget "x"  '((0 . "INSERT") (2 . "DA1DRTXT"))))
(setq inc (sslength ss1))
(repeat inc      
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 (setq inc (1- inc)) )) 'getattributes)
(if (= oldtag1 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr1) 
) ; end if
(if (= oldtag2 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr2) 
) ; end if
) ; end for
) ;end repeat
(setq oldtag1 "REV-NO")
(setq newstr1 "0")
(ddmmyy)
(setq oldtag2 "DATE")
(setq newstr2 date)
(setq oldtag3 "AMENDMENT")
(setq newstr3 "ISSUED FOR CONSTRUCTION")
(setq ss2 (ssget "x"  '((0 . "INSERT") (2 . "REVTABLE"))))
(setq inc (sslength ss2))
(repeat inc
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname ss2 (setq inc (1- inc)))) 'getattributes)
(if (= oldtag1 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr1) 
)
(if (= oldtag2 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr2) 
)
(if (= oldtag3 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr3) 
)
)
)
(setq ss1 nil)
; (setq ss2 nil)
(princ)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...