flowerrobot Posted April 10, 2009 Share Posted April 10, 2009 I can not for the life of me remember, and i carnt remember the correct wording to find it ;(. I would like to select only one item, Much how pedit works. This is what i have currenly, but would like it to move on, once its being selected (setq ss1 (ssget "X" '((0 . "INSERT")(66 . 1)))) Thanks for your time Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 10, 2009 Share Posted April 10, 2009 Do you need the user to select the item, as (ssget "X" ... ) will automatically select items. If it is indeed a single selection from a user, you could use either: (if (and (setq ent (car (entsel "\nSelect Item: "))) (= "INSERT" (cdr (assoc 0 (entget ent)))) (= 1 (cdr (assoc 66 (entget ent))))) (progn ;...do stuff... ) (princ "\nSelected Item Isn't an Attributed Block")) or (if (setq ss (ssget "_:S" '((0 . "INSERT") (66 . 1)))) (progn ;; do stuff here... ) (princ "\nNothing Selected")) Quote Link to comment Share on other sites More sharing options...
flowerrobot Posted April 10, 2009 Author Share Posted April 10, 2009 Thanks lee, for that fantasitc reply. Thats what i wanted (while (not (setq ss (ssget "_:S" '((0 . "INSERT") (66 . 1)))) ) ) Also, While im bugging you. Whats an alternative to this (setq en (ssname ss1 0)) (setq ed (entget en)) (setq blkn (dxf 2 ed)) which would be shortly followed with this (= "ITEMBALLOON" blkn) (trying to find the correct block) THanks for you time! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 10, 2009 Share Posted April 10, 2009 If you only want the user to select that specific block, just include it in the filter list of the ssget: (while (not (setq ss (ssget "_:S" '((0 . "INSERT")(2 . "ITEMBALLOON")(66 . 1)))) ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 10, 2009 Share Posted April 10, 2009 Whats an alternative to this: (setq en (ssname ss1 0)) (setq ed (entget en)) (setq blkn (dxf 2 ed)) But in answer to your question: (setq blkn (cdr (assoc 2 (entget (ssname ss1 0))))) Quote Link to comment Share on other sites More sharing options...
flowerrobot Posted April 10, 2009 Author Share Posted April 10, 2009 Thanks very much!! one last problem. Why does this while not work,It repeats, but will not stop, (defun c:ct () ;for testing ;to find if want to increase or renumber from a selected up (setq incre (getstring (strcat "\nDo you want to renumber(1,2) or increment (+1,-2)? <" incre "> :"))) ;works out the choice made (cond ((= (substr incre 1 1) "+") (progn (setq change 0) (setq orgno (atoi (substr incre 2))) ) ) ((= (substr incre 1 1) "-") (progn (setq change 1) (setq orgno (atoi (substr incre 2))) ) ) ((<= 1 (atoi incre)) (progn (setq change 2) (setq orgno (atoi incre)) ) ) ) [color=red];this while!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!![/color] (while (progn (setq ss1 nil) ;select the block for it to be done to. (while (not (setq ss1 (ssget "_:S" '((0 . "INSERT") (66 . 1)))) ) ) ;finds its data (setq en (ssname ss1 0)) (setq ed (entget en)) ;makes sure its itemballoon (setq blkn (cdr (assoc 2 ed))) (cond ((= blkn "ITEMBALLOON") (progn (setq edata (entget en)) (setq edata (entget (entnext (cdr (assoc -1 edata))))) ;gives attibutes current number (setq itembubbleorg (atoi (cdr (assoc 1 edata)))) (rever) ) ) ((not (= blkn "ITEMBALLOON")) (Princ "\nYou Must Select the Item Bubble or masslist block") ) ) ) ) ) (defun rever () ;0, addes the number to the items one,1 takes it away, 2 changes it to selected one, then every item seleted will add one to that (change 3) (cond ((= change 0) (setq itembubblenew (+ itembubbleorg orgno)) ) ((= change 1) (setq itembubblenew (- itembubbleorg orgno)) ) ((= change 2) (progn (setq change 3) (setq itembubblenew orgno) ) ) ((= change 3) (setq itembubblenew (1+ itembubblenew)) ) ) ;creates the number to a string (setq interitembubblenew (itoa itembubblenew)) ;inserts it back to the attribute (setq el (subst (cons 1 interitembubblenew) (assoc 1 edata) edata)) (entmod el) ) Cheers mate! Quote Link to comment Share on other sites More sharing options...
jammie Posted April 11, 2009 Share Posted April 11, 2009 An alternate way of looping It allows the user to select only one obect or returns nil if the user hits return I would suggest encorporating an error function to restore the pickadd to 1 as well (setvar 'pickadd 0) (setq ss (ssget '((0 . "INSERT")(2 . "ITEMBALLOON")(66 . 1)))) (setvar 'pickadd 1) Might not be the functional method but it something to consider Jammie Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 11, 2009 Share Posted April 11, 2009 I suppose this is a shortcut: (defun c:ct (/ incre change orgno ss1 att newitem) (setq incre (getstring (strcat "\nDo you want to renumber(1,2) or increment (+1,-2)? <" incre "> :"))) (cond ((= (substr incre 1 1) "+") (setq change 0 orgno (atoi (substr incre 2)))) ((= (substr incre 1 1) "-") (setq change 1 orgno (atoi (substr incre 2)))) ((<= 1 (atoi incre)) (setq change 2 orgno (atoi incre)))) (while (not ss1) (setq ss1 (ssget "_:S" '((0 . "INSERT") (2 . "ITEMBALLOON") (66 . 1))))) (setq att (entget (entnext (ssname ss1 0))) newitem (rever (cdr (assoc 1 att)))) (entmod (subst (cons 1 newitem) (assoc 1 att) att)) (command "_regenall") (princ)) (defun rever (old / new) (cond ((= change 0) (setq new (+ old orgno))) ((= change 1) (setq new (- old orgno))) ((= change 2) (setq new old new (1+ new)))) new) But requries Esc to exit. Quote Link to comment Share on other sites More sharing options...
CAB Posted April 11, 2009 Share Posted April 11, 2009 Not sure what the end goal is but here is my one pick with Enter exit. (defun c:ct (/ incre change orgno ss1 att newitem) (or incre (setq incre "+1")) (setq incre (getstring (strcat "\nDo you want to renumber(1,2) or increment (+1,-2)? <" incre "> :" ) ) ) (cond ((= (substr incre 1 1) "+") (setq change 0 orgno (atoi (substr incre 2)) ) ) ((= (substr incre 1 1) "-") (setq change 1 orgno (atoi (substr incre 2)) ) ) ((<= 1 (atoi incre)) (setq change 2 orgno (atoi incre) ) ) ) (setvar "ErrNo" 0) ; reset variable (while (progn (setq ss1 (ssget "_+.:E:S" '((0 . "INSERT") (2 . "ITEMBALLOON") (66 . 1)))) (cond ((= 52 (getvar "ErrNo")) ; enter pressed (prompt "\nUser Quit.") ) ((null ss1) (princ "\nMissed, Try again.") ) ) ) ) (if ss1 (progn (setq att (entget (entnext (ssname ss1 0))) newitem (rever (cdr (assoc 1 att))) ) (entmod (subst (cons 1 newitem) (assoc 1 att) att)) (command "_regenall") ) ) (princ) ) (defun rever (old / new) (cond ((= change 0) (setq new (+ old orgno)) ) ((= change 1) (setq new (- old orgno)) ) ((= change 2) (setq new old new (1+ new) ) ) ) new ) Quote Link to comment Share on other sites More sharing options...
flowerrobot Posted April 11, 2009 Author Share Posted April 11, 2009 Saddy i carnt seem to get any of the suggestions to work, Jamie, i had thought of doing this orginally, but "_:S" is to the same effect, Thanks lee, for that, ill take it on board Cab, mate couldnt get your's to work, tryed playing around with it, but couldnt. If you carnt see what it does, place a single attibuted block , where the first attribute is a number, then you can choose to increase it by 6 "+6" or "-6"for every block selected, or just renumber them starting from any number. i belive asmi, has one very similar, but i didnt want a prefix or sufic thanks guys for you help! 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.