乐筑天下

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

[编程交流] 自动绘制标签距离(&A)

[复制链接]

26

主题

1495

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 15:50:57 | 显示全部楼层
我认为R14中没有任何(vl)函数可用。我认为它们是在A2K中引入的-大卫
回复

使用道具 举报

CAB

29

主题

781

帖子

430

银币

中流砥柱

Rank: 25

铜币
526
发表于 2022-7-6 15:55:18 | 显示全部楼层
谢谢大卫。
 
杰瑞,
如果将其粘贴到R14中的命令行,会发生什么?
  1. (alert (vl-princ-to-string (+ 1 2 3)))
回复

使用道具 举报

CAB

29

主题

781

帖子

430

银币

中流砥柱

Rank: 25

铜币
526
发表于 2022-7-6 15:58:36 | 显示全部楼层
我确实发现:
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 16:01:40 | 显示全部楼层
感谢您的输入CAB,我还没有包括标志插入,我将稍微修改它,以包括总码数也。
 
vl函数在14个版本中不起作用,真丢脸,也许有人可以解决它们?
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 16:05:25 | 显示全部楼层
更新版本:
 
(但同样,使用一些vl函数…)
 
  1. ; Golf by Lee McDonnell  ~  28/12/2008
  2. ; Credit to ASMI for Polyline Vertex Code
  3. (defun c:golf (/ *error* varLst oldVars pl plvert dislist totyrd anglist ptslist lastxt txtval)
  4.    
  5. ;     --- Error Trap ---
  6.    (defun *error* (msg)
  7.    (mapcar 'setvar varLst oldVars)
  8.    (if (= msg "")
  9.        (princ "\nFunction Complete.")
  10.        (princ "\nError or Esc pressed... ")
  11.    ) ;_  end if
  12.    (princ)
  13.    ) ; end of *error*
  14.    (setq varLst  (list "CMDECHO" "CLAYER")
  15.      oldVars (mapcar 'getvar varLst)
  16.    ) ; end setq
  17. ;    --- Error Trap ---
  18.    (or (getenv "GOLF:OFF") (setenv "GOLF:OFF" "125"))
  19.    (or (getenv "GOLF:TEXT") (setenv "GOLF:TEXT" "30.0"))
  20.    (or (getenv "GOLF:LTSCALE") (setenv "GOLF:LTSCALE" "300"))
  21.    (alert (strcat "Type "GOLFSET" to Alter Base Variables \nCurrent Settings: \nText Offset: "
  22.           (getenv "GOLF:OFF")
  23.           "\nText Height: "
  24.           (getenv "GOLF:TEXT")
  25.           "\nLine-Type Scale: "
  26.           (getenv "GOLF:LTSCALE")
  27.       ) ;_  end strcat
  28.    ) ;_  end alert
  29.    (setvar "cmdecho" 0)
  30.    (mapcar 'makelay
  31.        '("DESIGN-PROP-CTR-LINES"
  32.          "DESIGN-PROP-CTR-LINES-POINTS"
  33.          "DESIGN-PROP-CTR-LINES-FLAGS"
  34.          "DESIGN-PROP-CTR-LINES-YARDS"
  35.         )
  36.    ) ;_  end mapcar
  37.    
  38.    (setvar "clayer" "DESIGN-PROP-CTR-LINES")
  39.    (prompt "\nConsruct Polyline: ")
  40.    (command "_pline")
  41.    (while (> (getvar "cmdactive") 0) (command pause))
  42.    (setq pl (entlast))
  43.    (command "_pedit" pl "w" "1.0" "")
  44.    (command "_chprop" pl "" "C" "BYLAYER" "LT" "AG-CENTER" "S" (getenv "GOLF:LTSCALE") "")
  45.    (setq plvert (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 10 (car x))) (entget pl))))
  46.    (Pointer plvert)
  47.    (pdist plvert)
  48.    (setq totyrd (/ (apply '+ dislist) 3))
  49.    (setq dislist (mapcar '(lambda (x) (/ x 3)) dislist))
  50.    (pangs plvert)
  51.    (setq anglist (mapcar '(lambda (x) (+ x (/ pi 2))) anglist))
  52.    (setq ptslist (cdr plvert))
  53.    (if    (= (length anglist) (length ptslist))
  54.    (progn
  55.        (setq xth 0)
  56.        (foreach x anglist
  57.        (setq pt (polar (nth xth ptslist) x (atof (getenv "GOLF:OFF"))))
  58.        (maketext pt (rtos (nth xth dislist) 2 0))
  59.        (command "_chprop" (entlast) "" "C" "BYLAYER" "")
  60.        (setq xth (1+ xth))
  61.        ) ;_  end foreach
  62.    ) ;_  end progn
  63.    ) ;_  end if
  64.    (setq lastxt (entget (entlast)))
  65.    (setq txtval (cdr (assoc 1 lastxt)))
  66.    (setq lastxt (subst (cons 1 (strcat txtval "/" (rtos totyrd 2 0))) (assoc 1 lastxt) lastxt))
  67.    (entmod lastxt)
  68.    (*error* "")
  69.    (princ)
  70. ) ;_  end defun
  71. (defun Pointer (entlist / don)
  72.    (setvar "clayer" "DESIGN-PROP-CTR-LINES-POINTS")
  73.    (foreach coord entlist
  74.    (command "_donut" "0" "20" coord "")
  75.    (setq don (entlast))
  76.    (command "_chprop" don "" "C" "BYLAYER" "")
  77.    ) ;_  end foreach
  78. ) ;_  end defun
  79. (defun makelay (x)
  80.    (if    (not (tblsearch "Layer" x))
  81.    (command "-layer" "m" x "")
  82.    (setvar "clayer" x)
  83.    ) ;_  end if
  84. ) ;_  end defun
  85. (defun pdist (entlist1 / index len dis)
  86.    (setq index    0
  87.      len    (length entlist1)
  88.    ) ;_  end setq
  89.    (while (< index (1- len))
  90.    (setq dis
  91.              (distance    (nth index entlist1)
  92.                (nth (1+ index) entlist1)
  93.              ) ;_  end distance
  94.          dislist (cons dis dislist)
  95.          index   (1+ index)
  96.    ) ;_  end setq
  97.    ) ;_  end while
  98.    (princ)
  99. ) ;_  end defun
  100. (defun maketext    (x y)
  101.    (entmake
  102.    (list '(0 . "TEXT")
  103.          '(8 . "DESIGN-PROP-CTR-LINES-YARDS")
  104.          (cons 10 x)
  105.          (cons 40 (atof (getenv "GOLF:TEXT")))
  106.          (cons 1 y)
  107.          '(50 . 0.0)
  108.          '(7 . "STANDARD")
  109.          '(71 . 0)
  110.          '(72 . 1)
  111.          '(73 . 2)
  112.          (cons 11 x)
  113.    ) ; end list
  114.    ) ; end entmake
  115. ) ;_  end defun
  116. (defun pangs (entlist2 / len1 index1 ang)
  117.    (setq index1 0
  118.      len1     (length entlist2)
  119.    ) ;_  end setq
  120.    (while (< index1 (1- len1))
  121.    (setq ang
  122.              (angle (nth index1 entlist2)
  123.                 (nth (1+ index1) entlist2)
  124.              ) ;_  end distance
  125.          anglist (cons ang anglist)
  126.          index1  (1+ index1)
  127.    ) ;_  end setq
  128.    ) ;_  end while
  129.    (princ)
  130. ) ;_  end defun
  131. (defun c:golfset (/ goff gtxt glt)
  132.    
  133.    (or (getenv "GOLF:OFF") (setenv "GOLF:OFF" "125"))
  134.    (or (getenv "GOLF:TEXT") (setenv "GOLF:TEXT" "30.0"))
  135.    (or (getenv "GOLF:LTSCALE") (setenv "GOLF:LTSCALE" "300"))
  136.    
  137.    (alert (strcat "Current Settings: \nText Offset: "
  138.           (getenv "GOLF:OFF")
  139.           "\nText Size: "
  140.           (getenv "GOLF:TEXT")
  141.           "\nLine-Type Scale: "
  142.           (getenv "GOLF:LTSCALE")
  143.       ) ;_  end strcat
  144.    ) ;_  end alert
  145.    (if    (setq goff (getreal (strcat "\nSpecify Text Offset <"
  146.                    (getenv "GOLF:OFF")
  147.                    "> : "
  148.                ) ;_  end strcat
  149.           ) ;_  end getreal
  150.    ) ;_  end setq
  151.    (setenv "GOLF:OFF" (rtos goff))
  152.    ) ;_  end if
  153.    (if    (setq gtxt (getreal (strcat "\nSpecify Text Height <"
  154.                    (getenv "GOLF:TEXT")
  155.                    "> : "
  156.                ) ;_  end strcat
  157.           ) ;_  end getreal
  158.    ) ;_  end setq
  159.    (setenv "GOLF:TEXT" (rtos gtxt))
  160.    ) ;_  end if
  161.    (if    (setq glt (getreal (strcat "\nSpecify Line-Type Scale <"
  162.                   (getenv "GOLF:LTSCALE")
  163.                   "> : "
  164.               ) ;_  end strcat
  165.          ) ;_  end getreal
  166.    ) ;_  end setq
  167.    (setenv "GOLF:LTSCALE" (rtos glt))
  168.    ) ;_  end if
  169.    (princ "\nBase Variables Set.")
  170.    (princ)
  171. ) ;_  end defun
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 16:09:32 | 显示全部楼层
只需添加标志块,这不会花费太多。
 
我应该为用户创建一个对话框来选择正确的块,还是使用默认的文件路径?
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 16:11:19 | 显示全部楼层
另一个快速更新-抱歉这里的所有帖子伙计们,
 
已更新LISP以指示所有vl命令。
 
  1. ; Golf by Lee McDonnell  ~  28/12/2008
  2. ; Credit to David Bethel for Polyline Vertex Code
  3. (defun c:golf (/ *error* varLst oldVars pl nlist plvert dislist totyrd anglist ptslist lastxt txtval)
  4.    
  5. ;     --- Error Trap ---
  6.    (defun *error* (msg)
  7.    (mapcar 'setvar varLst oldVars)
  8.    (if (= msg "")
  9.        (princ "\nFunction Complete.")
  10.        (princ "\nError or Esc pressed... ")
  11.    ) ;_  end if
  12.    (princ)
  13.    ) ; end of *error*
  14.    (setq varLst  (list "CMDECHO" "CLAYER")
  15.      oldVars (mapcar 'getvar varLst)
  16.    ) ; end setq
  17. ;    --- Error Trap ---
  18.    (or (getenv "GOLF:OFF") (setenv "GOLF:OFF" "125"))
  19.    (or (getenv "GOLF:TEXT") (setenv "GOLF:TEXT" "30.0"))
  20.    (or (getenv "GOLF:LTSCALE") (setenv "GOLF:LTSCALE" "300"))
  21.    (alert (strcat "Type "GOLFSET" to Alter Base Variables \nCurrent Settings: \nText Offset: "
  22.           (getenv "GOLF:OFF")
  23.           "\nText Height: "
  24.           (getenv "GOLF:TEXT")
  25.           "\nLine-Type Scale: "
  26.           (getenv "GOLF:LTSCALE")
  27.       ) ;_  end strcat
  28.    ) ;_  end alert
  29.    (setvar "cmdecho" 0)
  30.    (mapcar 'makelay
  31.        '("DESIGN-PROP-CTR-LINES"
  32.          "DESIGN-PROP-CTR-LINES-POINTS"
  33.          "DESIGN-PROP-CTR-LINES-FLAGS"
  34.          "DESIGN-PROP-CTR-LINES-YARDS"
  35.         )
  36.    ) ;_  end mapcar
  37.    
  38.    (setvar "clayer" "DESIGN-PROP-CTR-LINES")
  39.    (prompt "\nConsruct Polyline: ")
  40.    (command "_pline")
  41.    (while (> (getvar "cmdactive") 0) (command pause))
  42.    (setq pl (entlast))
  43.    (command "_pedit" pl "w" "1.0" "")
  44.    (command "_chprop" pl "" "C" "BYLAYER" "LT" "AG-CENTER" "S" (getenv "GOLF:LTSCALE") "")   
  45.    (setq plvert (massoc 10 (entget pl)))
  46.    (Pointer plvert)
  47.    (pdist plvert)
  48.    (setq totyrd (/ (apply '+ dislist) 3))
  49.    (setq dislist (mapcar '(lambda (x) (/ x 3)) dislist))
  50.    (pangs plvert)
  51.    (setq anglist (mapcar '(lambda (x) (+ x (/ pi 2))) anglist))
  52.    (setq ptslist (cdr plvert))
  53.    (if    (= (length anglist) (length ptslist))
  54.    (progn
  55.        (setq xth 0)
  56.        (foreach x anglist
  57.        (setq pt (polar (nth xth ptslist) x (atof (getenv "GOLF:OFF"))))
  58.        (maketext pt (rtos (nth xth dislist) 2 0))
  59.        (command "_chprop" (entlast) "" "C" "BYLAYER" "")
  60.        (setq xth (1+ xth))
  61.        ) ;_  end foreach
  62.    ) ;_  end progn
  63.    ) ;_  end if
  64.    (setq lastxt (entget (entlast)))
  65.    (setq txtval (cdr (assoc 1 lastxt)))
  66.    (setq lastxt (subst (cons 1 (strcat txtval "/" (rtos totyrd 2 0))) (assoc 1 lastxt) lastxt))
  67.    (entmod lastxt)
  68.    (*error* "")
  69.    (princ)
  70. ) ;_  end defun
  71. (defun Pointer (entlist / don)
  72.    (setvar "clayer" "DESIGN-PROP-CTR-LINES-POINTS")
  73.    (foreach coord entlist
  74.    (command "_donut" "0" "20" coord "")
  75.    (setq don (entlast))
  76.    (command "_chprop" don "" "C" "BYLAYER" "")
  77.    ) ;_  end foreach
  78. ) ;_  end defun
  79. (defun makelay (x)
  80.    (if    (not (tblsearch "Layer" x))
  81.    (command "-layer" "m" x "")
  82.    (setvar "clayer" x)
  83.    ) ;_  end if
  84. ) ;_  end defun
  85. (defun pdist (entlist1 / index len dis)
  86.    (setq index    0
  87.      len    (length entlist1)
  88.    ) ;_  end setq
  89.    (while (< index (1- len))
  90.    (setq dis
  91.              (distance    (nth index entlist1)
  92.                (nth (1+ index) entlist1)
  93.              ) ;_  end distance
  94.          dislist (cons dis dislist)
  95.          index   (1+ index)
  96.    ) ;_  end setq
  97.    ) ;_  end while
  98.    (princ)
  99. ) ;_  end defun
  100. (defun maketext    (x y)
  101.    (entmake
  102.    (list '(0 . "TEXT")
  103.          '(8 . "DESIGN-PROP-CTR-LINES-YARDS")
  104.          (cons 10 x)
  105.          (cons 40 (atof (getenv "GOLF:TEXT")))
  106.          (cons 1 y)
  107.          '(50 . 0.0)
  108.          '(7 . "STANDARD")
  109.          '(71 . 0)
  110.          '(72 . 1)
  111.          '(73 . 2)
  112.          (cons 11 x)
  113.    ) ; end list
  114.    ) ; end entmake
  115. ) ;_  end defun
  116. (defun pangs (entlist2 / len1 index1 ang)
  117.    (setq index1 0
  118.      len1     (length entlist2)
  119.    ) ;_  end setq
  120.    (while (< index1 (1- len1))
  121.    (setq ang
  122.              (angle (nth index1 entlist2)
  123.                 (nth (1+ index1) entlist2)
  124.              ) ;_  end distance
  125.          anglist (cons ang anglist)
  126.          index1  (1+ index1)
  127.    ) ;_  end setq
  128.    ) ;_  end while
  129.    (princ)
  130. ) ;_  end defun
  131. (defun massoc (key alist)
  132.    (foreach x alist
  133.    (if (eq key (car x))
  134.        (setq nlist (cons (cdr x) nlist))
  135.    ) ;_  end if
  136.    ) ;_  end foreach
  137.    (reverse nlist)
  138. ) ;_  end defun
  139. (defun c:golfset (/ goff gtxt glt)
  140.    
  141.    (or (getenv "GOLF:OFF") (setenv "GOLF:OFF" "125"))
  142.    (or (getenv "GOLF:TEXT") (setenv "GOLF:TEXT" "30.0"))
  143.    (or (getenv "GOLF:LTSCALE") (setenv "GOLF:LTSCALE" "300"))
  144.    
  145.    (alert (strcat "Current Settings: \nText Offset: "
  146.           (getenv "GOLF:OFF")
  147.           "\nText Size: "
  148.           (getenv "GOLF:TEXT")
  149.           "\nLine-Type Scale: "
  150.           (getenv "GOLF:LTSCALE")
  151.       ) ;_  end strcat
  152.    ) ;_  end alert
  153.    (if    (setq goff (getreal (strcat "\nSpecify Text Offset <"
  154.                    (getenv "GOLF:OFF")
  155.                    "> : "
  156.                ) ;_  end strcat
  157.           ) ;_  end getreal
  158.    ) ;_  end setq
  159.    (setenv "GOLF:OFF" (rtos goff))
  160.    ) ;_  end if
  161.    (if    (setq gtxt (getreal (strcat "\nSpecify Text Height <"
  162.                    (getenv "GOLF:TEXT")
  163.                    "> : "
  164.                ) ;_  end strcat
  165.           ) ;_  end getreal
  166.    ) ;_  end setq
  167.    (setenv "GOLF:TEXT" (rtos gtxt))
  168.    ) ;_  end if
  169.    (if    (setq glt (getreal (strcat "\nSpecify Line-Type Scale <"
  170.                   (getenv "GOLF:LTSCALE")
  171.                   "> : "
  172.               ) ;_  end strcat
  173.          ) ;_  end getreal
  174.    ) ;_  end setq
  175.    (setenv "GOLF:LTSCALE" (rtos glt))
  176.    ) ;_  end if
  177.    (princ "\nBase Variables Set.")
  178.    (princ)
  179. ) ;_  end defun
回复

使用道具 举报

1

主题

5

帖子

4

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 16:13:51 | 显示全部楼层
Dave,这是粘贴结果。。。当然感谢大家的帮助。。。杰尔
 
命令:(警报(vl princ to string(+1 2 3)))
错误或按Esc*取消*
命令:*取消*
回复

使用道具 举报

1

主题

5

帖子

4

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 16:18:00 | 显示全部楼层
李,
 
真 的!干得好!我真的很感激你所做的一切。它越来越接近我想要它做的事情了。
 
所附文件将向您显示“码数”文本正从绿色“背面”插入T形三通。因此,码数是相反的。我试图自己纠正它,但没有成功。
 
我建议在这个时候对甜甜圈进行“评论”,因为我认为他们不会被需要。
 
正如你所说的,接下来是累计码数和旗杆。我现在没有关于“路径名”标志的答案。稍后我会再打给你。
 
从长远来看,使用R14,您认为在移动中心线夹点时,是否可以使用VBA反应器自动更新“码数文本”?
 
非常感谢您和其他做出贡献的人。
 
杰瑞
布局示例6。图纸
回复

使用道具 举报

CAB

29

主题

781

帖子

430

银币

中流砥柱

Rank: 25

铜币
526
发表于 2022-7-6 16:20:14 | 显示全部楼层
太糟糕了,vl函数不能工作。
 
见附件李的例行程序的修订版本。
我添加了标志,它必须存在于此版本的DWG中。
还去掉了甜甜圈。
 
我会复习你的新图纸。
高尔夫CL李。LSP
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-5-29 00:09 , Processed in 0.793972 second(s), 81 queries .

© 2020-2025 乐筑天下

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