五金模具中集体偏移的程序
<P>我想做一个五金模具中集体偏移的程序.</P><P>比如我的图形有5个圆,5个封闭复合线.</P>
<P>我现在选择此10个图元后,我输入正值,此10个图元集体向外偏移.</P>
<P>我输入负值,此10个图元集体向内偏移.</P>
<P>考虑了好久,没搞定输入负值的情况,请高手指点.</P>
<P>(我需要程序原代码)</P> <P>;1. 将下载的“off1.fas”存入G盘目录下,如存入<BR>; 其它地址,则修改程序中“(load "g:/off1.fas")”<BR>; 使之相符。<BR>;2. 使用以下示例程序,即可完成图元的集体偏移。</P>
<P>(defun c:cc()<BR> (if (null off1)(load "g:/off1.fas"))<BR> (while (setq jl (getreal "\n 请选择偏移距离<回车结束>:"))<BR> (princ "\n 请选择要偏移的图元:")<BR> (if (and jl (setq sa (ssget))) (off1 jl sa))<BR> )<BR> )</P> <P>;1. 将下载的“off1.fas”存入G盘目录下,如存入<BR>; 其它地址,则修改程序中“(load "g:/off1.fas")”<BR>; 使之相符。<BR>;2. 使用以下示例程序,即可完成图元的集体偏移。</P>
<P>(defun c:cc()<BR> (if (null off1)(load "g:/off1.fas"))<BR> (while (setq jl (getreal "\n 请选择偏移距离<回车结束>:"))<BR> (princ "\n 请选择要偏移的图元:")<BR> (if (and jl (setq sa (ssget))) (off1 jl sa))<BR> )<BR> )</P> 怎么附件传不上来,请致电<A href="mailto:hrycly@126.com" target="_blank" >hrycly@126.com</A> <P>(defun c:fs(/ oce vs1 ent_list id list_len ent msg od)<BR> ;(setq oce (getvar "cmdecho"))<BR> ;(setvar "cmdecho" 0)<BR> (setq vs1 (getvar "vsmax"))<BR> (setq msg (strcat "Give the offset dist<" (rtos (getvar "offsetdist")) ">:" ))<BR> (setq od (getdist msg ))<BR> (if (= nil od) <BR> (setq od (getvar "offsetdist"))<BR> (setvar "offsetdist" od)<BR> )<BR> (setq ent_list (ssget))<BR> (setq list_len (sslength ent_list))<BR> (setq id 0)<BR> (ssname ent_list id)<BR> (repeat list_len <BR> (setq ent (ssname ent_list id))<BR> (command ".offset" "" ent vs1 "")<BR> (command ".change" (entlast) "" "p" "c" "red" "")<BR> (entdel ent)<BR> (setq id (1+ id))<BR> )<BR> (prinC (strcat (rtos list_len 2 0) " Entites has offseted."))<BR> (PRINC)<BR> <BR>)</P>
<P>不过这个只能放大</P> chenknight 发表于 2005-10-6 12:11
(defun c:fs(/ oce vs1 ent_list id list_len ent msg od) ;(setq oce (getvar "cmdecho")) ;( ...
谢谢兄弟 分享的好程序:handshake (defun C:py ( / curve ent holdcmd holdosmode jang n pt pt1 pt2 ss tmp x)
(if (not (tblsearch "layer" "补偿前"))
(command "layer" "n" "补偿前" "c" "4" "补偿前" "")
)
(defun LEN (CURVE / TLEN)
(setq TLEN (vlax-curve-getdistatparam
CURVE
(vlax-curve-getendparam CURVE)
)
)
)
(setq HOLDOSMODE (getvar "OSMODE"))
(setq HOLDCMD (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(setvar "OSMODE" 0)
(while
(setq ss (ssget '((0 . "*LINE,circle,ARC"))))
(progn
(setq n 0)
(initget 2)
(if *move*
(setq tee_dist (getreal (strcat"\n请输入补偿:<" (rtos *move* 2 2) ">:")))
(setq tee_dist (getreal "\n请输入补偿:"))
)
(if (null tee_dist)
(setq tee_dist *move*)
(setq *move* tee_dist)
)
(setq tee_dist(/ tee_dist 2))
(repeat (sslength ss)
(setq ent (ssname ss n)
n (1+ n)
)
(setq CURVE (vlax-ename->vla-object ENT)
x (vlax-curve-getParamAtDist curve (/ (len curve) 3.33))
pt (vlax-curve-getPointAtParam curve x)
)
(setq JANG (angle '(0 0 0) (vlax-curve-getfirstderiv CURVE X)))
(setq PT1 (polar PT (+ JANG (* 0.5 pi)) 0.00000001))
(setq PT2 (polar PT (- JANG (* 0.5 pi)) 0.00000001))
(command "_.OFFSET" (abs tee_dist) ENT PT1 "")
(if (or (and (> tee_dist 0) (> (LEN CURVE) (LEN (entlast))))
(and (< tee_dist 0) (< (LEN CURVE) (LEN (entlast))))
)
(progn
(entdel (entlast))
(command "_.OFFSET" (abs tee_dist) ENT PT2 "")
)
)
)
)
(command "change" ss "" "p" "la" "补偿前" "c" 150 "")
(setq sc_pd (getstring "\n是否删除对象[删除(Y)]:"))
(if (or (eq sc_pd "y") (eq sc_pd "Y") (eq sc_pd ""))
(command "ERASE" ss "" ) )
)
(setvar "OSMODE" HOLDOSMODE)
(setvar "CMDECHO" HOLDCMD)
(princ)
) 感谢你的分享
页:
[1]