乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 81|回复: 19

[编程交流] 查询:站点标签

[复制链接]

4

主题

16

帖子

12

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 11:01:50 | 显示全部楼层 |阅读模式
如果有人能告诉我需要什么代码来增加站点值。
 
附加的lisp引用了早期的线程(http://www.cadtutor.net/forum/showthread.php?t=24278&highlight=chainage)
 
我已附上转换后的lisp文件和我的工作图纸
 
谢谢
回复

使用道具 举报

1

主题

1069

帖子

1050

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
69
发表于 2022-7-6 11:06:01 | 显示全部楼层
 
这是老歌里的我不记得是怎么回事了
我记得它是为一个克罗地亚人写的
 
  1. ;; written by Fatty T.O.H. ()2004 * all rights removed
  2. ;; edited 6/5/10
  3. ;; Stationing
  4. ;;load ActiveX library
  5. (vl-load-com)
  6. ;;local defuns
  7. ;;//
  8. (defun start (curve)
  9. (vl-catch-all-apply (function (lambda()
  10. (vlax-curve-getclosestpointto curve
  11. (vlax-curve-getstartpoint curve
  12.    )
  13. )
  14. )
  15.    )
  16. )
  17. )
  18. ;;//
  19. (defun end (curve)
  20. (vl-catch-all-apply (function (lambda()
  21. (vlax-curve-getclosestpointto curve
  22. (vlax-curve-getendpoint curve
  23.    )
  24. )
  25. )
  26.    )
  27. )
  28. )
  29. ;;//
  30. (defun pointoncurve (curve pt)
  31. (vl-catch-all-apply (function (lambda()
  32. (vlax-curve-getclosestpointto curve
  33. pt
  34.    )
  35. )
  36. )
  37.    )
  38. )
  39. ;;//
  40. (defun paramatpoint (curve pt)
  41. (vl-catch-all-apply (function (lambda()
  42. (vlax-curve-getparamatpoint curve
  43. pt
  44.    )
  45. )
  46. )
  47.    )
  48. )
  49. ;;//
  50. (defun distatpt (curve pt)
  51. (vl-catch-all-apply (function (lambda()
  52. (vlax-curve-getdistatpoint curve
  53.    (vlax-curve-getclosestpointto curve pt)
  54.    )
  55. )
  56.    )
  57.    )
  58. )
  59. ;;//
  60. (defun pointatdist (curve dist)
  61. (vl-catch-all-apply (function (lambda()
  62. (vlax-curve-getclosestpointto curve
  63. (vlax-curve-getpointatdist curve dist)
  64.    )
  65. )
  66. )
  67.    )
  68. )
  69. ;;//
  70. (defun curvelength (curve)
  71. (vl-catch-all-apply (function (lambda()
  72. (vlax-curve-getdistatparam curve
  73. (- (vlax-curve-getendparam curve)
  74.     (vlax-curve-getstartparam curve)
  75.    )
  76. )
  77. )
  78. )
  79.    )
  80. )
  81. ;;//
  82. (defun distatparam (curve param)
  83. (vl-catch-all-apply (function (lambda()
  84. (vlax-curve-getdistatparam curve
  85. param
  86. )
  87. )
  88.    )
  89.    )
  90. )
  91. ;;//
  92. (defun statlabel (num step)
  93. ;; num - integer, zero based
  94. ;; step - double or integer, must be non zero
  95.            (strcat
  96.     (itoa (fix (/ num 2.)) )
  97.     "+"
  98.     (rtos (* (* step 2) (- (/  num 2.) (fix (/ num 2.)))) 2 2)
  99.     )
  100.     )
  101. ;;//
  102. (defun insertstation (acsp bname pt rot tag num step / block)
  103. (vl-catch-all-apply
  104.    (function (lambda()
  105.     (setq block (vlax-invoke-method acsp 'InsertBlock pt bname 1 1 1 rot))
  106. )
  107.       )
  108.    )
  109. (changeatt block tag (statlabel num step))
  110. block
  111. )
  112. ;;//
  113. (defun changeatt (block tag value / att)
  114. (setq atts (vlax-invoke block 'GetAttributes))
  115. (foreach att atts
  116.    (if (equal tag (vla-get-tagstring att))
  117.      (vla-put-textstring att value)
  118.      )
  119.    )
  120.    )
  121. ;;// written by VovKa (Vladimir Kleshev)
  122. (defun gettangent (curve pt)
  123. (setq param (paramatpoint curve pt)
  124.        ang ((lambda (deriv)
  125.     (if (zerop (cadr deriv))
  126.       (/ pi 2)
  127.       (atan (apply '/ deriv))
  128.     )
  129.   )
  130.    (cdr (reverse
  131.    (vlax-curve-getfirstderiv curve param)
  132.         )
  133.    )
  134. )
  135. )
  136. ang
  137. )
  138. ;;//
  139. (defun c:st50 (/ acsp adoc block blkdef cnt en ent label lastp
  140.          leng mul nop num pt rot sign start step)
  141. (setq adoc (vla-get-activedocument (vlax-get-acad-object))
  142.    acsp (vla-get-block (vla-get-activelayout adoc))
  143.     )
  144. (if (not (tblsearch "block" "Station"))
  145.   (progn
  146.     (alert "Block "Station" does not exist. Error...")
  147.     (exit)(princ)
  148.     )
  149.   )
  150. (setq blkdef (vla-item (vla-get-blocks adoc) "Station"))
  151. (setq nop T)
  152. (vlax-for item blkdef
  153.    (if (not (and (eq "AcDbAttributeDefinition" (vla-get-objectname item))
  154.      (eq "NUMBER" (vla-get-tagstring item))))
  155.      (setq nop nil)
  156.      )
  157.    )
  158.   (if nop
  159.   (progn
  160.     (alert "Block "Station" has not attribute "NUMBER". Error...")
  161.     (exit)(princ)
  162.     )
  163.   )
  164. (setq step 50.)
  165. (if
  166. (setq
  167.    ent (entsel
  168.   "\nSelect curve near to the start point >>"
  169. )
  170. )
  171.   (progn
  172.     (setq en (car ent)
  173.    pt (pointoncurve en (cadr ent))
  174.    leng (distatparam en (vlax-curve-getendparam en))
  175.     )
  176.     (setq num (fix (/ leng step))
  177.     )
  178.     (setq mul (- leng (* num step))
  179.     )
  180.     (if (not (zerop mul))
  181.       (setq lastp T)
  182.       (setq lastp nil)
  183.     )
  184.     (if (> (- (paramatpoint en pt)
  185.        (paramatpoint en (vlax-curve-getstartpoint en))
  186.     )
  187.     (- (paramatpoint en (vlax-curve-getendpoint en))
  188.        (paramatpoint en pt)
  189.     )
  190. )
  191.       (progn
  192. (setq start leng
  193.        sign  -1
  194. )
  195. )
  196.       (progn
  197. (setq start (distatparam en (vlax-curve-getstartparam en))
  198.        sign  1
  199. )
  200.       )
  201.     )
  202.     (vla-startundomark
  203.       (vla-get-activedocument (vlax-get-acad-object))
  204.     )
  205.     (setq cnt 0)
  206.     (repeat (1+ num)
  207.       (setq pt  (pointatdist en start)
  208.      rot (gettangent en pt)
  209.       )
  210.      (setq block
  211.      (insertstation acsp "Station"
  212.        (vlax-3d-point pt)
  213.        rot
  214.        "NUMBER" cnt step)
  215.     )
  216.       (setq cnt   (1+ cnt)
  217.      start (+ start (* sign step))
  218.       )
  219.     )
  220. (if lastp
  221.    (progn
  222.    (if (= sign -1)
  223.    (progn
  224.      (setq pt  (vlax-curve-getstartpoint en)
  225.      rot (gettangent en pt)
  226.       )
  227.      )
  228.      (progn
  229.      (setq pt  (vlax-curve-getendpoint en)
  230.      rot (gettangent en pt)
  231.       )
  232.      )
  233.      )
  234.      (setq block
  235.      (insertstation acsp "Station"
  236.        (vlax-3d-point pt)
  237.        rot
  238.        "NUMBER" (1- cnt) 0)
  239.     )
  240.    (setq label (statlabel (1- cnt) 50.)
  241.   label (strcat (substr label 1 (1+ (vl-string-search "+" label)))
  242.   (rtos mul 2 2))
  243.   )
  244.    (changeatt block "NUMBER" label)
  245.    )
  246.    )
  247.     (vla-endundomark
  248.       (vla-get-activedocument (vlax-get-acad-object))
  249.     )
  250.   )
  251.   (princ "\nNothing selected")
  252. )
  253. (princ)
  254. )
  255. (prompt "\n   >>>   Type ST50 to execute...")
  256. (prin1)

 
~'J'~
回复

使用道具 举报

4

主题

16

帖子

12

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 11:10:47 | 显示全部楼层
谢谢你,菲索,很好用。
 
感谢您抽出时间提供帮助。
回复

使用道具 举报

6

主题

249

帖子

247

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-6 11:13:04 | 显示全部楼层
 
这很漂亮。为了使其工作,使用一个名为NUMBER的属性创建一个名为STATION的块
块可以只是一条短垂直线,属性位于垂直线上方,块的插入点可以是短垂直线的底部。将块另存为桩号,并打开短垂直线和名为NUMBER的属性。
干杯
史蒂夫
回复

使用道具 举报

1

主题

1069

帖子

1050

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
69
发表于 2022-7-6 11:16:18 | 显示全部楼层
不客气
 
~'J'~
回复

使用道具 举报

4

主题

16

帖子

12

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 11:19:33 | 显示全部楼层
是否可以预加载块或添加代码来创建块“站”?
回复

使用道具 举报

1

主题

1069

帖子

1050

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
69
发表于 2022-7-6 11:22:14 | 显示全部楼层
 
改为尝试编辑lisp
  1. ;; written by Fatty T.O.H. ()2004 * all rights removed
  2. ;; edited 6/5/10
  3. ;; Stationing
  4. ;;load ActiveX library
  5. (vl-load-com)
  6. ;;local defuns
  7. ;//
  8. (defun makeblock (adoc aprompt atag bname txtheight tstyle / at_obj blk_obj lay line_obj tst)
  9. (if (not (tblsearch "block" bname))
  10. (progn
  11. (setq tst (getvar "textstyle"))
  12. (setvar "textstyle" tstyle)
  13. (setq lay (getvar "clayer"))
  14. (setvar "clayer" "0")
  15. (setq blk_obj (vla-add (vla-get-blocks adoc) (vlax-3d-point '(0. 0. 0.)) bname))
  16. (setq line_obj (vlax-invoke blk_obj 'Addline '(0. 0. 0.) (list 0. 12.0 0.)))
  17. (vla-put-color line_obj acyellow)
  18. (setq at_obj (vla-addattribute blk_obj
  19.   txtheight
  20.   acattributemodeverify
  21.   aprompt
  22.   (vlax-3d-point '(-0.5 1. 0.))
  23.   atag
  24.   "0+0.00")
  25. )
  26. (vla-put-rotation at_obj (/ pi 2))
  27. (vla-put-color at_obj acwhite)
  28. (mapcar (function (lambda(x) vlax-release-object x))
  29.   (list at_obj line_obj blk_obj )
  30.   )
  31. (setvar "clayer" lay)
  32. (setvar "textstyle" tst)
  33. )
  34. )
  35. )
  36. ;;//
  37. (defun start (curve)
  38. (vl-catch-all-apply (function (lambda()
  39. (vlax-curve-getclosestpointto curve
  40. (vlax-curve-getstartpoint curve
  41.    )
  42. )
  43. )
  44.    )
  45. )
  46. )
  47. ;;//
  48. (defun end (curve)
  49. (vl-catch-all-apply (function (lambda()
  50. (vlax-curve-getclosestpointto curve
  51. (vlax-curve-getendpoint curve
  52.    )
  53. )
  54. )
  55.    )
  56. )
  57. )
  58. ;;//
  59. (defun pointoncurve (curve pt)
  60. (vl-catch-all-apply (function (lambda()
  61. (vlax-curve-getclosestpointto curve
  62. pt
  63.    )
  64. )
  65. )
  66.    )
  67. )
  68. ;;//
  69. (defun paramatpoint (curve pt)
  70. (vl-catch-all-apply (function (lambda()
  71. (vlax-curve-getparamatpoint curve
  72. pt
  73.    )
  74. )
  75. )
  76.    )
  77. )
  78. ;;//
  79. (defun distatpt (curve pt)
  80. (vl-catch-all-apply (function (lambda()
  81. (vlax-curve-getdistatpoint curve
  82.    (vlax-curve-getclosestpointto curve pt)
  83.    )
  84. )
  85.    )
  86.    )
  87. )
  88. ;;//
  89. (defun pointatdist (curve dist)
  90. (vl-catch-all-apply (function (lambda()
  91. (vlax-curve-getclosestpointto curve
  92. (vlax-curve-getpointatdist curve dist)
  93.    )
  94. )
  95. )
  96.    )
  97. )
  98. ;;//
  99. (defun curvelength (curve)
  100. (vl-catch-all-apply (function (lambda()
  101. (vlax-curve-getdistatparam curve
  102. (- (vlax-curve-getendparam curve)
  103.     (vlax-curve-getstartparam curve)
  104.    )
  105. )
  106. )
  107. )
  108.    )
  109. )
  110. ;;//
  111. (defun distatparam (curve param)
  112. (vl-catch-all-apply (function (lambda()
  113. (vlax-curve-getdistatparam curve
  114. param
  115. )
  116. )
  117.    )
  118.    )
  119. )
  120. ;;//
  121. (defun statlabel (num step)
  122. ;; num - integer, zero based
  123. ;; step - double or integer, must be non zero
  124.            (strcat
  125.     (itoa (fix (/ num 2.)) )
  126.     "+"
  127.     (rtos (* (* step 2) (- (/  num 2.) (fix (/ num 2.)))) 2 2)
  128.     )
  129.     )
  130. ;;//
  131. (defun insertstation (acsp bname pt rot tag num step / block)
  132. (vl-catch-all-apply
  133.    (function (lambda()
  134.     (setq block (vlax-invoke-method acsp 'InsertBlock pt bname 1 1 1 rot))
  135. )
  136.       )
  137.    )
  138. (changeatt block tag (statlabel num step))
  139. block
  140. )
  141. ;;//
  142. (defun changeatt (block tag value / att)
  143. (setq atts (vlax-invoke block 'GetAttributes))
  144. (foreach att atts
  145.    (if (equal tag (vla-get-tagstring att))
  146.      (vla-put-textstring att value)
  147.      )
  148.    )
  149.    )
  150. ;;// written by VovKa (Vladimir Kleshev)
  151. (defun gettangent (curve pt)
  152. (setq param (paramatpoint curve pt)
  153.        ang ((lambda (deriv)
  154.     (if (zerop (cadr deriv))
  155.       (/ pi 2)
  156.       (atan (apply '/ deriv))
  157.     )
  158.   )
  159.    (cdr (reverse
  160.    (vlax-curve-getfirstderiv curve param)
  161.         )
  162.    )
  163. )
  164. )
  165. ang
  166. )
  167. ;;//
  168. (defun c:st50 (/ acsp adoc block blkdef cnt en ent label lastp
  169.          lay leng mul nop num pt rot sign start step)
  170. (setvar "dimzin" 2)
  171. (setq lay (getvar "clayer"))
  172. (setvar "clayer" "0")
  173. (setq adoc (vla-get-activedocument (vlax-get-acad-object))
  174.    acsp (vla-get-block (vla-get-activelayout adoc))
  175.     )
  176. (if (not (tblsearch "block" "Station"))
  177.   (makeblock adoc "NUMBER" "NUMBER" "Station" 2.0 "Standard")
  178.   )
  179. (setq step 50.)
  180. (if
  181. (setq
  182.    ent (entsel
  183.   "\nSelect curve near to the start point >>"
  184. )
  185. )
  186.   (progn
  187.     (setq en (car ent)
  188.    pt (pointoncurve en (cadr ent))
  189.    leng (distatparam en (vlax-curve-getendparam en))
  190.     )
  191.     (setq num (fix (/ leng step))
  192.     )
  193.     (setq mul (- leng (* num step))
  194.     )
  195.     (if (not (zerop mul))
  196.       (setq lastp T)
  197.       (setq lastp nil)
  198.     )
  199.     (if (> (- (paramatpoint en pt)
  200.        (paramatpoint en (vlax-curve-getstartpoint en))
  201.     )
  202.     (- (paramatpoint en (vlax-curve-getendpoint en))
  203.        (paramatpoint en pt)
  204.     )
  205. )
  206.       (progn
  207. (setq start leng
  208.        sign  -1
  209. )
  210. )
  211.       (progn
  212. (setq start (distatparam en (vlax-curve-getstartparam en))
  213.        sign  1
  214. )
  215.       )
  216.     )
  217.     (vla-startundomark
  218.       (vla-get-activedocument (vlax-get-acad-object))
  219.     )
  220.     (setq cnt 0)
  221.     (repeat (1+ num)
  222.       (setq pt  (pointatdist en start)
  223.      rot (gettangent en pt)
  224.       )
  225.      (setq block
  226.      (insertstation acsp "Station"
  227.        (vlax-3d-point pt)
  228.        rot
  229.        "NUMBER" cnt step)
  230.     )
  231.       (setq cnt   (1+ cnt)
  232.      start (+ start (* sign step))
  233.       )
  234.     )
  235. (if lastp
  236.    (progn
  237.    (if (= sign -1)
  238.    (progn
  239.      (setq pt  (vlax-curve-getstartpoint en)
  240.      rot (gettangent en pt)
  241.       )
  242.      )
  243.      (progn
  244.      (setq pt  (vlax-curve-getendpoint en)
  245.      rot (gettangent en pt)
  246.       )
  247.      )
  248.      )
  249.      (setq block
  250.      (insertstation acsp "Station"
  251.        (vlax-3d-point pt)
  252.        rot
  253.        "NUMBER" (1- cnt) 0)
  254.     )
  255.    (setq label (statlabel (1- cnt) 50.)
  256.   label (strcat (substr label 1 (1+ (vl-string-search "+" label)))
  257.   (rtos mul 2 2))
  258.   )
  259.    (changeatt block "NUMBER" label)
  260.    )
  261.    )
  262.    (setvar "clayer" lay)
  263.     (vla-endundomark
  264.       (vla-get-activedocument (vlax-get-acad-object))
  265.     )
  266.   )
  267.   (princ "\nNothing selected")
  268. )
  269. (princ)
  270. )
  271. (prompt "\n   >>>   Type ST50 to execute...")
  272. (prin1)

 
~'J'~
回复

使用道具 举报

4

主题

16

帖子

12

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 11:26:22 | 显示全部楼层
谢谢fixo-这真的很管用!:眨眼:
回复

使用道具 举报

6

主题

249

帖子

247

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-6 11:28:21 | 显示全部楼层
真的需要把方块翻转180度。
当沿着指定位置的线“行走”时
你得把书倒过来读!!
只有我的意见和2美分
 
当然,人们可以使用第一个版本并制作自己的区块。
S
回复

使用道具 举报

1

主题

1069

帖子

1050

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
69
发表于 2022-7-6 11:31:16 | 显示全部楼层
 
嗨,史蒂夫,我不知道帝国标准
 
你能纠正你说的话吗?
 
~'J'~
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-6 11:23 , Processed in 0.403564 second(s), 72 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表