Jump to content

Proceed with routine only if SSLENGTH=1...?


lamensterms

Recommended Posts

Hey guys,

 

I've got this routine which I plan to use as a tool to rev up drawings. It basically duplicates the revision block and puts the old revision block within another block (so it cannot be edited by another 'block attribute update' routine).

 

This routine is dependent on there only being one instance of the revision block within the drawing, so I wanted to add that condition to the code.

 

So my code is:

 

(defun c:REVUP ( / ss NBASE ruPt1 )
(setq ss (ssget "all" '((0 . "INSERT") (66 . 1) (2 . "*REVISIONS"))))
(if (= (sslength ss) 1)
(progn
(SETQ NBASE (POLAR '(0 0 0) (* PI (/ 90 180.0)) (* (GETVAR "DIMSCALE") 5)))
(COMMAND "COPY" SS "" "0,0,0" NBASE)
(setq ruPt1 '( 0 0 0))
(command "copybase" RUpt1 SS "" "pasteblock" RUpt1 "erase" "p" "")
)
)
(princ)
)

 

This code does not seem to work (at least, the IF and PROGN sections). The routine will run even if there are more than 1 instance of the revision block.

 

Just wondering if someone can please advise me on where I have gone wrong.

 

Thanks a lot for any help.

Link to comment
Share on other sites

Hi BigAl,

 

Thanks for the reply. I had a bit of an issue with SSGET "X", it seems that when the old revision blocks are placed in blocks (with the "pasteblock" command) - SSGET "X" is still able to detect them. When I switched to SSGET "all", I understand that SSGET could no longer detect the blocks within blocks. Is this correct?

Link to comment
Share on other sites

Reading your post again why not just create a block with multiple rev lines and just check if entry is blank and if not find blank and put values in next line there is a way of counting attributes rather than using tags, if you have say 3 entries per line then 4th value would be second line 7th 10 etc I have an example somewhere in VBA this is real easy it just starts with attrib(0) attrib(1) attrib(2) till you run out. 5 lines attrib(14)

Link to comment
Share on other sites

Unfortunately the way we have our title blocks set up, this would not work. We have our revision blocks stacked above the title block. So if there is only 1 revision, there is only one revision block. Hopefully that makes sense.

 

I've been reading a bit about SSLENGTH bombing out if there is nothing in the selection set. So would it be possible to do something like...

 

If ss is empty or doesn't exist - then do this.

If ss has a SSLENGTH of 1 - then do this.

If ss has a SSLENGTH greater than 1 - then do this.

 

Sorry I can't put the code in, I'm on my mobile.

Link to comment
Share on other sites

If there are more than 1

 

Check the attribute value for last entry number/letter

Or

Check the "position" of the block relative to the title block to determine latest and greatest

 

Sslength will not bombed if use correctly ;)

 

A demo for conditions

 

(defun c:demo ( / number)
   	(setq number (getint "\nEnter Number: "))
 	(cond
  	((null number)(princ "\nNo value for number"))
	((minusp number)(princ "\nNegative number?, Why.. oh why..?"))
	((= number 1)(princ "\nThere could be only one"))
	( T (princ "\nNumber is more than 1, I'm doing this..")))
 (princ)
 )

Link to comment
Share on other sites

Hi pBe,

 

Thanks a lot for the reply. Will the "(null number)" code work for a selection set that cannot be obtained? In this case, the issue I've been having is that the block of a specific name does not exist in the drawing, and due the the selection set filter - No selection set can be created.

Link to comment
Share on other sites

Hi pBe,

 

Thanks a lot for the reply. Will the "(null number)" code work for a selection set that cannot be obtained? In this case, the issue I've been having is that the block of a specific name does not exist in the drawing, and due the the selection set filter - No selection set can be created.

 

Yes. no selection means nil --> (null ss)

Link to comment
Share on other sites

Ah cool. Thanks a lot for that pBe. I'll fix the code up and test it out in the morning.

 

Thanks again for all your help guys, I really appreciate it.

Link to comment
Share on other sites

Thanks a lot for that tip pBe, the "null" function worked perfectly.

 

Code:

 

(DEFUN C:REVUPTEST ( / )
(setq ss (ssget "all" '((0 . "INSERT") (66 . 1) (2 . "*REVISIONS"))))
(cond 

((null ss)
(ALERT "Incorrect revision block quantity, please check Drawing!\n\n(No (zero) revision blocks were detected in this drawing)")
)

((= (sslength ss) 1)
(SETQ NBASE (POLAR '(0 0 0) (* PI (/ 90 180.0)) (* (GETVAR "DIMSCALE") 5)))
(COMMAND "COPY" SS "" "0,0,0" NBASE)
(setq ruPt1 '( 0 0 0))
(command "copybase" RUpt1 SS "" "pasteblock" RUpt1 "erase" "p" "")
)

((> (sslength ss) 1)
(ALERT "Incorrect revision Blocks, please check Drawing!\n\n(There may be too many, or not enough revision blocks within drawing - there can only be one!)")
)

)
(PRINC)
)

 

Thanks again.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...