Author Topic: LISP Guru needed  (Read 6020 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: LISP Guru needed
« Reply #15 on: August 17, 2012, 12:30:55 PM »
Lee, your amazing!

That's very kind of you to say David  :-)

With regards to the 'c:Draw3dWall' function, I suppose if you wanted to go the ActiveX route entirely, you could use something like this (probably excessive error-trapping):

Code - Auto/Visual Lisp: [Select]
  1. (defun c:draw3dwall ( / e1 e2 r1 r2 sp )
  2.     (if
  3.         (and
  4.             (setq e1 (LM:select-if "\nSelect Outer Wall: " '(lambda ( x ) (LM:catchapply 'vlax-curve-isclosed (list x)))))
  5.             (setq e2 (LM:select-if "\nSelect Inner Wall: " '(lambda ( x ) (LM:catchapply 'vlax-curve-isclosed (list x)))))
  6.         )
  7.         (progn
  8.             (setq sp (vlax-get-property (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)))
  9.             (if
  10.                 (and
  11.                     (setq r1 (car (LM:catchapply 'vlax-invoke (list sp 'addregion (list (vlax-ename->vla-object e1))))))
  12.                     (setq r2 (car (LM:catchapply 'vlax-invoke (list sp 'addregion (list (vlax-ename->vla-object e2))))))
  13.                 )
  14.                 (progn
  15.                     (vla-boolean r1 acsubtraction r2)
  16.                     (vla-addextrudedsolid sp r1 120.0 0.0)
  17.                     (vla-delete r1)
  18.                     (entdel e1)
  19.                     (entdel e2)
  20.                 )
  21.                 (princ "\nUnable to create Region from selected objects.")
  22.             )
  23.         )
  24.     )
  25.     (princ)
  26. )
  27.  
  28. (defun LM:catchapply ( func params / result )
  29.     (if (not (vl-catch-all-error-p (setq result (vl-catch-all-apply func params))))
  30.         result
  31.     )
  32. )
  33.  
  34. (defun LM:select-if ( msg pred / ent )
  35.     (setq pred (eval pred))
  36.     (while
  37.         (progn (setvar 'errno 0) (setq ent (car (entsel msg)))
  38.             (cond
  39.                 (   (= 7 (getvar 'errno))
  40.                     (princ "\nMissed try again.")
  41.                 )
  42.                 (   (= 'ename (type ent))
  43.                     (if (null (pred ent))
  44.                         (princ "\nInvalid Object selected.")
  45.                     )
  46.                 )
  47.             )
  48.         )
  49.     )
  50.     ent
  51. )
  52.  
  53. ;; Active Document  -  Lee Mac
  54. ;; Returns the VLA Active Document Object
  55.  
  56. (defun LM:acdoc nil
  57.     (LM:acdoc)
  58. )

But the extra steps that are required to convert the objects to regions, before performing the boolean subtraction, then creating the extrudedsolid yields lengthy code given the simple command call alternative.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: LISP Guru needed
« Reply #16 on: August 17, 2012, 12:45:26 PM »
But the extra steps that are required to convert the objects to regions, before performing the boolean subtraction, then creating the extrudedsolid yields lengthy code given the simple command call alternative.

And there is a lot of VL stuff there that I don't know what it is doing.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)