Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error Chech

8 REPLIES 8
Reply
Message 1 of 9
safcadd08
504 Views, 8 Replies

Error Chech

Helllo,

If Ii have a few block on the scree, and I would like to pick them, but I'm running a block counter at the sametime. How would I go about making sure the block gets picked and the counter does not advance?

 

Thanks,

Steve

8 REPLIES 8
Message 2 of 9
Moshe-A
in reply to: safcadd08

Steve,

 

how can you pick objects (your blocks)  while 'counter' is running?

 

what's this 'counter' is?  an AutoLISP command?

 

what is your goal?

 

Moshe

 

 

Message 3 of 9
safcadd08
in reply to: Moshe-A

Hello, If I pick, the counter will advance even if I miss the block...Is their a better way to do this? Thanks for the reply. Steve
Message 4 of 9
Kent1Cooper
in reply to: safcadd08


@safcadd08 wrote:
....If I pick, the counter will advance even if I miss the block...Is their a better way to do this? ....

Try something that will ask again if you miss, such as this, using a combination of selection-method codes that Lee Mac called to my attention [one part of which is not documented in the AutoLISP Reference].  It makes (ssget) work like individual-object selection, similar to (entsel) but with the possibility of filtering:

 

(while

  (not

    (setq blk (ssget "_+.:S:E" '((0 . "INSERT")))))

    (prompt "\nNothing selected, or not a Block -- try again:"))

  )

)

 

And once that has been satisfied, then advance the counter.  You can get more sophisticated with the use of the ERRNO System Variable, so that you can end it with Enter or space [with the above, those will also result in its asking you to try again, and only Escape will end it].  Seeing the routine that includes the counter would make it easier to know whether that's needed, and to suggest how to integrate something like this into it.

Kent Cooper, AIA
Message 5 of 9
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:
.... 

(while

  (not

    (setq blk (ssget "_+.:S:E" '((0 . "INSERT")))))

    (prompt "\nNothing selected, or not a Block -- try again:"))

  )

)

....


Sorry [too late to Edit my previous message] -- that should be:
 

(while
  (not (setq blk (ssget "_+.:S:E" '((0 . "INSERT")))))
  (prompt "\nNothing selected, or not a Block -- try again:")
)
 

You can also get more sophisticated in other ways, such as eliminating Xrefs, or Blocks on locked Layers, or not add to the count Blocks that were already selected, as well as the usual error handling, etc.

Kent Cooper, AIA
Message 6 of 9
safcadd08
in reply to: Kent1Cooper

Hello Kent and All, Here is the code I want to erro check: ================================================== (command "_erase" "c" "26.97,27.39" "17,26.34" "") ;Erace line of text (command "-insert" "of21" "26.23,26.82" "" "" "") ;Insert a new line of text (command "-insert" "00" "29.06,26.81" "" "" "") ;Inserts first number in counter (setq c1 0) ;Sets counter to zero (repeat 21 (setq c1 (+ c1 1)) ;Add 1 to counter ; ;=================This section of code by Tharwat================= (if (and (setq ss (ssget "_+.:S:E" '((0 . "INSERT")))) (> (sslength ss) 0) ) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (setq sn1 sn) (if (< (length s) 21) (setq s (cons (cdr (assoc 2 (entget sn))) s)) ) (entdel sn) ) ) ;==================================================== (setq s1 (car s)) ;Converts a list to string by Kent Cooper ; ====================This code inserts first block ================================= (if (= c1 1) (progn (command "-insert" s1 "92.68,15.79" "" "" "") (command "_erase" "c" "29.68,27.55" "28.39,27.20" "") (command "-insert" "01" "29.06,26.81" "" "" "") ) ) ;====================================================== If the selection misses for block s1, : How would I check for that? Thanks, Steve
Message 7 of 9
Kent1Cooper
in reply to: safcadd08


@safcadd08 wrote:
Hello, If I pick, the counter will advance even if I miss the block...Is their a better way to do this? Thanks for the reply. Steve

Before looking at your latest, since I came up with the attached, here it is.  But it occurs to me to wonder [maybe this will be apparent in your latest post that I haven't looked into yet]:  do you want to pick them one at a time so that it matters if you miss, or would you also like to be able to select them by window/crossing/wp/cp/fence methods?  In some ways the latter would be easier, but the attached assumes the former because of your wording above.

Kent Cooper, AIA
Message 8 of 9
safcadd08
in reply to: Kent1Cooper

Hello, The selection is one at a time, so each block pick will need to be checked. Thanks, Steve
Message 9 of 9
Kent1Cooper
in reply to: safcadd08


safcadd08 wrote:
....

(if (and (setq ss (ssget "_+.:S:E" '((0 . "INSERT")))) (> (sslength ss) 0) )

  (repeat (setq i (sslength ss))....

;Converts a list to string by Kent Cooper ;

....

 

If the selection misses for block s1, : How would I check for that? Thanks, Steve


Hard to say as it appears here, but I pasted it into Notepad and sorted it some, and I don't understand a few things.

 

It seems to be missing a right parenthesis somewhere, but I'm not positive.

 

There are a few mystery characters as it comes up in Notepad, so I wonder whether I'm missing something.

 

The sn1 variable doesn't appear to be used for anything, and I'm not sure about the need for the c1 variable.

 

The reference to me doesn't seem to be about anything that's going on in the code.

 

This part:

  (if (and (setq ss (ssget "_+.:S:E" '((0 . "INSERT")))) (> (sslength ss) 0))
    (repeat (setq i (sslength ss))

doesn't make much sense to me.  The :S is for single-object selection, so (sslength ss) should always be 1, so there doesn't seem to be much point in the (repeat) function and the i counter variable.

 

As to your question at the end, I don't see how the selection set can miss for block s1, since it looks like s1 is the first block name in a list, and nothing's going into that list unless it is found in the (ssget) function.  Do you mean if nothing is found at the point of (ssget) selection, well before the s1 variable is set?  If that's the case, you could put a prompt as an 'else' argument to complement the (repeat) function that is the 'then' argument to the (if) function, something like this:
 

  (if (and (setq ss (ssget "_+.:S:E" '((0 . "INSERT")))) (> (sslength ss) 0))
    (repeat (setq i (sslength ss))

      .....

    ); end repeat

    (prompt "\nNo Block selected."); else

  ); end if

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost