dbdr:让你见笑了.我不会用mdt,以后有机会希望能学学.不过为了不辜负大家的支持我觉得还是应该把程序贴出来,让大家讨论以下,希望能得到你的支持.
说明:该程序只是为了掸明实现曲面到曲面实体的思路,漏洞很多,希望大家共同完善!!
;曲面按照指定方向生成的曲面等厚实体 ;沪 ljc 2005.6 (defun c:st() (command "ucs" "w") (setq cm(getvar "cmdecho") os(getvar "osmode") ) (setvar "cmdecho" 0) (setq bh(getint "请输入板厚:")) (setq xf (car (entsel "请选择法线:"))) (if (= xf nil) (setq xf (car (entsel "请选择法线:"))) ) (princ "请选择曲面:") (setq ss (ssget '((0 . "3DFACE") )) ) (setq n (sslength ss)) (setq a 0) (repeat n (setq qm (ssname ss a)) (setq qm(entget qm)) (setq p10(cdr(assoc 10 qm))) (setq p11(cdr(assoc 11 qm))) (setq p12(cdr(assoc 12 qm))) (setq p13(cdr(assoc 13 qm))) (setvar "osmode" 0) (command "3dpoly" p10 p11 p12 "c" ) (setvar "osmode" os) (setq m1(entlast)) (command "region" m1 "") (setq m1(entlast)) (jj p10 p11 p12 xf) (setq cd (/ bh sinjj)) (command "LENGTHEN" "t" cd xf "") (command "extrude" m1 "" "p" xf "") (setq t1(entlast)) (setvar "osmode" 0) (command "3dpoly" p12 p13 p10 "c" ) (setvar "osmode" os) (setq m2(entlast)) (command "region" m2 "") (setq m2(entlast)) (jj p10 p11 p12 xf) (setq cd (/ bh sinjj)) (command "LENGTHEN" "t" cd xf "" ) (command "extrude" m2 "" "p" xf "") (setq t2(entlast)) (command "union" t1 t2 "" ) (setq a (+ a 1)) ) (setvar "cmdecho" cm) (command "_union" "all" "") (command "_shademode" "g")
) ;******************
;======夹角=========== ;======ljc.2005.7===== (DEFUN jj( p0 p1 p2 fx / p3 p4 a b c x x0 x1 x2 x3 x4 y y0 y1 y2 y3 y4 z z0 z1 z2 z3 z4 yy rr ) (setq p3(cdr(assoc 10 (entget fx))) p4(cdr(assoc 11 (entget fx))) ) (setq x0(car p0) y0(cadr p0) z0(last p0)) (setq x1(car p1) y1(cadr p1) z1(last p1)) (setq x2(car p2) y2(cadr p2) z2(last p2)) (setq x3(car p3) y3(cadr p3) z3(last p3)) (setq x4(car p4) y4(cadr p4) z4(last p4))
(setq a(- (* (- y1 y0) (- z2 z0)) (* (- y2 y0) (- z1 z0)))) (setq b(- (* (- z1 z0) (- x2 x0)) (* (- z2 z0) (- x1 x0)))) (setq c(- (* (- x1 x0) (- y2 y0)) (* (- x2 x0) (- y1 y0)))) (setq x(- x4 x3) y(- y4 y3) z(- z4 z3)) (setq yy(abs(+ (* a x) (* b y) (* c z) ))) (setq rr(* (expt (+ (expt a 2) (expt b 2) (expt c 2) ) 0.5) (expt (+ (expt x 2) (expt y 2) (expt z 2) ) 0.5))) (setq sinjj(/ yy rr))
)
|