Author Topic: Advancing my routine from "just works" to proficient  (Read 5703 times)

0 Members and 1 Guest are viewing this topic.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Advancing my routine from "just works" to proficient
« Reply #15 on: September 01, 2015, 03:43:58 AM »
@ Lee:
Why the use of vl-catch-all-apply? Are there numbers where rtos will error out?

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Advancing my routine from "just works" to proficient
« Reply #16 on: September 01, 2015, 04:27:55 AM »
@ Lee:
Why the use of vl-catch-all-apply? Are there numbers where rtos will error out?

My original thought process (before adding the if statement to account for approximate integers) was to ensure that DIMZIN was reset no matter the outcome of the rtos call, and so I [lazily] wrapped the expression in a vl-catch-all-apply; but since rtos is now called within the test expression for the if statement (and so would error on an invalid argument before DIMZIN is modified), I agree that the vl-catch-all-apply is no longer required - thanks.
« Last Edit: September 01, 2015, 04:31:20 AM by Lee Mac »

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Advancing my routine from "just works" to proficient
« Reply #17 on: September 01, 2015, 06:02:21 AM »
... Some would argue that a function *should* throw an error when supplied with an invalid argument.

FWIW: I think this is strange:
Code: [Select]
: (LM:num->str 1.00000001)
"1"
: (LM:num->str 1.500000000000001)
"1.500000000000001"

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Advancing my routine from "just works" to proficient
« Reply #18 on: September 01, 2015, 06:23:50 AM »
... Some would argue that a function *should* throw an error when supplied with an invalid argument.

I agree it should - but in the previous iteration of this function, such an error would cause DIMZIN to not be reset if vl-catch-all-apply were not used.

FWIW: I think this is strange:
Code: [Select]
: (LM:num->str 1.00000001)
"1"
: (LM:num->str 1.500000000000001)
"1.500000000000001"

I agree - either the initial test should use a tolerance of 1e-15 or the conversion should use a precision argument of 8.

Initially the test for an approximate integer was not included, but I subsequently modified the function as I wanted to avoid results such as 1.999999999999998 caused by the floating-point format, but retain maximum accuracy in other cases.

cgeorg13

  • Guest
Re: Advancing my routine from "just works" to proficient
« Reply #19 on: September 04, 2015, 10:54:19 AM »
I have just encountered a major problem that i cant figure out how to test for.

If I run the lisp on a selection set that has a line without any attached object data, it errors out.

what i would like it to do is just increment i and move on to the next entity in the list.

I was wondering if I could use vlax-method-applicable-p to test for getting Object Data or if there is a way to return if an item has attached object data.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Advancing my routine from "just works" to proficient
« Reply #20 on: September 04, 2015, 04:42:36 PM »
cgeorg13,

Excuse me for being a grumpy old person ;

You are making the assumption that someone knows which lisp code you are talking about.

If you want anyone other than the masochists among us to look at your problem you'll need to be explicit.

What code are you using and where does it crash ??

//---------

There will be several ways to create a conditional to make your test.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Advancing my routine from "just works" to proficient
« Reply #21 on: September 04, 2015, 04:53:31 PM »
I don't use Map, so :

If the entity does not have any data added what does this return ?


Code - Auto/Visual Lisp: [Select]
  1.   (setq ent (car (entsel "\nSelect point to follow link")))
  2.   (setq link (ade_odgetfield ent "myTable" "myField" 0))

Have you tried something like :
Code - Auto/Visual Lisp: [Select]
  1. (if (ade_odgettables thingy) ...
« Last Edit: September 04, 2015, 04:58:37 PM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.