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

Apperaring Warning error

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
odin
423 Views, 6 Replies

Apperaring Warning error

I have made a block with consist of shape drawing and some attribute data that must specified when the block inserted. my question is, how to make "warning error input" appear if mistake input occurs? thanks to anyone could help me 🙂
Tags (1)
6 REPLIES 6
Message 2 of 7
_Tharwat
in reply to: odin

e.g.

 

(if (eq <inputs) correct)

    (do this)

    (otherwise print a message of your desire )

)

 

Message 3 of 7
Moshe-A
in reply to: odin

Odin,

 

that's depands on what input the user should be enter...if the attribute is expecting a numeric value?

then you can do somthing like this?:

 

(setq real_value (getreal "\nEnter real value: ")) ; require a value from 0 to 100

(if (and

         (>= real_value 0)

         (<= real_value 100)

    )

   (do_insert_block)

   (prompt "\n*invalid value*")

)

 

if the attribute is expecting a string value (like a key option)?

then you can do somthing like that:

 

(initget "Red Yellow Green Cyan") ; note the capital letter at start of each key word option

(setq color (getkword "\nChange color -> Red/Yellow/Green/Cyan: "))

 

the user can enter only R for Red, Y for Yellow (like any other key option in any other

standard AutoCAD Command

 

if user misses to specify the right key option? then autolisp it self will alert him and continue

to pause until the right value (allowed) is given.

 

 

Cheers,

Moshe

 

 

Message 4 of 7
Kent1Cooper
in reply to: Moshe-A


@Moshe-A wrote:

....if the attribute is expecting a numeric value?

then you can do somthing like this?:

 

(setq real_value (getreal "\nEnter real value: ")) ; require a value from 0 to 100

(if (and

         (>= real_value 0)

         (<= real_value 100)

    )

   (do_insert_block)

   (prompt "\n*invalid value*")

)

.... 


Two refinements I would suggest:

 

Numerical value comparison functions can take more than two arguments.  So in place of

 

(and

  (>= real_value 0)

  (<= real_value 100)

)

 

you can do simply:

 

(<= 0 real_value 100)

 

And if you format it something like this:

 

(while
  (not
    (<=
      0 ; minimum allowable value
      (setq real_value (getreal "\nEnter real value: "))
      100 ; maximum allowable value
    ); <=
  ); not
  (prompt "\nYou must give a value between 0 and 100.")
); while

.... go on with insertion, feeding values in where Attribute prompts occur ....

 

it will work like the (initget)/(getkword) approach, in that it will keep asking for input until a valid value is supplied, rather than just taking one input, and if it's wrong, putting up a message and stopping.

Kent Cooper, AIA
Message 5 of 7
odin
in reply to: odin

Thanks a lot, I'll try to use it in my drawing, it will usefull for me Rrgard, Odin
Message 6 of 7
odin
in reply to: _Tharwat

Thanks a lot it will help full
Message 7 of 7
odin
in reply to: Kent1Cooper

Thanks a lot It will help full for me

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

Post to forums  

Autodesk Design & Make Report

”Boost