明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2434|回复: 8

修改连续偏移程序

[复制链接]
发表于 2007-6-2 23:55 | 显示全部楼层 |阅读模式

高手帮我看看这个程序,是个连续偏移程序,但是不能输入小数,还在只能连续偏移三次,希望高手帮我修改一下,让它能输入小数,而且能循环输入数据!

发表于 2007-6-4 22:07 | 显示全部楼层

程序呢???

 楼主| 发表于 2007-6-4 23:26 | 显示全部楼层

(defun c:oo (/ dst)
(setq o1 (getint "\n指定偏移距离: "))
(setq c1 (entsel "选择要偏移的对象: : "))
(setq pt (getpoint "\n指定点以确定偏移所在一侧: "))
(command "offset" o1 c1 pt "")
(setq o1 (getint "\n指定偏移距离: "))
(setq c1 (entsel "选择要偏移的对象: : "))
(setq pt (getpoint "\n指定点以确定偏移所在一侧: "))
(command "offset" o1 c1 pt "")
(setq o1 (getint "\n指定偏移距离: "))
(setq c1 (entsel "选择要偏移的对象: : "))
(setq pt (getpoint "\n指定点以确定偏移所在一侧: "))
(command "offset" o1 c1 pt "")
)

不好意思,忘记上传了啦,现在传上来了,帮我看看

发表于 2007-6-5 15:37 | 显示全部楼层

(setq o1 (getint "\n指定偏移距离: "))
改为

(setq o1 (getreal "\n指定偏移距离: "))
楼主看看我以前编的程序:

;*****************************************************************

 ;              fg1.LSP
;   BY zjyangxyz        
;   8 september 2004
;   This program  automatically offset distance(only out offset)
;;; **********************************************************************;

(defun clerr (s)
  (if (/= s "Function cancelled")     ; If an error (such as CTRL-C) occurs
    (princ (strcat "\nError: " s))    ; while this command is active...
  )
  (command "UCS" "P")                 ; Restore previous UCS
  (setvar "BLIPMODE" sblip)           ; Restore saved modes
  (setvar "GRIDMODE" sgrid)
  (setvar "HIGHLIGHT" shl)
  (setvar "UCSFOLLOW" sucsf)
  (command "LAYER" "S" clay "")
  (command "undo" "e")
  (setvar "CMDECHO" scmde)
  (setq *error* olderr)               ; Restore old *error* handler
  (princ)                            
)
;*****************************************************************
(defun c:fg (/ olderr scmde b1 s1 ss sblip )
   (setq olderr *error*
        *error* clerr)
   (setq sblip (getvar "BLIPMODE"))
   (setq scmde (getvar "CMDECHO"))
   (setvar "cmdecho" 0)
   (command "UNDO" "GROUP")
   (princ "\n此程序编制2004.9.08")
   (princ "\noffset distance:<") (princ x) (princ ">:")
   (setq b1 (getreal))
   (cond
           ((= nil (numberp b1)) (setq b1 x))
           ((= T (numberp b1)) (setq x b1))
   )
   (setq i 0)
   (setq ss (ssget))
   (if (null ss) (exit))
   (setq j (sslength ss))
   (repeat j
   (command "UNDO" "GROUP")
   (setq s1 (ssname ss i))
   (setq i (+ i 1))
   (command "offset" b1 s1 "0,0" "")(command "chprop" "l" "" "c" "1" "")
   (command "ERASE" s1 "")
   (command "UNDO" "END")
   )
   (command "UNDO" "END")
   (setvar "BLIPMODE" sblip)
   (setvar "CMDECHO" scmde)
   (setq *error* olderr) 
   (princ)
)
;****************end***********************

 楼主| 发表于 2007-6-6 00:08 | 显示全部楼层
兄弟,能否帮我那个程序加个循环程序,谢谢你哦
发表于 2007-6-6 16:02 | 显示全部楼层

(defun c:fg (/ olderr scmde b1 s1 ss sblip)
   (setq olderr *error*  *error* clerr)
   (setq sblip (getvar "BLIPMODE"))
   (setq scmde (getvar "CMDECHO"))
   (setvar "cmdecho" 0)
   (command "-osnap" "off")
   (command "UNDO" "GROUP")
   (princ "\noffset distance:<") (princ x) (princ ">:")
   (setq b1 (getreal))
   (cond
           ((= nil (numberp b1)) (setq b1 x))
           ((= T (numberp b1)) (setq x b1))
   )
    (setq i 0)
   (setq ss (ssget))
   (if (null ss)( cond (COMMAND "-OSNAP" "End,Mid,Cen,Node,Quad,Int,Perp,Ext") (exit)))
   (setq j (sslength ss))
   (repeat j
   (command "UNDO" "GROUP")
   (setq s1 (ssname ss i))
   (setq i (+ i 1))
   (command "offset" b1 s1 pause "")
   (command "chprop" "l" "" "c" "1" "")
   (command "ERASE" s1 "")
   (command "UNDO" "END")
   )
   (command "UNDO" "END")
   (COMMAND "-OSNAP" "End,Mid,Cen,Node,Quad,Int,Perp,Ext")
   (setvar "BLIPMODE" sblip)
   (setvar "CMDECHO" scmde)
   (setq *error* olderr) 
   (princ)
)
;****************end***********************

这个就是和你的一样了,你用一下看看!

 楼主| 发表于 2007-6-8 23:29 | 显示全部楼层
呵呵,兄弟,还是达不到我的那种效果哦,要不你再改改!
发表于 2007-6-9 11:22 | 显示全部楼层

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:wer( / h1 h2 wor)
(setvar "cmdecho" 0)
(setq h2 (entsel "\nTHE object:"))
(setq h3 (getpoint "\nThe point:"))
(setq h9 (getreal "\nThe number:"))
(command "offset" h9 h2 h3 "")
(setq m1 h9)
(while  (setq h1 (getreal "\nThe number:"))
(progn
(setq m1 (+ h1 m1))
(command "offset"  m1  h2 h3 "")
(princ m1)
)
);end while
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

这个是我的,请楼主试一下。就是没有错误返回机制了

发表于 2007-6-9 11:39 | 显示全部楼层

如果是想达到3楼的效果,并循环的。

楼上的,没问题。。。

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-19 06:32 , Processed in 0.224906 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表