Jump to content

Attribute Change what went wrong?


Cheezee

Recommended Posts

Posted (edited)

Hi guys, to all LSP expert pls help me

at first this LSP code was working and I'm using for long time using auto cad 2012. But now LSP code is not working

 

Code tag:

pls see attachment,

 

 

what went wrong?

Im using this LSP for my scr. for multiple drawings and it is really useful.

CHATTRIB.LSP

Edited by Cheezee
Code posting is not working so what I did is to attach my lsp
  • Replies 26
  • Created
  • Last Reply

Top Posters In This Topic

  • Tharwat

    11

  • Cheezee

    11

  • pBe

    4

  • SLW210

    1

Top Posters In This Topic

Posted Images

Posted

Nothing is wrong with that function , but if the block name is a dynamic block that wouldn't work .

Posted

@Tharwat How do I know if block is dynamic block?

Posted

This is what I get when I'm using my CHATTRIB LSP

autocad.winow.JPG

Posted
@Tharwat How do I know if block is dynamic block?

 

Entget the entity name of your block then search for the cdr value of DXF 2 , if it is start with *U it means a Dynamic Block , otherwise it is not . :)

Posted

Sorry Tharwat I really don't understand how to know if my block is dynamic

I try to input Entget but autocad said unknown

 

 

I have attach my .dwg and .lsp in my previous message.

Pls mind to upload and made some recommendation how to make my LSP work again.

Posted

Copy and paste the following line of codes into your command line then press Enter to start so select a block , if it start with *U so it is Dynamic otherwise it's not .

 

(cdr (assoc 2 (entget (car (entsel "\n Select a Block :")))))

Posted

Anyway , try this modification and let me know .

 

NOTE: add your function changeAttribValue to the following routine .

 

(defun C:CHATTRIB  (/ ss sn a attag bname oldval newval)
 (and (/= "" (setq bname (getstring "\nBlock name: ")))
      (/= "" (setq attag (getstring T "\nTag: ")))
      (/= "" (setq oldval (getstring T "\nOld value: ")))
      (/= "" (setq newval (getstring T "\nNew value: ")))
      (setq ss (ssget "_X"
                      (list '(0 . "INSERT")
                            '(66 . 1)
                            (cons 2 (strcat "`*U*," bname)))))
      (repeat (setq a (sslength ss))
        (if (eq (vla-get-effectivename
                  (vlax-ename->vla-object
                    (setq sn (ssname ss (setq a (1- a))))))
                bname)
          (changeAttribValue
            sn
            attag
            oldval
            newval)
          ))
      )
 (princ)
 )(vl-load-com)

Posted

Sorry Sir SLW210, I will edit my post

thank you sir,

Posted
Copy and paste the following line of codes into your command line then press Enter to start so select a block , if it start with *U so it is Dynamic otherwise it's not .

 

(cdr (assoc 2 (entget (car (entsel "\n Select a Block :")))))

 

 

Sir Tharwat It is confirmed Dynamic block

 

 

Sir How can I change this block, so that I can use your code?

Posted

I manage to find out how to change dynamic block to static block,

but I can't still use the chageattribute code.

 

 

Does this mean we can't use lsp in AutoCAD 2012?

Posted

Does this mean we can't use lsp in AutoCAD 2012?

 

I already modified your codes and added a few functions to it , did not you try it ?

Posted
I already modified your codes and added a few functions to it , did not you try it ?

 

 

Sir Tharwat there is an error

pls see attachment for snap shot

Snapshot.jpg

Posted
Anyway , try this modification and let me know .

 

NOTE: add your function changeAttribValue to the following routine .

 

Sir Tharwat there is an error

pls see attachment for snap shot

 

I also already gave you a note that you need to add the function changeAttribValue to my modified program , got it ?

Posted
I already modified your codes and added a few functions to it , did not you try it ?

 

I also already gave you a note that you need to add the function changeAttribValue to my modified program , got it ?

 

 

I don't know where to put the add function,

this is usually step

Once I appload the lsp

then typing in the command

_CHATTRIB

BLOCK NAME:___ (It ask for block name)

Old value: ___ (after I enter the block name It instantly ask for Old value)

New value: ___ (same with previous it ask instantly for New value)

and then error after I enter my desire New value

Where in this command can I add the changeattribvalue?

Posted
(defun c:CHATTRIB (/ ss sn a attag bname oldval newval)
 (defun changeAttribValue (ent atttag oldval newval / entl)
   (while (and ent
               (/= "SEQEND" (cdr (assoc 0 (setq entl (entget ent)))))
          )
     (and (= atttag (cdr (assoc 2 entl)))
          (= oldval (cdr (assoc 1 entl)))
          (entmod (subst (cons 1 newval) (assoc 1 entl) entl))
          (entupd ent)
          (mapcar 'princ (list "\n" oldval " -> " newval))
     )
     (setq ent (entnext ent))
   )
 )
 (and (/= "" (setq bname (getstring "\nBlock name: ")))
      (/= "" (setq attag (getstring T "\nTag: ")))
      (/= "" (setq oldval (getstring T "\nOld value: ")))
      (/= "" (setq newval (getstring T "\nNew value: ")))
      (setq ss (ssget "_X"
                      (list '(0 . "INSERT")
                            '(66 . 1)
                            (cons 2 (strcat "`*U*," bname))
                      )
               )
      )
      (repeat (setq a (sslength ss))
        (if (eq (vla-get-effectivename
                  (vlax-ename->vla-object
                    (setq sn (ssname ss (setq a (1- a))))
                  )
                )
                bname
            )
          (changeAttribValue
            sn
            attag
            oldval
            newval
          )
        )
      )
 )
 (princ)
)(vl-load-com)

Posted

Sir Tharwat thank you so much it work I can finally change the attribute value with your code

thank you very much.

:)

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...