Author Topic: Modify Layer  (Read 1474 times)

0 Members and 1 Guest are viewing this topic.

josano

  • Guest
Modify Layer
« on: November 26, 2010, 08:13:56 AM »
Friends,

I have a lisp in the company to enter the center circle with line, lisp modified to accept two layers that already exist in.
The lisp asks the diameter, but the point in putting the error  :-(
Does anyone know please tell me where is the mistake?
Thanks for the help.

Hugs,
Josano

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Modify Layer
« Reply #1 on: November 26, 2010, 08:23:23 AM »
There's quite a lot of the code that could be improved as far as error trapping goes, but I believe your error is occurring as some of your 'command' functions only have one 'm':

Code: [Select]
(comand "-layer"...
Are you using the VLIDE to write code? If you use a code editor, you can see these kind of mistakes easily as the functions are highlighted :-)

Perhaps see here:

http://lee-mac.com/introtovlide.html

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Modify Layer
« Reply #2 on: November 26, 2010, 08:39:08 AM »
Had a bit of time, so I would recommend perhaps something along these lines (for UCS planes parallel to WCS that is):

Code: [Select]
(defun c:CIR ( / *error* Line Circle pt )

  (defun *error* ( msg )
    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **")))
    (princ)
  )

  (defun line ( p q l )
    (entmakex
      (list
        (cons 0 "LINE")
        (cons 8  l)
        (cons 10 p)
        (cons 11 q)
      )
    )
  )

  (defun circle ( c r l )
    (entmakex
      (list
        (cons 0 "CIRCLE")
        (cons 8  l)
        (cons 10 c)
        (cons 40 r)
      )
    )
  )

  (if
    (and (setq pt (getpoint "\nForneca o ponto de insercao: "))
      (setq *rad*
        (cond
          (
            (getdist pt
              (strcat "\nRaggio "
                (if *rad* (strcat "<" (rtos *rad*) "> : ") ": ")
              )
            )
          )
          ( *rad* )
        )
      )
    )
    (progn
      (line (trans (polar pt    (/ pi 2.)     (* *rad* 1.6)) 1 0)
            (trans (polar pt (/ (* 3. pi) 2.) (* *rad* 1.6)) 1 0) "LC1"
      )

      (line (trans (polar pt       0          (* *rad* 1.6)) 1 0)
            (trans (polar pt       pi         (* *rad* 1.6)) 1 0) "LC1"
      )
      (circle (trans pt 1 0) *rad* "CT4")
    )
  )

  (princ)
)

Entmake is a much easier way to approach it as you don't have to go messing with the OSMODE...

Also have you looked into Points with PDMODE=34 ;)

josano

  • Guest
Re: Modify Layer
« Reply #3 on: November 26, 2010, 08:54:42 AM »
Lee,

Thanks for help.
That is exactly what I had imagined but as a beginner I'm a bit lost in time.

Hugs,
Josano

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Modify Layer
« Reply #4 on: November 26, 2010, 08:57:30 AM »
You're very welcome Josano, happy I could lend a hand  :-)