The Buzzard Posted October 8, 2010 Share Posted October 8, 2010 Hello All, The posted code I have works great, However I seem to find it overkill to step thru a selection set again for the same attribute. I tried a couple of different ways to no avail to edit an attribute multiple times in a single selection set, But could not get it to work correctly. Any guidence would be greatly appreciated. Thanks in advance, The Buzzard ;///////////////////////////////////////////////////////////////////////////////////////// ; ; F06 - Increment Attribute Value. ; (defun CIT_IAV () (cond ((= CIT:IDFS "0")(setq ATAG$ (strcat ""FLRN$"-"BTAG$"-"SEQN$""))) ((= CIT:IDFS "1")(setq ATAG$ (strcat ""FLRN$""IDFR$"-"BTAG$"-"SEQN$"")))) (setq SSET (ssget "_l" (list (cons 0 "INSERT")(cons 66 1))) INDX 0 ENAM (ssname SSET INDX) ELST (entget ENAM)) (while (/= (cdr (assoc 0 ELST)) "SEQEND") (setq ELST (entget ENAM)) (if (= "ID-TAG" (cdr (assoc 2 ELST))) (progn (entmod (subst (cons 1 ATAG$)(assoc 1 ELST) ELST)) (entupd ENAM))) (setq ENAM (entnext ENAM))) (setq INDX (1+ INDX) SEQN# (atoi SEQN$) SEQN# (+ SEQN# 1) SEQN$ (itoa SEQN#) SEQN$ (CIT_AT:NumFix SEQN$ 3) CIT:SEQN SEQN$) (CIT_RA) (princ)) ; ;///////////////////////////////////////////////////////////////////////////////////////// ; ; F07 - Rotate Attribute. ; (defun CIT_RA () (setq SSET (ssget "_l" (list (cons 0 "INSERT")(cons 66 1))) INDX 0 ENAM (ssname SSET INDX) ELST (entget ENAM)) (while (/= (cdr (assoc 0 ELST)) "SEQEND") (setq ELST (entget ENAM)) (if (= "ID-TAG" (cdr (assoc 2 ELST))) (progn (entmod (subst (cons 50 RAD#)(assoc 50 ELST) ELST)) (entupd ENAM))) (setq ENAM (entnext ENAM))) (setq INDX (1+ INDX)) (princ)) ; ;///////////////////////////////////////////////////////////////////////////////////////// ; Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted October 8, 2010 Author Share Posted October 8, 2010 Sorry for posting prematurely, But I figured out another way. In all cases I wanted to increment the attribute value, But not in all cases does the attribute need to be rotated. I was able to combine this into one function, So I am ok with this. I will post a completed code in the near future. Thanks, The Buzzard Quote Link to comment Share on other sites More sharing options...
David Bethel Posted October 8, 2010 Share Posted October 8, 2010 Buzzard, 1 thing I do when I'm dealing with revising multiple attributes, is to set a flag when a match has been found. If the flag is T, then issue (entupd) after the end of the loop of SEQEND. You do need to set the flag nil at the beginning. Another option is not call (entupd) at all, but rather issue a (command "_.REGENALL") at the end of the routine (entupd) can really bog down a large pickset. -David Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted October 8, 2010 Author Share Posted October 8, 2010 Hi RenderMan, I could post what I did, But it would not make sence to anyone without the complete code which I am still working on. As I mentioned I will post that code in the near future which is real soon, But it will be on a completely different thread. Just the same here is what I did. I am using an If statement to avoid rotating the attribute if it does not meet those conditions. Thanks for asking all the same. ;///////////////////////////////////////////////////////////////////////////////////////// ; ; F06 - Edit Attribute Value. ; (defun CIT_EAV () (cond ((= CIT:IDFS "0")(setq ATAG$ (strcat ""FLRN$"-"BTAG$"-"SEQN$""))) ((= CIT:IDFS "1")(setq ATAG$ (strcat ""FLRN$""IDFR$"-"BTAG$"-"SEQN$"")))) (setq SSET (ssget "_l" (list (cons 0 "INSERT")(cons 66 1))) INDX 0 ENAM (ssname SSET INDX) ELST (entget ENAM)) (while (/= (cdr (assoc 0 ELST)) "SEQEND") (setq ELST (entget ENAM)) (if (= "ID-TAG" (cdr (assoc 2 ELST))) (progn (entmod (subst (cons 1 ATAG$)(assoc 1 ELST) ELST)) (entupd ENAM))) (setq ENAM (entnext ENAM))) (setq INDX (1+ INDX) SEQN# (atoi SEQN$) SEQN# (+ SEQN# 1) SEQN$ (itoa SEQN#) SEQN$ (CIT_AT:NumFix SEQN$ 3) CIT:SEQN SEQN$) (if (and (> DEG# 90.0)(<= DEG# 270.0)) (progn (setq RAD# (CIT_DTR (+ DEG# 180.0))) (setq SSET (ssget "_l" (list (cons 0 "INSERT")(cons 66 1))) INDX 0 ENAM (ssname SSET INDX) ELST (entget ENAM)) (while (/= (cdr (assoc 0 ELST)) "SEQEND") (setq ELST (entget ENAM)) (if (= "ID-TAG" (cdr (assoc 2 ELST))) (progn (entmod (subst (cons 50 RAD#)(assoc 50 ELST) ELST)) (entupd ENAM))) (setq ENAM (entnext ENAM))) (setq INDX (1+ INDX)))) (princ)) ; ;///////////////////////////////////////////////////////////////////////////////////////// Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted October 8, 2010 Author Share Posted October 8, 2010 Buzzard, 1 thing I do when I'm dealing with revising multiple attributes, is to set a flag when a match has been found. If the flag is T, then issue (entupd) after the end of the loop of SEQEND. You do need to set the flag nil at the beginning. Another option is not call (entupd) at all, but rather issue a (command "_.REGENALL") at the end of the routine (entupd) can really bog down a large pickset. -David Thanks David, Thats good to know, I will give that a try. Just to mention also this is a single attribute being revised mutiple times if certain conditions are met. Again Thanks Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 8, 2010 Share Posted October 8, 2010 I could post what I did, But it would not make sence to anyone without the complete code which I am still working on. As I mentioned I will post that code in the near future which is real soon, But it will be on a completely different thread. Sorry about that Buzzard, I must not have read you post completely . Post deleted, and many thanks. Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted October 8, 2010 Author Share Posted October 8, 2010 I think we posted at the same time. Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted October 8, 2010 Author Share Posted October 8, 2010 David, I just tried the regenall and its a much better call as I can see the difference in it. Thanks Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted October 8, 2010 Author Share Posted October 8, 2010 David, I am only inserting one block with one attribute at a time through a while loop. As mentioned before in all cases the attribute value will be increment by one. In some cases after the attribute has been incremented it may be rotated depending upon the condition. I am finding that the regenall method seems to be slower in this case although it is somewhat cleaner, But it gives you the indication that the block is being redefined every time although I know thats really not the case as the attribute is being just updated. I think I will stick with the original method until I post the complete code for everyones evaluation to see which method is actually better in this case. Thanks all the same, But I will wait on that one. The methods I am using will be more apparent to you when I post the complete code. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted October 8, 2010 Share Posted October 8, 2010 Buzzard, Are issuing just 1 REGNEALL at the end of the entire routine? -David Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted October 8, 2010 Author Share Posted October 8, 2010 Yes, But as I said before, I am inserting through a while loop. This program is meant to insert identification labels and increment each time one after ther other. So the while loop will cause this regen each time there is an insert. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted October 8, 2010 Share Posted October 8, 2010 Ok Gotcha -David Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted October 8, 2010 Author Share Posted October 8, 2010 Ok Gotcha -David Thats why I mentioned it would be more apparent when I post the full code later on another thread. I am doing a final cleanup on it and adding a help dialog at this time. I will be posting it soon for comments and suggestions before I finalize anything. As always Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 8, 2010 Share Posted October 8, 2010 Hi Buzzard, I've tried not to change too much, just to convey a general idea, but this is perhaps how to perform both changes without iterating twice through the set. ;///////////////////////////////////////////////////////////////////////////////////////// ; ; F06 - Edit Attribute Value. (defun CIT_EAV ( / ss ent elst ) (setq ATAG$ (cond ( (= CIT:IDFS "0") (strcat FLRN$ "-" BTAG$ "-" SEQN$) ) ( (= CIT:IDFS "1") (strcat FLRN$ IDFR$ "-" BTAG$ "-" SEQN$) ) ) ) (if (setq ss (ssget "_L" (list (cons 0 "INSERT") (cons 66 1)))) (progn (setq ent (ssname ss 0)) (while (not (eq "SEQEND" (cdr (assoc 0 (setq elst (entget (setq ent (entnext ent)))))))) (if (eq "ID-TAG" (cdr (assoc 2 elst))) (entupd (cdr (assoc -1 (entmod (subst (cons 1 ATAG$) (assoc 1 elst) (if (and (> DEG# 90.0)(<= DEG# 270.0)) (subst (cons 50 (CIT_DTR (+ DEG# 180.0))) (assoc 50 elst) elst) elst ) ) ) ) ) ) ) ) ) ) ) ;///////////////////////////////////////////////////////////////////////////////////////// Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted October 8, 2010 Author Share Posted October 8, 2010 Ok Lee, I see the if at the beginning when getting the selection set and in addition adding the not to the SEQEND. Thanks I will give that a try. It beats going thru the selection set twice which I said seem to be overkill. Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted October 8, 2010 Author Share Posted October 8, 2010 Lee, I added the code to test and I am not getting any errors, But the attributes are not changing either. I think at this point it would be best if I post the full code before I make any more changes so everyone can see what is suppose to happen. I somewhat got the idea of what you are conveying to me and I know additional adjustments are required, But I am trying now at this point to finish it off so I can post it. It will be alot clearer if its in working order even if it is less concise to your programming methods. At that point we can all take it from there and see how it should get fixed. Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 8, 2010 Share Posted October 8, 2010 No worries Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted October 9, 2010 Author Share Posted October 9, 2010 (edited) No worries Lee, I have finished editing the code and went back to take another look at your function. I have it working well now. I had a few quirks as to where the local variables should have been localized. Also where I had put the call for incrementing the attribute value was another issue. And finally I was using a variable called INDX for the index number which was adding 1 to the value was not being used in your code, So I hard coded the 1 to be added to the sequence number and all is good now. It is a much smaller function calling the selection set only once which was the goal in mind and I am very happy with it. I will be posting the entire code soon on another thread for it and plan to reference this thread to it as well. Thank you and everyone else that had participated here with help. The Buzzard Edited October 9, 2010 by The Buzzard Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 9, 2010 Share Posted October 9, 2010 Happy that I could offer some assistance Buzzard 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.