markv Posted June 1, 2010 Share Posted June 1, 2010 I am currently slamming my head against my desk. I have two routines that replace blocks by name and then changes the visibility to the proper state. The routines use other predefined functions that are not shown. code below. this one works (defun c:REB (/ ENT1 BL1 NWNM OLD ODNM) ;THIS PROGRAM REPLACES SELECTED DUPLEX RECEPTACLE BLOCKS WITH THE PROPER RECEPTACLE BLOCK IN AN ELECTRICAL DRAWING (initerr3) (command "-insert" "rec.dwg" "0,0" "" "" "") (command "erase" "l" "") (setq ENT1 (ssget "X" (list (cons 0 "INSERT") (cons 2 "DR" ) ) ) ) (IF (= ENT1 NIL) (C:FPR)) (setq N (sslength ENT1)) (setq I 0) (repeat N (setq BL1 (entget (ssname ENT1 I)) NM (cdr (assoc 2 BL1)) ) (setq NWNM (cons 2 (strcat "REC"))) (setq OLD (assoc 2 BL1)) (entmod (subst NWNM OLD BL1)) (setq I (1+ I)) ) (c:chdr) (prin1) (reset3) ;(command "-purge" "b" "*" "n") (c:fpr) ) ;----------------------------------------------------------- c:Chdr ----- (defun c:Chdr () ;changes visibility to duplex plan receptacle (ChangeVisibility "REC" "Duplex Plan") (princ) ) this one does not. it will change the block but not the visibilty state. I have checked for typos and everthing is correct on the block names. (defun c:RCR (/ ENT1 BL1 NWNM OLD ODNM) ;THIS PROGRAM REPLACES SELECTED Single Ceiling Mounted RECEPTACLE BLOCKS WITH THE PROPER RECEPTACLE BLOCK IN AN ELECTRICAL DRAWING (initerr3) (command "-insert" "CR.dwg" "0,0" "" "" "") (command "erase" "l" "") (setq ENT1 (ssget "X" (list (cons 0 "INSERT") (cons 2 "SRC" ) ) ) ) (IF (= ENT1 NIL) (C:DRC)) (setq N (sslength ENT1)) (setq I 0) (repeat N (setq BL1 (entget (ssname ENT1 I)) NM (cdr (assoc 2 BL1)) ) (setq NWNM (cons 2 (strcat "CR"))) (setq OLD (assoc 2 BL1)) (entmod (subst NWNM OLD BL1)) (setq I (1+ I)) ) (c:Chsrc) (prin1) (reset3) ;(command "-purge" "b" "*" "n") (c:DRC) ) ;----------------------------------------------------------- c:Chsrc ----- (defun c:Chsrc () ;changes visibility to Single Ceiling receptacle (ChangeVisibility "CR" "Single Ceiling Receptacle") (princ) ) Quote Link to comment Share on other sites More sharing options...
markv Posted June 8, 2010 Author Share Posted June 8, 2010 I know the geniuses here should have something. Nobody has anything? Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 8, 2010 Share Posted June 8, 2010 It's difficult to test this with limited information. Does it work on the block if you just try the visibility portion of the code? Quote Link to comment Share on other sites More sharing options...
markv Posted June 9, 2010 Author Share Posted June 9, 2010 No it doesnt that is waht is so strange. I have doulble checked my visibilty state names for discrepencies and it all checks out. I can post the entire code but it gets quite long. it is not broken out into tool box routines as would be a lot better. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 10, 2010 Share Posted June 10, 2010 Hi markv. You have some kind of functions that are not recognized in our systemthings like : (c: fpr) (c: DRC) and why did you includ the command purge and did not use it ;(command "-purge" "b" "*" "n") So finally nobody can use your codes or check either. Regards Tharwat Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 10, 2010 Share Posted June 10, 2010 http://www.cadtutor.net/forum/showthread.php?t=9184 Just upload a file. Quote Link to comment Share on other sites More sharing options...
markv Posted June 10, 2010 Author Share Posted June 10, 2010 Files attached. RCR.lsp is the NON-working routine, REB.lsp is the working one. REB.LSP RCR.LSP Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted June 10, 2010 Share Posted June 10, 2010 Files attached. RCR.lsp is the NON-working routine, REB.lsp is the working one. You did not upload the blocks. Quote Link to comment Share on other sites More sharing options...
markv Posted June 10, 2010 Author Share Posted June 10, 2010 Sorry about that. this should help elecblocks.zip 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.