Author Topic: ===[CHALLENGE - hex fractal]===  (Read 3530 times)

0 Members and 1 Guest are viewing this topic.

gile

  • Water Moccasin
  • Posts: 2492
  • Marseille, France
Re: ===[CHALLENGE - hex fractal]===
« Reply #15 on: March 23, 2018, 03:58:37 PM »
When I replace (command-s) with (vl-cmdf) on A2014 it works, but on A2017 it doesn't... Can you explain?

I can't explain, it seems there's something wrong (bug?) with vl-cmdf. The "hex0" block is not created.

Anyway, why don't you use command-s which is available since AutoCAD 2012 and  should be faster than both command and vl-cmdf?
Speaking English as a French Frog

gile

  • Water Moccasin
  • Posts: 2492
  • Marseille, France
Re: ===[CHALLENGE - hex fractal]===
« Reply #16 on: March 23, 2018, 06:26:11 PM »
When I replace (command-s) with (vl-cmdf) on A2014 it works, but on A2017 it doesn't... Can you explain?

I got it.

This is due to the fact that vl-cmdf returns T if none of the arguments are nil while command-s always returns nil.
So, in the following expression:
Code - Auto/Visual Lisp: [Select]
  1.       (or (tblsearch "BLOCK" "hex0")
  2.           (command-s "_.polygon" 6 c "_inscribe" (polar c (/ pi 2) 1))
  3.           (command-s "_.block" "hex0" c (entlast) "")
  4.       )
both (command-s ...) expressions are executed while with:
Code - Auto/Visual Lisp: [Select]
  1.       (or (tblsearch "BLOCK" "hex0")
  2.           (vl-cmdf "_.polygon" 6 c "_inscribe" (polar c (/ pi 2) 1))
  3.           (vl-cmdf "_.block" "hex0" c (entlast) "")
  4.       )
only the first (vl-cmdf ...) expression is executed.

So, if you want to use vl-cmdf, just replace this expression with:
Code - Auto/Visual Lisp: [Select]
  1.       (if (not (tblsearch "BLOCK" "hex0"))
  2.         (progn
  3.           (vl-cmdf "_.polygon" 6 c "_inscribe" (polar c (/ pi 2) 1))
  4.           (vl-cmdf "_.block" "hex0" c (entlast) "")
  5.         )
  6.       )
Speaking English as a French Frog

ribarm

  • Gator
  • Posts: 3180
  • Marko Ribar, architect
Re: ===[CHALLENGE - hex fractal]===
« Reply #17 on: March 24, 2018, 05:06:01 AM »
Thanks, that explains things...

FYI, (command-s) is just slightly slower than (vl-cmdf)... Test it for yourself :
https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/fit-arc-lisp-not-working-in-2017/m-p/7401334/highlight/true#M359125

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

gile

  • Water Moccasin
  • Posts: 2492
  • Marseille, France
Re: ===[CHALLENGE - hex fractal]===
« Reply #18 on: March 24, 2018, 06:03:31 AM »
From the tests I did using MP's Benchmark routine, command-s is slighty faster.

Never mind, if execution speed is an issue, don't use command/vl-cmdf/command-s at all, or better, don't use LISP...
Speaking English as a French Frog