Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Member
odin
Posts: 5
Registered: ‎05-28-2012
Message 1 of 7 (149 Views)
Accepted Solution

Apperaring Warning error

149 Views, 6 Replies
05-28-2012 10:20 PM
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 :smileyhappy:
Distinguished Mentor
_Tharwat
Posts: 599
Registered: ‎07-02-2010
Message 2 of 7 (146 Views)

Re: Apperaring Warning error

05-28-2012 10:35 PM in reply to: odin

e.g.

 

(if (eq <inputs) correct)

    (do this)

    (otherwise print a message of your desire )

)

 

____________________________________________________
Get learn and learn and practice , to become experienced guy .
Distinguished Mentor
Moshe-A
Posts: 739
Registered: ‎09-14-2003
Message 3 of 7 (123 Views)

Re: Apperaring Warning error

05-29-2012 09:56 AM 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

 

 

*Expert Elite*
Kent1Cooper
Posts: 5,368
Registered: ‎09-13-2004
Message 4 of 7 (117 Views)

Re: Apperaring Warning error

05-29-2012 10:37 AM 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
Member
odin
Posts: 5
Registered: ‎05-28-2012
Message 5 of 7 (97 Views)

Re: Apperaring Warning error

05-29-2012 10:11 PM in reply to: odin
Thanks a lot, I'll try to use it in my drawing, it will usefull for me Rrgard, Odin
Member
odin
Posts: 5
Registered: ‎05-28-2012
Message 6 of 7 (91 Views)

Re: Apperaring Warning error

05-29-2012 11:08 PM in reply to: _Tharwat
Thanks a lot it will help full
Member
odin
Posts: 5
Registered: ‎05-28-2012
Message 7 of 7 (90 Views)

Re: Apperaring Warning error

05-29-2012 11:10 PM in reply to: Kent1Cooper
Thanks a lot It will help full for me
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.