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

constant values for automatic numbering in lisp file

4 REPLIES 4
Reply
Message 1 of 5
lsokutan
157 Views, 4 Replies

constant values for automatic numbering in lisp file

Hello, I am working normally with the attached file. It numbers my blocks by asking me for the letter and starting number.

I got it from the internet and with help from there, it came to the shape I wanted.
As conditions changed, demands also changed. Now I need help with 2 things:

1) I want the following variables to have constant values. Let it read these values from the lisp file and continue, without asking questions.
(SETQ ST_STR1 (GETSTRING "\nEnter Letter (such as A. S.)")) ----> Let it automatically give the value A. here. I tried with Setq but I couldn't do it.
(SETQ ST_STR2 (GETSTRING "\nENTER"))----> skip this line. So he shouldn't want to.
(SETQ ST_STR (GETINT "\nDigit?"))----> Here it automatically starts with the number 01. Don't ask us.
2) It poses all my blocks in order and gives them the same number even though the blocks have exactly the same name. Like A.01, A.02.
If the block names are the same, how can I make it give the same number to these blocks?

Thanks very much for your help. I am attaching the file.

4 REPLIES 4
Message 2 of 5
Kent1Cooper
in reply to: lsokutan


@lsokutan wrote:

....

A)  (SETQ ST_STR1 (GETSTRING "\nEnter Letter (such as A. S.)")) ----> Let it automatically give the value A. here. I tried with Setq but I couldn't do it.
B)  (SETQ ST_STR2 (GETSTRING "\nENTER"))----> skip this line. So he shouldn't want to.
C)  (SETQ ST_STR (GETINT "\nDigit?"))----> Here it automatically starts with the number 01. Don't ask us.

....


Without studying it in detail....

On A) above, did you (setq) it as a text string?  If you didn't put the A in double-quotes, it would not work as you want.

(SETQ ST_STR1 "A")

On B), you can just remove that line, or put a semicolon ; at the beginning of it ["comment it out"] and it will be ignored.

On C), does it not work to just set it?

(SETQ ST_STR 1)

 

I'm not sure about the sayicevir function.  I think, based on how it's used later, that it should be something more like this, if deg is an argument to be supplied to it:

(defun sayicevir (deg)
  (cond
    ((and (>= deg 0) (<= deg 9)) (strcat "0" (itoa deg)))
    (t (itoa deg))

  )

)

Or, more simply:

(defun sayicevir (deg)
  (if (<= 1 deg 9) (strcat "0" (itoa deg)) (itoa deg))

)

Or even this:

(defun sayicevir (deg)
  (strcat (if (<= 1 deg 9) "0" "") (itoa deg))

)

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

unfortunately it didn't happen. problem not solved.

Message 4 of 5
Kent1Cooper
in reply to: lsokutan


@lsokutan wrote:

unfortunately it didn't happen. problem not solved.


To which "it" are you referring?  Give us much more information to work with about the "problem" you are having.  What happens, and in what way is it different from what you intend?  Are there any messages?  Etc., etc.

On the one I called B) above, should there be a constant value put into that variable as with your "A" and 1, rather than just skipping it?  It is used later, which would be a problem with no value in it.

Kent Cooper, AIA
Message 5 of 5
Sea-Haven
in reply to: lsokutan

A couple more suggestions,

 

(SETQ BLOCK_LIST (SSGET))

(SETQ BLOCK_LIST (SSGET '((0 . "INSERT"))))

"If the block names are the same, how can I make it give the same number to these blocks?" can be done need to make a list of block name and entity name, so set say "A.01." loop through the list and only change to A.02. when block name changes, keep changing as required. 

(SETQ ST_STR1 (GETSTRING "\nHarf Gir (A. S. gibi)"))
  (SETQ ST_STR2 (GETSTRING "\nENTER"))
  (SETQ ST_STR (GETINT "\nRakam?"))

(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Enter values " "Harf Gir (A. S. gibi)" 10 9  "A. ." "Rakam" 5 4 "1")))
(setq ST_STR1 (nth 0 ans))
(setq ST_STR (atoi (nth 1 ans))) ; need to check is less than ten so 01 02 etc.

SeaHaven_1-1706597375221.png

Will add to my to do list some one else may do something for you and post before I have some time. Would just start from scratch.

 

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

Post to forums  

Autodesk Design & Make Report

”Boost