Author Topic: Why this lisp not working?  (Read 1321 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Why this lisp not working?
« on: August 22, 2012, 07:42:35 AM »
I need to create a lot parallel sections in a solid
I created this code but not working
Code: [Select]
(defun c:sho (/)

  (setvar "OSNAPCOORD" 1)
  (setq ss (ssget))
 
  (while
    (setq pt (getpoint))
  (command "section" ss "" "YZ" pt)))

kruuger

  • Swamp Rat
  • Posts: 637
Re: Why this lisp not working?
« Reply #1 on: August 22, 2012, 07:51:09 AM »
I need to create a lot parallel sections in a solid
I created this code but not working
Code: [Select]
(defun c:sho (/)

  (setvar "OSNAPCOORD" 1)
  (setq ss (ssget))
 
  (while
    (setq pt (getpoint))
  (command "section" ss "" "YZ" pt)))
why not _array or _copy ?
i think you should continue this at your tread about solid.
combine solution at one topic.
k.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Why this lisp not working?
« Reply #2 on: August 22, 2012, 08:03:03 AM »
First: Localize variables. Especially selection sets - as you're only allowed a finite number of active selection sets.

Second: Rather than change a system variable to stop osnaps, use the None forced snap. Otherwise you may have to reset it back, and this reset needs to happen in an error handler. IMO much more coding.

Third: Test if something has been selected - else an error occurs.

Fourth: Localize the commands and options by prefixing with underscores. So they work on other language acads as well.

This seems to work fine for me:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:sho (/ ss pt)
  2.   (if (setq ss (ssget))
  3.     (while (setq pt (getpoint))
  4.       (command "._section" ss "" "_YZ" "_Non" pt)))
  5.   (princ))
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Why this lisp not working?
« Reply #3 on: August 22, 2012, 09:01:06 AM »
First:
...

brilliant as usual
Thanks irneb

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Why this lisp not working?
« Reply #4 on: August 22, 2012, 09:23:09 AM »
You're welcome! Glad it works for you.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.