找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 668|回复: 5

[试用]:管桩桩位图自动编号程序---希各位高手指教

[复制链接]
发表于 2004-10-7 16:59:18 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

×
(defun c:columnaxis(/ axis axisnum)

(setq axis (ssget '(( 0 . "line") (8 . "axis")))) ;;;拾取轴线:过滤条件--线段、axis图层
(setq axisnum (sslength axis))                    ;;;轴线的数量

(command "layer" "new" "columntext" "")           ;;;新建图层columntext
(command "layer" "color"  "7" "columntext" "")    ;;;设置图层columntext颜色为白色
(command "layer" "set" "columntext" "")           ;;;设置图层columntext为当前层

  (setq nnum 0)
  (setq nnnnum 0)

  (if (= updown nil)                                               ;;;若有轴线为斜线段
                                                                   ;;;求出比值(y2-y1)/(x2-x1)的正负
    (while (and (= updown nil) (< nnnnum (- axisnum 1)))           ;;;
                                                                   ;;;
    (setq Xpot1 (cadr (assoc 10 (entget (ssname axis nnnnum)))))   ;;;提取轴线线段两端点的x、y值
    (setq Ypot1 (caddr (assoc 10 (entget (ssname axis nnnnum)))))  ;;;
    (setq Xpot2 (cadr (assoc 11 (entget (ssname axis nnnnum)))))   ;;;
    (setq Ypot2 (caddr (assoc 11 (entget (ssname axis nnnnum)))))  ;;;
    (if (and (/= Xpot1 Xpot2) (/= Ypot1 Ypot2))                    ;;;
    (setq updown (/(- Xpot2 Xpot1) (- Ypot2 Ypot1)))               ;;;
    )                                                              ;;;
    (setq nnnnum (+ nnnnum 1))                                     ;;;
  )                                                                ;;;
)                                                                  ;;;


(repeat axisnum
   
  (setq ChanceMX 0)
  (setq ChanceMY 0)
  (setq nnum 0)
  (setq nnnnum 0)

  (repeat (sslength axis)
    (setq Xpot1 (cadr (assoc 10 (entget (ssname axis nnnnum)))))   ;;;提取轴线线段两端点的x、y值
    (setq Ypot1 (caddr (assoc 10 (entget (ssname axis nnnnum)))))  ;;;
    (setq Xpot2 (cadr (assoc 11 (entget (ssname axis nnnnum)))))   ;;;
    (setq Ypot2 (caddr (assoc 11 (entget (ssname axis nnnnum)))))  ;;;

    (setq MidXpot (/ (+ Xpot1 Xpot2) 2))    ;;;求出轴线中点的x、y坐标
    (setq MidYpot (/ (+ Ypot1 Ypot2) 2))    ;;;
   
      (if (and (= ChanceMX 0)(= ChanceMY 0))        ;;;第一次时直接将
        (progn                                      ;;;MidXpot赋给ChanceMX
          (setq ChanceMX MidXpot)                   ;;;MidYpot赋给ChanceMY
          (setq ChanceMY MidYpot)                   ;;;
          (setq nnum nnnnum)
        )

        (if (< MidXpot ChanceMX)
          (progn
            (setq ChanceMX MidXpot)                   ;;;MidYpot赋给ChanceMY
            (setq ChanceMY MidYpot)                   ;;;
            (setq nnum nnnnum)
          )
          (if (= ChanceMX MidXpot)
          (if (or (= UpDown nil) (< updown 0))
            (if (< MidYpot ChanceMY)
              (progn                                    ;;;MidXpot赋给ChanceMX
                (setq ChanceMX MidXpot)                   ;;;MidYpot赋给ChanceMY
                (setq ChanceMY MidYpot)                   ;;;
                (setq nnum nnnnum)
              )
            )

            (if (> MidYpot ChanceMY)
              (progn                                    ;;;MidXpot赋给ChanceMX
                (setq ChanceMX MidXpot)                   ;;;MidYpot赋给ChanceMY
                (setq ChanceMY MidYpot)                   ;;;
                (setq nnum nnnnum)
              )
            )
                )

         
          )
        )


      )

      


    (setq nnnnum (+ nnnnum 1))
  )
  (setq Xpot1 (cadr (assoc 10 (entget (ssname axis nnum)))))   ;;;提取轴线线段两端点的x、y值
  (setq Ypot1 (caddr (assoc 10 (entget (ssname axis nnum)))))  ;;;
  (setq Xpot2 (cadr (assoc 11 (entget (ssname axis nnum)))))   ;;;
  (setq Ypot2 (caddr (assoc 11 (entget (ssname axis nnum)))))  ;;;

  (setq MidXpot (/ (+ Xpot1 Xpot2) 2))    ;;;求出轴线中点的x、y坐标
  (print MIDXpot)

  (ssdel (ssname axis nnum) axis)


(if (= Xpot1 Xpot2)                            ;;;轴线是垂直线段时
  (progn                                       ;;;轴线左右偏移1500
    (setq pt1 (list (- Xpot1 1500) Ypot1 0))   ;;;得到矩形区域的四个角点坐标
    (setq pt2 (list (+ Xpot1 1500) Ypot1 0))
    (setq pt3 (list (+ Xpot2 1500) Ypot2 0))
    (setq pt4 (list (- Xpot2 1500) Ypot2 0))
  )
)

(if (and (/= Xpot1 Xpot2) (/= Ypot1 Ypot2))    ;;;轴线是斜线段时
  (progn                                       ;;;轴线左右偏移1500
    (setq columnatan (atan (- ypot2 ypot1) (- xpot2 xpot1)))  ;;;得到矩形区域的四个角点坐标
    (setq xxpt (* 1500 (sin columnatan)))
    (setq yypt (* 1500 (cos columnatan)))

    (setq pt1 (list (+ Xpot1 xxpt) (- Ypot1 yypt) 0))
    (setq pt2 (list (- Xpot1 xxpt) (+ Ypot1 yypt) 0))
    (setq pt3 (list (- Xpot2 xxpt) (+ Ypot2 yypt) 0))
    (setq pt4 (list (+ Xpot2 xxpt) (- Ypot2 yypt) 0))
  )
)

(if (= Ypot1 Ypot2)                            ;;;轴线是水平线段时
  (progn                                       ;;;轴线左右偏移1500
    (setq pt1 (list Xpot1 (- Ypot1 1500) 0))   ;;;得到矩形区域的四个角点坐标
    (setq pt2 (list Xpot1 (+ Ypot1 1500) 0))
    (setq pt3 (list Xpot2 (+ Ypot2 1500) 0))
    (setq pt4 (list Xpot2 (- Ypot2 1500) 0))
  )
)

(setq pt_list (list pt1 pt2 pt3 pt4 ) )
(setq ColumnAll (ssget "CP" pt_list  '((0 . "circle"))  ))



(setq n (sslength ColumnAll))
(if (= temp nil)
(setq nnnum 1))
(setq temp 1)
(setq num 0)

  (repeat n
  (setq num 0)
  (setq nnum 0)
  (setq ChanceXTpot nil)
  (setq ChanceYTpot nil)


  (repeat (sslength ColumnAll)
  (setq ColumnOne (ssname ColumnAll num))
  (setq XTpot (cadr (assoc 10 (entget ColumnOne))))
  (setq YTpot (caddr (assoc 10 (entget ColumnOne))))

     (if (= ChanceYTpot nil)
       (progn
       (setq  nnum num)       
       (setq ChanceXTpot XTpot)
       (setq ChanceYTpot YTpot)
       )
     )

  (if (= xpot1 xpot2)
     (if (> ChanceYTpot YTpot)
       (progn
       (setq  nnum num)       
       (setq ChanceXTpot XTpot)
       (setq ChanceYTpot YTpot)
       )
         (if  (= ChanceYTpot YTpot)
           (if(> ChanceXTpot XTpot)
             (progn
             (setq  nnum num)       
             (setq ChanceXTpot XTpot)
             (setq ChanceYTpot YTpot)
             )
           )
         )
     )
  )


  (if (and (= ypot1 ypot2) (= updown nil))
     (if (< ChanceXTpot XTpot)
       (progn
       (setq  nnum num)       
       (setq ChanceXTpot XTpot)
       (setq ChanceYTpot YTpot)
       )
         (if  (= ChanceXTpot XTpot)
           (if(> ChanceYTpot YTpot)
             (progn
             (setq  nnum num)       
             (setq ChanceXTpot XTpot)
             (setq ChanceYTpot YTpot)
             )
           )
         )
     )
  )



(if (and (= ypot1 ypot2) (< updown 0))
     (if (< ChanceXTpot XTpot)
       (progn
       (setq  nnum num)       
       (setq ChanceXTpot XTpot)
       (setq ChanceYTpot YTpot)
       )
         (if  (= ChanceXTpot XTpot)
           (if(> ChanceYTpot YTpot)
             (progn
             (setq  nnum num)       
             (setq ChanceXTpot XTpot)
             (setq ChanceYTpot YTpot)
             )
           )
         )
     )
  )


  (if (and (= ypot1 ypot2) (> updown 0))
     (if (> ChanceXTpot XTpot)
       (progn
       (setq  nnum num)       
       (setq ChanceXTpot XTpot)
       (setq ChanceYTpot YTpot)
       )
         (if  (= ChanceXTpot XTpot)
           (if(< ChanceYTpot YTpot)
             (progn
             (setq  nnum num)       
             (setq ChanceXTpot XTpot)
             (setq ChanceYTpot YTpot)
             )
           )
         )
     )
  )


(if (and (/= xpot1 xpot2) (/= ypot1 ypot2))
(if (> ChanceYTpot YTpot)
       (progn
       (setq  nnum num)       
       (setq ChanceXTpot XTpot)
       (setq ChanceYTpot YTpot)
       )
         (if  (= ChanceYTpot YTpot)
           (if(> ChanceXTpot XTpot)
             (progn
             (setq  nnum num)       
             (setq ChanceXTpot XTpot)
             (setq ChanceYTpot YTpot)
             )
           )
         )
    )
    )



  
  



    (setq num (+ num 1))
  )
  (entmake '((0 . "TEXT")( 10 0 0 0.0) (40 . 200) (1 . "1") (50 . 0.0)))
  (setq xYTpot (list 10 (+ 250 ChanceXTpot) (+ 250 ChanceYTpot)  0))
  (setq xytext (cons 1 (itoa nnnum)))
  (setq writenum (subst xYTpot (assoc 10 (entget(entlast))) (entget(entlast))))
  (entmod writenum)
  (setq writenum (subst xytext (assoc 1 (entget(entlast))) (entget(entlast))))
  (entmod writenum)
  (ssdel (ssname ColumnAll nnum) ColumnAll)
  (setq nnnum (+ nnnum 1))
  )
  )
)
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2004-10-8 16:44:22 | 显示全部楼层
我只能说你厉害
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-10-9 11:44:07 | 显示全部楼层
还请楼主讲讲怎么用啊

谢谢
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2004-10-10 08:50:03 | 显示全部楼层
装载后,输入columnaxis 选择要编号的桩所在的轴线就行了
说明:1适用于直线轴网、有转角的轴网
         2轴线所有的图层为axis
         3桩的图形属性为circle

思路:1根据选择轴线的坐标确定轴线先后次序
         2选择轴线附近范围内的桩
         3根据桩的坐标确定桩的编号先后次序
         4写入桩的编号

希望各位大虾试用一下,帮助修改完善,有什么问题请告诉我。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-10-10 08:58:59 | 显示全部楼层
在哪编辑这个文件呀大哥
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2004-10-10 09:14:53 | 显示全部楼层
5楼的朋友上一楼copy啦
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-5-26 13:56 , Processed in 0.255548 second(s), 41 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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