Cheezee Posted February 12, 2015 Share Posted February 12, 2015 (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 February 13, 2015 by Cheezee Code posting is not working so what I did is to attach my lsp Quote Link to comment Share on other sites More sharing options...
pBe Posted February 12, 2015 Share Posted February 12, 2015 Wrong in what way Cheezee? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 12, 2015 Share Posted February 12, 2015 Nothing is wrong with that function , but if the block name is a dynamic block that wouldn't work . Quote Link to comment Share on other sites More sharing options...
Cheezee Posted February 12, 2015 Author Share Posted February 12, 2015 @Tharwat How do I know if block is dynamic block? Quote Link to comment Share on other sites More sharing options...
Cheezee Posted February 12, 2015 Author Share Posted February 12, 2015 This is what I get when I'm using my CHATTRIB LSP Quote Link to comment Share on other sites More sharing options...
Cheezee Posted February 12, 2015 Author Share Posted February 12, 2015 See attachment for dwg and lsp CHATTRIB.LSP sample.dwg Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 12, 2015 Share Posted February 12, 2015 @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 . Quote Link to comment Share on other sites More sharing options...
Cheezee Posted February 12, 2015 Author Share Posted February 12, 2015 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. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 12, 2015 Share Posted February 12, 2015 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 :"))))) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 12, 2015 Share Posted February 12, 2015 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) Quote Link to comment Share on other sites More sharing options...
SLW210 Posted February 12, 2015 Share Posted February 12, 2015 Cheezee, Please read the Code Posting Guidelines and edit your post to include the Code in Code Tags. Quote Link to comment Share on other sites More sharing options...
Cheezee Posted February 12, 2015 Author Share Posted February 12, 2015 Sorry Sir SLW210, I will edit my post thank you sir, Quote Link to comment Share on other sites More sharing options...
Cheezee Posted February 13, 2015 Author Share Posted February 13, 2015 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? Quote Link to comment Share on other sites More sharing options...
Cheezee Posted February 13, 2015 Author Share Posted February 13, 2015 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? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 13, 2015 Share Posted February 13, 2015 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 ? Quote Link to comment Share on other sites More sharing options...
Cheezee Posted February 13, 2015 Author Share Posted February 13, 2015 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 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 13, 2015 Share Posted February 13, 2015 Anyway , try this modification and let me know . NOTE: add your function changeAttribValue to the following routine . Sir Tharwat there is an errorpls 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 ? Quote Link to comment Share on other sites More sharing options...
Cheezee Posted February 13, 2015 Author Share Posted February 13, 2015 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? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 13, 2015 Share Posted February 13, 2015 (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) Quote Link to comment Share on other sites More sharing options...
Cheezee Posted February 14, 2015 Author Share Posted February 14, 2015 Sir Tharwat thank you so much it work I can finally change the attribute value with your code thank you very much. Quote Link to comment Share on other sites More sharing options...
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.