明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
123
返回列表 发新帖
楼主: hastan

[提问] 點選多段線生成5m或10m dtmpoint點至txt檔

[复制链接]
发表于 2015-10-7 16:43 | 显示全部楼层
hastan 发表于 2015-10-6 22:45
可以告訴我嗎

  1. (or (tblsearch "layer" "TPTEMP")
  2.     (command "layer" "n" "TPTEMP" "")
  3. )
  4. (or (tblsearch "layer" "CONTEMP")
  5.     (command "layer" "n" "CONTEMP" "")
  6. )
  7. (or (tblsearch "layer" "DTM3D")
  8.     (command "layer" "n" "DTM3D" "")
  9. )
  10. (defun c:tt (/ ss dis ps box ss        v pb sss m n p0        pls pts        _pi2 trilst ppt ppl
  11.              ms)
  12.   (if (and (setq dis (getdist "\nDistance of Axis: "))
  13.            (setq ps (ssget "+.:S" '((0 . "*Polyline"))))
  14.            (setq pl (ssname ps 0))
  15.            (setq pls (xlrx-curve-getstretchpoints pl))
  16.            (setq ss (ssget "x" '((0 . "insert") (2 . "99"))))
  17.            (setq sss (XLRX-TriAngle ss ps nil t))
  18.       )
  19.     (progn
  20.       (setq box           (list (apply 'mapcar (cons 'min pls))
  21.                          (apply 'mapcar (cons 'max pls))
  22.                    )
  23.             v           (mapcar 'abs (apply 'mapcar (cons '- box)))
  24.             pb           (mapcar '+ (list (/ dis 2) (/ dis 2) 0.) (car box))
  25.             m           (fix (/ (- (car v) (/ dis 2)) dis))
  26.             n           (fix (/ (- (cadr v) (/ dis 2)) dis))
  27.             p0           pb
  28.             trilst (mapcar 'xlrx-curve-getstretchpoints
  29.                            (xlrx-pickset->list sss)
  30.                    )
  31.             ms           (vla-get-modelspace
  32.                      (vla-get-activedocument (vlax-get-acad-object))
  33.                    )
  34.       )
  35.       (command ".layer" "F" "三角网,99" "")
  36.       (repeat m
  37.         (setq pts (cons (setq p0 (polar p0 0.0 dis)) pts))
  38.       )
  39.       (setq pts         (cons pb (reverse pts))
  40.             _pi2 (/ pi 2)
  41.             ppt         (apply
  42.                    'append
  43.                    (mapcar
  44.                      '(lambda (x / p ptl)
  45.                         (setq p x)
  46.                         (repeat        n
  47.                           (setq ptl (cons (setq p (polar p _pi2 dis)) ptl))
  48.                         )
  49.                         (vl-remove-if
  50.                           '(lambda (a) (not (XLRX-Point-IsInPoly1 a pls)))
  51.                           (cons x (reverse ptl))
  52.                         )
  53.                       )
  54.                      pts
  55.                    )
  56.                  )
  57.       )
  58.       (foreach x trilst
  59.         (if (setq stri
  60.                    (vl-remove-if-not
  61.                      (function
  62.                        (lambda (a)
  63.                          (apply 'xlrx-point-getTriIntersElev (cons a x))
  64.                        )
  65.                      )
  66.                      ppt
  67.                    )
  68.             );_可以再优化算法
  69.           (mapcar (function (lambda (b / pt blk)
  70.                               (setq pt        (apply 'xlrx-point-getTriIntersElev (cons b x))
  71.                                     blk        (vla-insertblock
  72.                                           ms
  73.                                           (vlax-3d-point pt)
  74.                                           "99"
  75.                                           1.
  76.                                           1.
  77.                                           1.
  78.                                           0.
  79.                                         )
  80.                               )
  81.                               (vla-put-layer blk "TPTEMP")
  82.                               (XLRX-Block-SetAtts
  83.                                 (entlast)
  84.                                 "PTELEV"
  85.                                 (rtos (caddr pt) 2 3)
  86.                               )
  87.                               (setq ppt (vl-remove b ppt))
  88.                             )  
  89.                   )
  90.                   stri
  91.           )
  92.         )
  93.       )
  94.       (if ppt
  95.         (foreach x ppt
  96.           (entmake (list '(0 . "point") (cons 10 x) '(62 . 3)))  
  97.         )
  98.       )
  99.     )
  100.   )
  101.   (princ)
  102. )
 楼主| 发表于 2015-10-7 18:54 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-2 20:08 , Processed in 0.468018 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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