本帖最后由 南国浪子 于 2012-4-30 11:00 编辑
过程是这样的,先画好标准的矩形(四边形),然后倒R角,一般是三大一小,或三小一大,如3-R1.8 &R.8或3-R0.8&R1.8
然后运行TEST.LSP,通过计算自动倒出与R相对应的C角,如3-C2.0&C1.0或者3-C1.0&C2.0
其中C角大小是程序通过计算R大小后加上0.2得到的,这部分程序已经实现
现在主要的问题是有部分图形可以完成,有些又不行,不知道为什么,因小弟是初学LSP,程序有点不专业,请大师们给予指正
- (defun c:test (/ entssa vn minpt maxpt ssent tem li ven sp dp sp1 sp2 dis tem1 tem2 sp11 sp12 dp11 dp12)
- (setvar "cmdecho" 0)
- (setq os (getvar "osmode"))
- (setvar "osmode" 512)
- (command "ucs" "w")
- (setq entssa (ssget (getpoint "\n选择多义线外形:")))
- (setq vn (vlax-ename->vla-object (ssname entssa 0)))
- (Vla-GetBoundingBox vn 'MinPt 'MaxPt)
- (setq MinPt (vlax-safeArray->list MinPt)
- MaxPt (vlax-safeArray->list MaxPt)
- )
- (setq long (- (car maxpt) (car minpt)))
- (setq wide (- (cadr maxpt) (cadr minpt)))
- (setq ssent (entget (ssname entssa 0)))
- (if (equal (cdr (assoc 0 (entget (ssname entssa 0))))
- "LWPOLYLINE"
- )
- (progn
- (setq n 0
- tem '()
- )
- (repeat (length ssent)
- (setq li (car (nth n ssent)))
- (setq ven (cdr (nth n ssent)))
- (if (= 10 li)
- (setq tem (append (list ven) tem))
- )
- (setq n (1+ n))
- )
- )
- )
- (setq tem1 (car tem))
- (setq tem2 (cdr tem))
- (setq tem (append tem2 (list tem1)))
- (setq n 0)
- (repeat 4
- (setq sp (nth (* 2 n) tem))
- (setq sp1 (polar sp (* (- 1.5 (* 0.5 n)) pi) (/ wide 2)))
- (setq sp1 (cons 0.0 sp1 ))
- (setq sp11 (car sp1))
- (setq sp12 (cdr sp1))
- (setq sp1 (append sp12 (list sp11)))
- (setq dp (nth (1+ (* 2 n)) tem))
- (setq dp1 (polar dp (* (- 1 (* 0.5 n)) pi) (-(/ wide 2))))
- (setq dp1 (cons 0.0 dp1 ))
- (setq dp11 (car dp1))
- (setq dp12 (cdr dp1))
- (setq dp1 (append dp12 (list dp11)))
- (setq dis (+ 0.2 (/ (distance sp dp) (sqrt 2))))
- (setvar "osmode" 0)
- (command "chamfer" "d" dis dis "chamfer" sp1 dp1)
- (setq n (1+ n))
- )
- (setvar "osmode" os)
- (princ)
- )
|