zhibeisha 发表于 2014-5-4 10:20:22

请教一个有关镜像的问题

我是刚学LISP语言,想请教各位下面这个问题怎么解决

(setq f1 (open "C:\\数据库cad文件夹\\dyfxcx.txt" "r"))
(initget 1)
   (setq x0 (atof (read-line f1))   
         y0 (atof (read-line f1))   
         xe (atof (read-line f1))
         ye (atof (read-line f1))
         ptf0 (list (+ x0 (car ptcxbb))(- (+ y0 (cadr ptcxbb))(* 0.25 da0)))
         ptfe (list (+ xe (car ptcxbb)) (- (+ ye (cadr ptcxbb)) (* 0.25 da0)))
         af0ptf0
    )
    (while (/= xe 1000.0)
    (command "layer" "s" "cusolidlcx" "")
    (command "line" ptf0 ptfe "" )
    (setq   xe (atof (read-line f1))
               ye (atof (read-line f1))
               ptf0ptfe
               ptfe (list (+ xe (car ptcxbb))(- (+ ye (cadr ptcxbb)) (* 0.25 da0)))
            afeptfe
    )   
   (if (/= xe 1000.0)
      (setq afee afe)
   )   
)
(command ^^)
(close f1)
(setqpfcx0afee
         pfcx1(list (car pfcx0) (- (cadr pfcx0) (- h0 ha0)))
         pfcx2(polarpfcx1 0 pox)
         t1 0
)
(setqpfcx3 (polar pfcx1 0 (* 0.5 pon))
         pfcx4 (polar pfcx1 (* 0.5 pi) (+ (- h0 ha0) 0.2))
         pfcx5 (polar pfcx1 (* 1.5 pi) h0)
)
(command "layer" "s" "centerl" "")
(command "line" pfcx1 pfcx2 "" );水平中心线
(command "line" pfcx4 pfcx5 "" );镜像对称线   


(command "mirror" "w" afee af0 "" pfcx6 pfcx7 "no");通过这句我想把读出来的数据点绘出的曲线图镜像一个,结果只能镜像一曲线顶部中的小部分,得不出完整的曲线图
(command ^^)

lsjj 发表于 2014-5-4 11:27:23

1. (command "mirror" "w" afee af0 "" pfcx6 pfcx7 "no")
pfcx6 pfcx7 在那?
2. 沒数据库dyfxcx.txt,大多人看到就當路過了

菡萏 发表于 2014-5-4 11:38:56

楼主提问前首先需认真的学习一下置顶的帖子 [公告] 【提示公告】本版关于提问的一些注意事项 再来提问!

zhibeisha 发表于 2014-5-4 15:08:29

lsjj 发表于 2014-5-4 11:27 static/image/common/back.gif
1. (command "mirror" "w" afee af0 "" pfcx6 pfcx7 "no")
pfcx6 pfcx7 在那?
2. 沒数据库dyfxcx.txt,大多 ...

不好意思   那句粘贴错了应该是(command "mirror" "w" afee af0 "" pfcx4 pfcx5 "no");
数据库已经没问题那是一系列的坐标点读出来的图形就是上图现在是将上图镜像不了

lsjj 发表于 2014-5-4 15:49:44

本帖最后由 lsjj 于 2014-5-4 15:51 编辑

老兄,你沒提供數據庫,沒完整代碼,大夥只能路過了

zhibeisha 发表于 2014-5-4 16:15:42

这就是数据文件   还有程序完整代码如下

;读入文件数据子函数
(defun dydata()
(setq f1 (open "C:\\数据库cad文件夹\\dy.txt" "r"))
(setq m (atof (read-line f1)))    ;               //滚刀模数
(setq LX(atof (read-line f1)))   ;               //单圆弧类型
(setq da0 (atof (read-line f1)))   ;            //滚刀外径
(setq L (atof (read-line f1)))   ;            //滚刀长度
(setq di (atof (read-line f1)))    ;            // 滚刀底径
(setq d1 (atof (read-line f1)))    ;            //内孔直径
(setq l1 (atof (read-line f1)))   
(setq rA (atof(read-line f1)))    ;            //键槽圆弧半径
(setq b1 (atof(read-line f1)))   ;            //键槽宽度   
(setq t1 (atof(read-line f1)))    ;            // 键高度         
(setq r1 (atof(read-line f1)))      ;            // 空刀尺寸圆弧半径
(setq D11(atof (read-line f1)))    ;            //D1空刀轴台直径
(setq l0(atof (read-line f1)))   ;            // 轴台长度         
(setq zk (atof (read-line f1)))    ;            //槽数   
(setq rr (atof (read-line f1)))    ;            //分圆螺旋升角
(setq K (atof (read-line f1)))   ;            //第一次铲背量
(setq K1 (atof (read-line f1)))   ;            //第二次铲背量
(setq H (atof (read-line f1)))    ;            //容屑槽槽深
(setq r (atof (read-line f1)))   ;            //滚刀分度圆直径
(setq d0 (atof (read-line f1)))   ;            //滚刀分度圆直径
(setq yy(atof (read-line f1)))
(setq pk (atof (read-line f1)))
(setq pon (atof (read-line f1)))    ;            //法向齿距
(setq pox (atof (read-line f1)))    ;            //轴向齿距
(setq h0(atof (read-line f1)))    ;            //齿全高
(setq ha0 (atof(read-line f1)))
(setq hk (atof(read-line f1)))
(setq hg (atof(read-line f1)))
(setq r11 (atof (read-line f1)))   ;            //槽底半径
(setq e (atof (read-line f1)))
(setq c0 (atof (read-line f1)))   ;            //槽角
(setq hk1 (atof (read-line f1)))
(setq R0 (atof (read-line f1)))
(setq ak (atof (read-line f1)))
(setq c1 (atof (read-line f1)))    ;            //空刀尺寸倒角
(setq c2 (atof (read-line f1)))    ;               //内孔直径倒角
(setq he (atof (read-line f1)))   
(setq aa (atof (read-line f1)))
(setq rg (atof (read-line f1)))
(close f1)

                                 
)


;数据过滤文件子函数
(defun dydatagl()
(dydata)
(setq    m   m    ;               //滚刀模数
         LX    LX
         da0   da0;            //滚刀外径
         L   L   ;            //滚刀长度
         di    di;            // 滚刀底径
         d1    d1
         l1   l1
         rA    rA   ;            ////键槽倒角
         b1    b1    ;            //轴向键槽宽度   
         t1    t1    ;            // 轴向键高度         
         r1    r1    ;            //轴向键槽圆弧半径
         r2    r2    ;
         D11    D11;            //D1空刀轴台直径
         l0    l0;            // 轴台长度         
         zk    zk    ;            //槽数   
       rr    rr    ;
         K   K      ;            //第一次铲背量
         K1   K1      ;            //第二次铲背量
         H   H      ;            //容屑槽槽深
         R0   R0
         d0   d0
         yy   yy
         pk   pk
         pon   pon      ;
         pox   pox      ;            //轴向齿距
         c1    c1    ;            //空刀尺寸倒角
       c   c    ;            //内孔直径倒角
         h0    h0
         ha0   ha0
         hk    hk
         hg    hg
         r   r                  
         e   e                  
         hk1   hk1
         R0    R0
         ak    ak   
         c1    c1
         c2    c2
         he    he
         aa    aa
       rg    rg
)       

)


;图层图纸设置子函数
(defun tc3()
(dydatagl)
(command "limits" '(list -100 -100 ) '(list 900 1200))
(command "zoom" "a")
(command "osnap" "off" "")      ;关闭目标捕捉   
(command "ortho" "off" "")      ;关闭捕捉命令   
(command "layer" "n" "centerl,cusolidl,xsolidl,cusolidlcx, bhatchl,dividel,demension"   
                 "c" 1 "centerl" "L" "center" "centerl""lw" 0.15 "centerl"
                 "c" 3 "cusolidl" "L" "continuous" "cusolidl" "lw" 0.30 "cusolidl"
                 "c" 2 "cusolidlcx" "L" "continuous" "cusolidl" "lw" 0.30 " cusolidlcx"
                 "c" 5 "xsolidl" "L" "continuous" "xsolidl" "lw" 0.15 "xsolidl"
                 "c" 4 "bhatchl" "L" "continuous" "bhatchl" "lw" 0.15 "bhatchl"
                 "c" 2 "dividel" "L" "divide" "dividel" "lw" 0.15 "dividel"
                 "c" 6 "demension" "L" "continuous" "demension" "lw" 0.15 "demension" "")
(command "ltscale" 5 "centerl")
(command "ltscale" 5 "dividel")
(if (and (< L 200) (<= da0 50) )
       (setq pt1 (list 0 0)
             pt2 (list 297 210)
             pt3 (list 25 5)
             pt4 (list 292 205)
             ptc1 (list 80 (+ 110 (* 0.5 da0)))
             ptc2 (polar ptc1 0 (+ L (* 0.5 da0) 70))
             ptc3 (polar ptc2 (* 0.5 pi) (+ (* 0.5 da0) 20))
             ptc4 (polar ptc2 (* 1.5 pi) (+ (* 0.5 da0) 20))
             ptcxb(list (+ (car ptc1) (* 2 pox) 20) (- (cadr pt4 ) 20))         ;齿形基点
             ptcxbb(polar ptcxb 0 (+ 30 (* 2 pox)))
       )
)
(if (and (< L 300)(<= da0 130) )
       (setq pt1 (list 0 0)
             pt2 (list 420 297)
             pt3 (list 25 5)
             pt4 (list 415 292)
             ptc1 (list 90 (+ 120 (* 0.5 da0)))
             ptc2 (polar ptc1 0 (+ L (* 0.5 da0) 80))
             ptc3 (polar ptc2 (* 0.5 pi) (+ (* 0.5 da0) 20))
             ptc4 (polar ptc2 (* 1.5 pi) (+ (* 0.5 da0) 20))
             ptcxb(list (+ (car ptc1) (* 2 pox) 20) (- (cadr pt4 ) 20))         ;齿形基点
             ptcxbb(polar ptcxb 0 (+ 30 (* 2 pox)))
        )
)
(if (and (< L 500) (<= da0 260) )
         (setq pt1 (list 0 0)
             pt2 (list 594 420)
             pt3 (list 25 10)
             pt4 (list 584 410)
             ptc1 (list 90 (+ 180 (* 0.5 da0)))
             ptc2 (polar ptc1 0 (+ L (* 0.5 da0) 80))
             ptc3 (polar ptc2 (* 0.5 pi) (+ (* 0.5 da0) 20))
             ptc4 (polar ptc2 (* 1.5 pi) (+ (* 0.5 da0) 20))
             ptcxb(list (+ (car ptc1) (* 2 pox) 20) (- (cadr pt4 ) 20))         ;齿形基点
             ptcxbb(polar ptcxb 0 (+ 30 (* 2 pox)))
          )
)
(command "layer" "s" "xsolidl" "")
(command "rectang" pt1 pt2)
(command "layer" "s" "cusolidl" "")
(command "rectang" pt3 pt4)
(command "layer" "s" "centerl" "")
(command "line" ptc1 ptc2 "")
(command "line" ptc1 (polar ptc20l1) "")          ; 水平中心线

(command "line" ptc3 ptc4 "")          ; 垂直中心线
)

;轴向齿形子程序
(defun fxcx3()
(tc3)
(setq f1 (open "C:\\数据库cad文件夹\\dyfxcx.txt" "r"))
(initget 1)
   (setq x0 (atof (read-line f1))
         y0 (atof (read-line f1))   
       xe (atof (read-line f1))
       ye (atof (read-line f1))
       ptf0 (list (+ x0 (car ptcxbb))(- (+ y0 (cadr ptcxbb))(* 0.25 da0)))
       ptfe (list (+ xe (car ptcxbb)) (- (+ ye (cadr ptcxbb)) (* 0.25 da0)))
       af0ptf0
)
   (while (/= xe 1000.0)
    (command "layer" "s" "cusolidlcx" "")
    (command "line" ptf0 ptfe "" )
    (setq   xe (atof (read-line f1))
          ye (atof (read-line f1))
            ptf0ptfe
          ptfe (list (+ xe (car ptcxbb))(- (+ ye (cadr ptcxbb)) (* 0.25 da0)))
          afeptfe
    )          
              (if (/= xe 1000.0)
                (setq        afee afe)
              )       
   
)
(command ^^)
(close f1)
(setqpfcx0afee
       pfcx1(list (car pfcx0) (- (cadr pfcx0) (- h0 ha0)))
       pfcx2(polarpfcx1 0 pox)
       t1 0
)

(setqpfcx3 (polar pfcx1 0 (* 0.5 pon))
       pfcx4 (polar pfcx3 (* 0.5 pi) (+ (- h0 ha0) 0.2))
       pfcx5 (polar pfcx3 (* 1.5 pi) h0)
       pfcx6 (polar pfcx1 (* 0.5 pi) (+ (- h0 ha0) 0.2))
       pfcx7 (polar pfcx1 (* 1.5 pi) h0)
)
(command "layer" "s" "centerl" "")
(command "line" pfcx1 pfcx2 "" )
(command "line" pfcx4 pfcx5 "" )
(command "line" pfcx6 pfcx7 "" )   
(command "mirror" "w" afee af0 "" pfcx6 pfcx7 "no");现在的问题是镜像只能得出小部分曲线图,而不是整个曲线图,我不知道是不是这样实现不了镜像
(command ^^)

(graphscr)
)

lsjj 发表于 2014-5-5 08:28:20

自己對照一下,小細節不提
主要是最後MIRROR的範圍是一條水平線

zhibeisha 发表于 2014-5-5 17:34:46

搞定   非常感谢!
页: [1]
查看完整版本: 请教一个有关镜像的问题