明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3374|回复: 12

ZZXXQQ帮忙修正ARC部分中的错误, 输出文件改为自动读取路径和可选择输出

  [复制链接]
发表于 2009-5-17 10:40:00 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2009-5-17 11:34:27 编辑

 

(DEFUN C:DAT()
  (setq out(open (strcat (getvar "dwgname")   ".dat" )  "w" ))
  (setq e (entnext))
  (while e
    (setq ed (entget e))
    (setq name (cdr (assoc 0 ed) )  )
    (if (= name "CIRCLE")
            (progn
            (setq cxy (assoc 10 ed))
            (setq cx  (nth 1 cxy))
            (setq cy  (nth 2 cxy))
            (setq r   (assoc 40 ed))
            (setq rr  (cdr r))
            (setq s (strcat "C  " "  =  " (rtos  cx 2 6) " , " (rtos cy 2 6) " , " (rtos rr 2 6) ))
            (write-line s out)
            )
    )
    (if (= name "LINE")
            (progn
            (setq xy1 (assoc 10 ed))
            (setq x1  (nth 1 xy1))
            (setq y1  (nth 2 xy1))
            (setq xy2 (assoc 11 ed))
            (setq x2  (nth 1 xy2))
            (setq y2  (nth 2 xy2))
            (setq s (strcat "L  " "  =  " (rtos  x1 2 6) " , " (rtos y1 2 6) " , " (rtos x2 2 6)" , " (rtos y2 2 6) ))
            (write-line s out)
            )
    )
    (if (= name "ARC")
            (progn
            (setq cxy (assoc 10 ed))
            (setq cx  (nth 1 cxy))
            (setq cy  (nth 2 cxy))
            (setq r   (assoc 40 ed))
            (setq rr  (cdr r))
            (setq sa1  (assoc 50 ed))
            (setq sa  (cdr sa1))
            (setq ea1  (assoc 51 ed))
            (setq ea  (cdr ea1))
            (setq sxy (polar (list cx cy) sa rr))
            (setq sx (nth 0 sxy))
            (setq sy (nth 1 sxy))

            (setq exy (polar (list cx cy) ea rr))
            (setq ex (nth 0 exy))
            (setq ey (nth 1 exy))
            
            (setq s (strcat "A  " "  =  " (rtos  cx 2 6) " , " (rtos cy 2 6) " , " (rtos sx 2 6)" , " (rtos sy 2 6)" , " (rtos ex 2 6)" , " (rtos ey 2 6)  ", N"))
            (write-line s out)
            )
    )

    (setq e (entnext e))
    )   ;END  OF WHILE
  (close out)
  (print)
  )

帮忙修正ARC部分中的错误, 输出文件改为自动读取路径和可选择输出,
(现在的是,全部层的东西都会输出,请帮忙改正,非常感谢!

 楼主| 发表于 2009-5-17 11:51:00 | 显示全部楼层

输出的正确格式如下,谢谢

L  1=   143.87473,   141.20577,   143.87473,   131.87078
L  2=    91.12475,   141.20577,    91.12475,   131.87078
L  3=    34.37476,   141.20577,    34.37476,   131.87078
L  4=   143.87473,   150.54076,   143.87473,   141.20577
L  5=    91.12475,   150.54076,    91.12475,   141.20577
L  6=    34.37476,   150.54076,    34.37476,   141.20577
L  7=    29.87482,    48.76000,    31.12482,    48.76000
L  8=    29.87482,    25.16000,    31.12482,    25.16000
L  9=   110.18481,    48.18160,   111.43481,    48.18160
L 10=   148.37473,    25.16000,   149.62473,    25.16000
L 11=   148.37473,    48.76000,   149.62473,    48.76000
L 12=    12.00000,    15.00000,    20.50000,    15.00000
L 13=    12.00000,    65.00000,    20.50000,    65.00000
L 14=   168.00000,    65.00000,   176.50000,    65.00000
L 15=   168.00000,    22.00000,   176.50000,    22.00000
L 16=   168.00000,   123.18077,   174.00000,   123.18077
L 17=   168.00000,   166.18077,   174.00000,   166.18077
L 18=    12.00000,   166.18077,    18.00000,   166.18077
L 19=    12.00000,   116.18077,    18.00000,   116.18077
L 20=   148.37473,   149.94077,   149.62473,   149.94077
L 21=   148.37473,   126.34077,   149.62473,   126.34077
L 22=   110.18481,   149.36237,   111.43481,   149.36237
L 23=    29.87482,   126.34077,    31.12482,   126.34077
L 24=    29.87482,   149.94077,    31.12482,   149.94077
L 25=     0.00000,   181.18077,   180.00000,   181.18077
L 26=   180.00000,   181.18077,   180.00000,   101.18077
L 27=   180.00000,   101.18077,     0.00000,   101.18077
L 28=     0.00000,   101.18077,     0.00000,   181.18077
L 29=    27.87527,   133.37075,    30.27311,   133.37075
L 30=    30.27311,   133.37075,    30.27311,   131.87078
L 31=    30.27311,   131.87078,    66.07390,   131.87078
L 32=    66.07390,   131.87078,    66.07390,   133.37080
L 33=    66.07390,   133.37080,    68.22469,   133.37080
L 34=    68.42469,   133.17080,    68.42469,   130.07118
L 35=    68.22469,   129.87118,    27.87527,   129.87118
L 36=    27.87527,   129.87118,    27.87527,   133.37075
L 37=    32.37476,   150.54076,    32.37476,   152.49076
L 38=    32.37476,   152.49076,    62.37476,   152.49076
L 39=    62.37476,   152.49076,    62.37476,   150.54076
L 40=    62.37476,   150.54076,    32.37476,   150.54076
L 41=    69.82469,   130.07118,    69.82469,   133.17092
L 42=    70.02471,   133.37092,    72.02310,   133.37075
L 43=    72.02310,   133.37075,    72.02310,   131.87078
L 44=    72.02310,   131.87078,   107.82388,   131.87078
L 45=   107.82388,   131.87078,   107.82388,   133.37080
L 46=   107.82388,   133.37080,   109.97467,   133.37080
L 47=   110.17467,   133.17080,   110.17467,   130.07118
L 48=   109.97467,   129.87118,    70.02469,   129.87118
L 49=    74.12475,   150.54076,    74.12475,   152.49076
L 50=    74.12475,   152.49076,   104.12475,   152.49076
L 51=   104.12475,   152.49076,   104.12475,   150.54076
L 52=   104.12475,   150.54076,    74.12475,   150.54076
L 53=   111.57467,   130.07078,   111.57467,   133.17092
L 54=   111.77469,   133.37092,   113.77308,   133.37075
L 55=   113.77308,   133.37075,   113.77308,   131.87078
L 56=   113.77308,   131.87078,   149.57386,   131.87078
L 57=   149.57386,   131.87078,   149.57386,   133.37080
L 58=   149.57386,   133.37080,   152.12473,   133.37080
L 59=   152.12473,   133.37080,   152.12473,   129.87118
L 60=   152.12473,   129.87118,   152.12473,   129.87078
L 61=   152.12473,   129.87078,   111.77467,   129.87078
L 62=   115.87473,   150.54076,   115.87473,   152.49076
L 63=   115.87473,   152.49076,   145.87473,   152.49076
L 64=   145.87473,   152.49076,   145.87473,   150.54076
L 65=   145.87473,   150.54076,   115.87473,   150.54076
L 66=   130.87473,    29.69021,   130.87473,    30.69001
L 67=    89.12475,    29.69021,    89.12475,    30.69001
L 68=   130.87473,    50.33499,   130.87473,    49.35999
L 69=    89.12475,    50.33499,    89.12475,    49.35999
L 70=    47.37476,    29.69021,    47.37476,    30.69001
L 71=    47.37476,    50.33499,    47.37476,    49.35999
L 72=   115.87473,    49.35999,   115.87473,    51.30999
L 73=   115.87473,    51.30999,   145.87473,    51.30999
L 74=   145.87473,    51.30999,   145.87473,    49.35999
L 75=   145.87473,    49.35999,   115.87473,    49.35999
L 76=   111.57467,    28.89001,   111.57467,    31.99015
L 77=   111.77469,    32.19015,   113.77308,    32.18998
L 78=   113.77308,    32.18998,   113.77308,    30.69001
L 79=   113.77308,    30.69001,   149.57386,    30.69001
L 80=   149.57386,    30.69001,   149.57386,    32.19003
L 81=   149.57386,    32.19003,   152.12473,    32.19003
L 82=   152.12473,    32.19003,   152.12473,    28.69041
L 83=   152.12473,    28.69041,   152.12473,    28.69001
L 84=   152.12473,    28.69001,   111.77467,    28.69001
L 85=    74.12475,    49.35999,    74.12475,    51.30999
L 86=    74.12475,    51.30999,   104.12475,    51.30999
L 87=   104.12475,    51.30999,   104.12475,    49.35999
L 88=   104.12475,    49.35999,    74.12475,    49.35999
L 89=    69.82469,    28.89041,    69.82469,    31.99015
L 90=    70.02471,    32.19015,    72.02310,    32.18998
L 91=    72.02310,    32.18998,    72.02310,    30.69001
L 92=    72.02310,    30.69001,   107.82388,    30.69001
L 93=   107.82388,    30.69001,   107.82388,    32.19003
L 94=   107.82388,    32.19003,   109.97467,    32.19003
L 95=   110.17467,    31.99003,   110.17467,    28.89041
L 96=   109.97467,    28.69041,    70.02469,    28.69041
L 97=    32.37476,    49.35999,    32.37476,    51.30999
L 98=    32.37476,    51.30999,    62.37476,    51.30999
L 99=    62.37476,    51.30999,    62.37476,    49.35999
L100=    62.37476,    49.35999,    32.37476,    49.35999
L101=    27.87527,    32.18998,    30.27311,    32.18998
L102=    30.27311,    32.18998,    30.27311,    30.69001
L103=    30.27311,    30.69001,    66.07390,    30.69001
L104=    66.07390,    30.69001,    66.07390,    32.19003
L105=    66.07390,    32.19003,    68.22469,    32.19003
L106=    68.42469,    31.99003,    68.42469,    28.89041
L107=    68.22469,    28.69041,    27.87527,    28.69041
L108=    27.87527,    28.69041,    27.87527,    32.18998
L109=     0.00000,    80.00000,   180.00000,    80.00000
L110=   180.00000,    80.00000,   180.00000,     0.00000
L111=   180.00000,     0.00000,     0.00000,     0.00000
L112=     0.00000,     0.00000,     0.00000,    80.00000
C  1=    29.87482,   149.94077,     1.25000
C  2=    29.87482,   126.34077,     1.25000
C  3=   110.18481,   149.36237,     1.25000
C  4=   148.37473,   126.34077,     1.25000
C  5=   148.37473,   149.94077,     1.25000
C  6=    12.00000,   116.18077,     6.00000
C  7=    12.00000,   166.18077,     6.00000
C  8=   168.00000,   166.18077,     6.00000
C  9=   168.00000,   123.18077,     6.00000
C 10=   168.00000,    22.00000,     8.50000
C 11=   168.00000,    65.00000,     8.50000
C 12=    12.00000,    65.00000,     8.50000
C 13=    12.00000,    15.00000,     8.50000
C 14=   148.37473,    48.76000,     1.25000
C 15=   148.37473,    25.16000,     1.25000
C 16=   110.18481,    48.18160,     1.25000
C 17=    29.87482,    25.16000,     1.25000
C 18=    29.87482,    48.76000,     1.25000
A  1=    68.22469,   133.17080,    68.22469,   133.37080,    68.42469,   133.17080,S
A  2=    68.22469,   130.07118,    68.42469,   130.07118,    68.22469,   129.87118,S
A  3=    70.02469,   133.17092,    69.82469,   133.17092,    70.02471,   133.37092,S
A  4=   109.97467,   133.17080,   109.97467,   133.37080,   110.17467,   133.17080,S
A  5=   109.97467,   130.07118,   110.17467,   130.07118,   109.97467,   129.87118,S
A  6=    70.02469,   130.07118,    70.02469,   129.87118,    69.82469,   130.07118,S
A  7=   111.77467,   133.17092,   111.57467,   133.17092,   111.77469,   133.37092,S
A  8=   111.77467,   130.07078,   111.77467,   129.87078,   111.57467,   130.07078,S
A  9=   111.77467,    31.99015,   111.57467,    31.99015,   111.77469,    32.19015,S
A 10=   111.77467,    28.89001,   111.77467,    28.69001,   111.57467,    28.89001,S
A 11=    70.02469,    31.99015,    69.82469,    31.99015,    70.02471,    32.19015,S
A 12=   109.97467,    31.99003,   109.97467,    32.19003,   110.17467,    31.99003,S
A 13=   109.97467,    28.89041,   110.17467,    28.89041,   109.97467,    28.69041,S
A 14=    70.02469,    28.89041,    70.02469,    28.69041,    69.82469,    28.89041,S
A 15=    68.22469,    31.99003,    68.22469,    32.19003,    68.42469,    31.99003,S
A 16=    68.22469,    28.89041,    68.42469,    28.89041,    68.22469,    28.69041,S

发表于 2009-5-17 21:12:00 | 显示全部楼层
本帖最后由 作者 于 2009-5-18 12:18:49 编辑

不知道对不对。
游客,本帖隐藏的内容需要发帖数高于 5 才可浏览,你当前发帖数只有 0
 楼主| 发表于 2009-5-18 08:47:00 | 显示全部楼层

ZZXXQQ 你好,

程序我运行了下,不行,出现不能搜索**.dat和出现错误

程序要的是把框选到的圆和圆弧和直线都输出,不是要选择输入输出

请帮忙改正.谢谢!!!!

 楼主| 发表于 2009-5-18 10:41:00 | 显示全部楼层
请查看附件中的文件

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2009-5-18 12:20:00 | 显示全部楼层
3楼改了,再试试。
 楼主| 发表于 2009-5-18 14:32:00 | 显示全部楼层
ZZXXQQ和各位大虾们好
请帮忙修改以下这三个地方就可以了,谢谢
问题0:给输出的坐标编号分类
  1. ;lisp程序
  2. (DEFUN C:DAT()
  3.   (setvar "DIMZIN" 0);设置小数精度(省零,重要)
  4.   (setvar "qaflags" 1)
  5.   (command "explode" "all" "")
  6.   (setq out(open (strcat (getvar "DWGPREFIX") (getvar "dwgname")  ".dat")   "w" ))
  7. [问题一:输出的文件名总有dwg(例:123.dwg.dat 能不能改成输出后是 123.dat) 谢谢]
  8.   (setq e (entnext))
  9.   (while e
  10.     (setq ed (entget e))
  11.     (setq name (cdr (assoc 0 ed) )  )
  12.     (if (= name "CIRCLE")
  13.             (progn
  14.             (setq cxy (assoc 10 ed))
  15.             (setq cx  (nth 1 cxy))
  16.             (setq cy  (nth 2 cxy))
  17.             (setq r   (assoc 40 ed))
  18.             (setq rr  (cdr r))
  19.             (setq s (strcat "C  " "  =  " (rtos  cx 2 5) " , " (rtos cy 2 5) " , " (rtos rr 2 5) ))
  20.             (write-line s out)
  21.             )
  22.     )
  23.     (if (= name "LINE")
  24.             (progn
  25.             (setq xy1 (assoc 10 ed))
  26.             (setq x1  (nth 1 xy1))
  27.             (setq y1  (nth 2 xy1))
  28.             (setq xy2 (assoc 11 ed))
  29.             (setq x2  (nth 1 xy2))
  30.             (setq y2  (nth 2 xy2))
  31.             (setq s (strcat "L  " "  =  " (rtos  x1 2 5) " , " (rtos y1 2 5) " , " (rtos x2 2 5)" , " (rtos y2 2 5) ))
  32.             (write-line s out)
  33.             )
  34.     )
  35.     (if (= name "ARC")
  36. [问题二:圆弧输出反是反方向的,请帮忙改正,谢谢,,,(本是倒的圆角是r0.2 但输出后就变成了 r0.2大半圆,相反方向)]
  37. [请查看我上边发的DWG文件内有标示,谢谢!!!!!!]
  38.             (progn
  39.             (setq cxy (assoc 10 ed))
  40.             (setq cx  (nth 1 cxy))
  41.             (setq cy  (nth 2 cxy))
  42.             (setq r   (assoc 40 ed))
  43.             (setq rr  (cdr r))
  44.             (setq sa1  (assoc 50 ed))
  45.             (setq sa  (cdr sa1))
  46.             (setq ea1  (assoc 51 ed))
  47.             (setq ea  (cdr ea1))
  48.             (setq sxy (polar (list cx cy) sa rr))
  49.             (setq sx (nth 0 sxy))
  50.             (setq sy (nth 1 sxy))
  51.             (setq exy (polar (list cx cy) ea rr))
  52.             (setq ex (nth 0 exy))
  53.             (setq ey (nth 1 exy))
  54.             
  55.             (setq s (strcat "A  " "  =  " (rtos  cx 2 5) " , " (rtos cy 2 5) " , " (rtos sx 2 5)" , " (rtos sy 2 5)" , " (rtos ex 2 5)" , " (rtos ey 2 5)  ", S"))
  56.             (write-line s out)
  57.             )
  58.     )
  59.     (setq e (entnext e))
  60.     )   ;END  OF WHILE
  61.   (close out)
  62.   (print)
  63.   )     ;END OF FUNCTION
 楼主| 发表于 2009-5-23 15:17:00 | 显示全部楼层
现在就差圆弧部分了,请ZZXXQQ和各位帮忙看下
圆弧本来是内圆的,输出后变了外圆
圆弧本来是外圆的,输出后变了内圆
两者刚好相反,请帮忙解决,谢谢...
  1. ;lisp程序
  2. (DEFUN C:DAT()
  3.   (setvar "osmode" 0)
  4.   (setvar "DIMZIN" 0);设置小数精度(省零,重要)
  5.   (setvar "qaflags" 1)
  6.   (command "explode" "all" "") ;炸开输出
  7.   (setq aa (getvar "dwgname") n (strlen aa) aa (substr aa 1 (- n 4)) out (open (strcat "D:\\个人重要资料(勿删)\\Administrator\\桌面\\编程文件\" aa  ".dat" )  "w" ));输出到文件夹
  8.   (setq e (entnext))
  9.   (while e
  10.     (setq ed (entget e))
  11.     (setq name (cdr (assoc 0 ed) )  )
  12.     (if (= name "LINE") ;读线条
  13.             (progn
  14.             (setq xy1 (assoc 10 ed))
  15.             (setq x1  (nth 1 xy1))
  16.             (setq y1  (nth 2 xy1))
  17.             (setq xy2 (assoc 11 ed))
  18.             (setq x2  (nth 1 xy2))
  19.             (setq y2  (nth 2 xy2))
  20.             (setq s (strcat "L  " "  =  " (rtos  x1 2 5) " , " (rtos y1 2 5) " , " (rtos x2 2 5)" , " (rtos y2 2 5) ))
  21.             (write-line s out)
  22.             )
  23.     )
  24.     (if (= name "CIRCLE");读圆形
  25.             (progn
  26.             (setq cxy (assoc 10 ed))
  27.             (setq cx  (nth 1 cxy))
  28.             (setq cy  (nth 2 cxy))
  29.             (setq r   (assoc 40 ed))
  30.             (setq rr  (cdr r))
  31.             (setq s (strcat "C  " "  =  " (rtos  cx 2 5) " , " (rtos cy 2 5) " , " (rtos rr 2 5) ))
  32.             (write-line s out)
  33.             )
  34.     )
  35. ;(Set Arc( "Directionf" 1))
  36.     (if (= name "ARC")
  37.             (progn
  38.             (setq cxy (assoc 10 ed))
  39.             (setq cx  (nth 1 cxy))
  40.             (setq cy  (nth 2 cxy))
  41.             (setq r   (assoc 40 ed))
  42.             (setq rr  (cdr r))
  43.             (setq sa1  (assoc 50 ed))
  44.             (setq sa  (cdr sa1))
  45.             (setq ea1  (assoc 51 ed))
  46.             (setq ea  (cdr ea1))
  47.             (setq sxy (polar (list cx cy) sa rr))
  48.             (setq sx (nth 0 sxy))
  49.             (setq sy (nth 1 sxy))
  50.             (setq exy (polar (list cx cy) ea rr))
  51.             (setq ex (nth 0 exy))
  52.             (setq ey (nth 1 exy))
  53.             
  54.             (setq s (strcat "A  " "  =  " (rtos  cx 2 5) " , " (rtos cy 2 5) " , " (rtos sx 2 5)" , " (rtos sy 2 5)" , " (rtos ex 2 5)" , " (rtos ey 2 5)  ", S"))
  55.             (write-line s out)
  56.             )
  57.     )
  58.     (setq e (entnext e))
  59.     ) ;END  OF WHILE
  60. (setvar "osmode" 703)
  61.   (close out)
  62.   (print)
  63.   )     ;END OF FUNCTION
发表于 2009-5-23 19:47:00 | 显示全部楼层
将圆弧的首未点颠倒一下试试。
 楼主| 发表于 2009-5-24 09:17:00 | 显示全部楼层

谢谢ZZXXQQ帮忙,问题我已经解决了

请教如何编序号?

比如 "A  " "  =  "

在 A 和 = 号之间写入序号 1

以此类推往下排列?

谢谢

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

本版积分规则

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

GMT+8, 2025-2-27 20:09 , Processed in 0.237311 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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