Author Topic: HIELP ME WITH THIS LISP  (Read 1470 times)

0 Members and 1 Guest are viewing this topic.

vnanhvu

  • Guest
HIELP ME WITH THIS LISP
« on: August 07, 2011, 12:49:02 AM »
  I make a lisp for break object, but make error with osnap ( turn off NEAREST regime osnap
Code: [Select]
(defun c:BRR(/ cobj ent ov pt1 pt2 tmp vl str); brk -> Break Curve
  (vl-load-com)
  (command "undo" "be")
  (setq vl '("osmode" "orthomode" "cmdecho") ; Sys Var list
ov (mapcar 'getvar vl))              ; Get Old values
  (mapcar 'setvar vl '(545 0 0))
  (if (and (setq Ent (car (entsel "\nChon doi tuong can chia :")))
   (wcmatch (cdr (assoc 0 (entget ent))) "*LINE,ARC")
   (not (redraw ent 3))
   (setq pt1 (getpoint "\nDiem dau :"))
   (setq pt2 (getpoint "\nDiem cuoi :"))   )
    (progn
          (setq cObj (vlax-ename->vla-object Ent)
    pt1 (vlax-curve-getClosestPointto cObj (trans pt1 1 0))
    pt2 (vlax-curve-getClosestPointto cObj (trans pt2 1 0)))
      (if (> (vlax-curve-getParamAtPoint cObj pt1)
     (vlax-curve-getParamAtPoint cObj pt2))
(setq tmp pt1 pt1 pt2 pt2 tmp) )     
      (command "._break" ent "_non" (trans pt2 0 1) "_non" (trans pt2 0 1))
      (if (equal pt1 (vlax-curve-getStartPoint cObj) 0.001)
(command "change" ent "" "p" "LA" (lcurr) "")
(progn
  (command "._break" ent "_non" (trans pt1 0 1) "_non" (trans pt1 0 1))
  (command "change" (entlast) "" "p" "LA" (lcurr) "")
  )
)
      (redraw ent 4)
      (mapcar 'setvar vl ov) ; reset Sys Vars
      (command "undo" "e")
      )
    (alert "Khong hop le !"))
  (princ))
;
(defun lcurr(/ e)
     (setq str (getstring t "\n Nhap ten layer hoac Enter de pick vao doi tuong :"))
(if (= str "")
(progn
(while (null (setq e (entsel "\n pick vao doi tuong :"))))
(setvar "clayer" (cdr(assoc 8 (entget(car e)))))
)
(progn
(while (null (tblsearch "layer" str))
(setq str (getstring t "\n Nhap lai ten layer :"))
)
(setvar "clayer" str)
)
)
)
). Can you help me fix this error. Thank you very much

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: HIELP ME WITH THIS LISP
« Reply #1 on: August 07, 2011, 07:40:59 AM »
To turn off Nearest
Code: [Select]
(mapcar 'setvar vl '(33 0 0)) ; (- 545 512)
Another example of break
http://www.theswamp.org/index.php?topic=10370.0
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.