乐筑天下

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

[编程交流] 将标记集添加到另一个L

[复制链接]

14

主题

719

帖子

706

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 10:12:16 | 显示全部楼层 |阅读模式
我有这两个口吃,都是李做的,如果我没有错的话,我经常使用并喜欢它们。我正在竭尽全力让更多的大学使用它们,因为它们是如此节省时间!因为它们写得很好,所以即使是在大厅对面的近退休女士也可以使用它们并理解它们。
 
你知道我在拍马屁吗?我知道
 
TG lisp(用引线将定位号放置在圆中)有一个标记集命令,用于设置文字高度和圆半径。CR lisp(在图形中放置坐标)没有标记集,如果有,那将非常棒*闪烁闪烁*当然CR不需要圆半径。。。
 
我听见你叹口气说:“可是老虎,你为什么不自己动手?”嗯,有两个原因,今天是星期五,我很快就要回家庆祝了(说来话长,但警察撤销了指控,哇!)我知道这里有人可以做得比我好得多*
 
  1. ;    .: Nozzle & Equipment Tags :.
  2. ;
  3. ;        .: by Lee McDonnell :.
  4. (defun c:tg  (/ olderr *error* varLst oldVars tagpt tagline linent linest linend tagang tcirc tcirccent t1)
  5. (or (getenv "tag:tsize") (setenv "tag:tsize" (rtos (getvar "TEXTSIZE"))))
  6. (or (getenv "tag:tcircr") (setenv "tag:tcircr" "4.2"))
  7. (princ
  8.    (strcat "\nType "TAGSET" to Change Base Variables  --  Current Settings:"
  9.        "\n\tText Height: "
  10.        (getenv "tag:tsize")
  11.        ",\tText Circle Radius: "
  12.        (getenv "tag:tcircr")))
  13. ;     --- Error Trap ---
  14. (setq    olderr    *error* *error*    errtrap)
  15. (defun errtrap  (msg)
  16.    (mapcar 'setvar varLst oldVars)
  17.    (setq *error* olderr)
  18.    (if    (= msg "")
  19.      (princ "\nFunction Complete.")
  20.      (princ "\nError or Esc pressed... "))
  21.    (princ))
  22. (setq    varLst    (list "CMDECHO" "CLAYER")
  23.    oldVars    (mapcar 'getvar varLst))
  24. ;    --- Error Trap ---
  25. (setvar "cmdecho" 0)
  26. (if (not (tblsearch "LAYER" "TAGLINE"))
  27.    (command "-layer" "m" "TAGLINE" "c" "5" "TAGLINE" ""))
  28. (if (not (tblsearch "LAYER" "TEXT"))
  29.    (command "-layer" "m" "TEXT" "c" "2" "TEXT" ""))
  30. (while
  31.    (/= (setq tagpt (getpoint "\nSelect First Tag Point: ")) nil)
  32.     (setvar "clayer" "TAGLINE")
  33.     (prompt "\nSpecify Second Point... ")
  34.     (command "_line" tagpt pause "")
  35.     (setq tagline (entlast)
  36.       linent  (entget tagline)
  37.       linest  (cdr (assoc 10 linent))
  38.       linend  (cdr (assoc 11 linent))
  39.       tagang  (angle linest linend)
  40.       tcirc   (atof (getenv "tag:tcircr")))
  41.     (setvar "clayer" "TEXT")
  42.     (setq tcirccent (polar linend tagang tcirc))
  43.     (command "_circle" "_non" tcirccent tcirc)
  44.     (command "-mtext" tcirccent "H" (getenv "tag:tsize") "J" "MC" "@8.4,0" "")
  45.     (command "_ddedit" (setq t1 (entlast)) "")
  46.     (entmod (subst (cons 10 tcirccent) (assoc 10 (entget t1)) (entget t1))))
  47. (*error* "")
  48. (princ))
  49. ; Base Variables
  50. (defun c:tagset     (/ tsize tcircr)
  51. (or (getenv "tag:tsize") (setenv "tag:tsize" (rtos (getvar "TEXTSIZE"))))
  52. (or (getenv "tag:tcircr") (setenv "tag:tcircr" "4.2"))
  53. (princ
  54.    (strcat "\nCurrent Settings:"
  55.        "\n\tText Height: "
  56.        (getenv "tag:tsize")
  57.        ",\tText Circle Radius @ 1:1: "
  58.        (getenv "tag:tcircr")))
  59. (if (setq tsize (getreal (strcat "\nSpecify Text Height <" (getenv "tag:tsize") ">: ")))
  60.    (setenv "tag:tsize" (rtos tsize)))
  61. (if (setq tcircr (getreal (strcat "\nSpecify Text Circle Radius <" (getenv "tag:tcircr") ">: ")))
  62.    (setenv "tag:tcircr" (rtos tcircr)))
  63. (princ "\nBase Variables Set.")
  64. (princ))
  1. (defun c:cr (/ *error* doc lFac tSze tLay tSty vl ov pt t1 t2)
  2. (vl-load-com)
  3. (setq doc (vla-get-ActiveDocument
  4.              (vlax-get-acad-object)))
  5. (defun *error* (msg)
  6.    (if doc (vla-EndUndoMark doc))
  7.    (if ov (mapcar 'setvar vl ov))
  8.    (if (not
  9.          (wcmatch
  10.            (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
  11.      (princ (strcat "\n** Error: " msg " **")))
  12.    (princ))
  13. (setq
  14.    lFac 1.5    ;; <<-- Line Spacing Factor
  15.    tSze 500    ;; <<-- TextSize (nil to use TEXTSIZE sys var)
  16.    tLay nil ;; <<-- Text Layer (nil to use CLAYER sys var)
  17.    tSty nil    ;; <<-- Text Style (nil to use TEXTSTYLE sys var)
  18. )
  19. (setq vl '("CMDECHO" "OSMODE")
  20.        ov (mapcar 'getvar vl))
  21. (setvar "CMDECHO" 0)
  22. (setvar "LUPREC" 3)
  23. ;;<<--  Error Checking  -->>
  24. (cond ((not (and (numberp lFac) (< 0 lFac)))
  25.         (princ "\n** Line Spacing not Valid **"))
  26.        ((and tLay (not (eq 'STR (type tLay))))
  27.         (princ "\n** Layer not a String **"))
  28.        (t
  29.         (or tSze (setq tSze (getvar "TEXTSIZE")))
  30.         (or tLay (setq tLay (getvar "CLAYER")))
  31.         (or tSty (setq tSty (getvar "TEXTSTYLE")))
  32.         (and tLay (not (tblsearch "LAYER" tLay))
  33.              (vla-add
  34.                (vla-get-layers doc) tLay))
  35. ;; <<---------------------->>
  36.         ;; <<-- Business End  -->>
  37.         
  38.         (while (setq pt (getpoint "\n Välj Punkt - <RETURN> för att avsluta :"))
  39.           (vla-StartUndoMark doc)
  40.           (setvar "OSMODE" 0)
  41.           (setq pt (trans pt 1 0))
  42.          
  43.           (command "_.point" pt)   ;; << Comment this if unnecessary
  44.           (setq t1
  45.             (Make_Text pt
  46.               (strcat "Y: " (rtos (/ (car pt) 1000.)))
  47.               0.  ;; Text is at 0 deg.
  48.               tSze tLay tSty))
  49.           (setq t2
  50.             (Make_Text (polar pt (/ (* 3 pi) 2.) (* lFac tSze))
  51.               (strcat "X: " (rtos (/ (cadr pt) 1000.)))
  52.               0.
  53.               tSze tLay tSty))
  54.           (setvar "OSMODE" (cadr ov))
  55.           (command "_.move" t1 t2 "" pt pause)
  56.           (vla-EndUndoMark doc))
  57.         ;; <<------------------>>
  58.         ))
  59. (mapcar 'setvar vl ov)
  60. (princ))
  61. ;; <<--  Sub-Function  -->>
  62. (defun Make_Text  (pt val rot sZe lay sty)
  63. (entmakex
  64.    (list
  65.      (cons 0 "TEXT")
  66.      (cons 8  lay)
  67.      (cons 10 pt)
  68.      (cons 40 sZe)
  69.      (cons 1  val)
  70.      (cons 50 rot)
  71.      (cons 7  sty)
  72.      (cons 71 0)
  73.      (cons 72 0)  ;; 0 = Left, 1 = Center, 2 = Right
  74.      (cons 73 1)  ;; 0 = Base, 1 = Bottom, 2 = Middle, 3 = Top
  75.      (cons 11 pt))))
因为这是setenv将值保存到的位置。
 
现在,我假设现在的注册表足够大,几个额外的键可以忽略不计,但同样的,当程序停止使用时,键仍然存在,除非用户知道通过注册表深入到上面的位置来删除它。。。然而,一个小的文本/cfg文件更容易处理。
 
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:18:59 | 显示全部楼层
谢谢你的澄清,李。
 
它仍然没有计算(还没有),但我会做一些阅读,Googl'ing,并重新访问这一点,一旦我得到这个提交了大门。
 
干杯
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 10:28:32 | 显示全部楼层
 
不客气
 
在本例中,我只使用了setenv/getenv函数-我认为这些函数比vl registry write更简单,因为它们只写入注册表中的一个位置-我认为最好的学习方法是尝试,但要小心干预注册表-也就是说,不要像大多数人一样害怕注册表——除非你是一个彻头彻尾的傻瓜,在不知道键做什么的情况下删除/修改键,否则它并没有那么危险。
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:35:35 | 显示全部楼层
... 我可能有点“神经质”。
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 10:45:29 | 显示全部楼层
 
莫哈哈-他们总会回来缠着你的,你知道的
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:48:55 | 显示全部楼层
顺便说一句,我不久前写的Tiger可能有用:
 
  1. (strcat "HKEY_CURRENT_USER\" (vlax-product-key) "\\FixedProfile\\General"
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 10:53:42 | 显示全部楼层
谢谢李,我喜欢在你之前的lisp中手动输入数字(有时需要在数字套装中打断),所以我坚持使用这个方法:wink:
回复

使用道具 举报

14

主题

719

帖子

706

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 11:00:13 | 显示全部楼层
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:11:07 | 显示全部楼层
BTW Tiger, I wrote this a while back, may be of use:
 
  1. ;;------------------------=={ Tag }==-------------------------;;;;                                                            ;;;;  Prompts the user for a tag prefix and starting tag number ;;;;  then proceeds to add tag blocks with incrementing tag     ;;;;  attribute until the user fails to pick a tag point.       ;;;;                                                            ;;;;  Tag block is created if non-existent. Tag Block layers    ;;;;  are created if non-existent.                              ;;;;------------------------------------------------------------;;;;  Author: Lee McDonnell, 2010                               ;;;;                                                            ;;;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;;;------------------------------------------------------------;;(defun c:tag ( / *error* ATT BL BLK BNME DEF DOC P1 P2 PR SCL SPC ) (vl-load-com) ;; © Lee Mac 2010 (setq bNme "TAG" scl (cond ( (zerop (getvar 'DIMSCALE)) 1. ) ( (getvar 'DIMSCALE) ))) (defun *error* ( msg )   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")       (princ (strcat "\n** Error: " msg " **")))   (princ) )  (LM:ActiveSpace 'doc 'spc)   (if (not (LM:Itemp (setq blk (vla-get-Blocks doc)) bNme))   (progn     (setq def (vla-Add blk (vlax-3D-point '(0. 0. 0.)) bNme))          (vla-put-layer (vla-AddCircle def (vlax-3D-point '(0. 0. 0.)) 5.) "0")          (setq att (vla-AddAttribute def 2.5 0 "Tag Number: " (vlax-3D-point '(0. 0. 0.)) "TNO" "N1"))     (vla-put-layer att "0")     (vla-put-Alignment att acAlignmentMiddleCenter)   ) ) (foreach l '("2" "5") (or (tblsearch "LAYER" l) (vla-Add (vla-get-layers doc) l))) (setq pr (getstring t "\nSpecify Tag Prefix: ")) (setq *tag*   (cond     (       (getint         (strcat "\nSpecify Tag Number  : "         )       )     )     ( *tag* )   ) ) (while (and (setq p1 (getpoint "\nSpecify First Point  : "))             (setq p2 (getpoint (strcat "\nSpecify Point for Tag (" pr (itoa *tag*) ")  : ") p1)))   (vla-put-Layer     (vla-AddLine spc       (vlax-3D-point (trans p1 1 0))       (vlax-3D-point (trans (polar p2 (angle p2 p1) (* 5.0 scl)) 1 0))     )     "5"   )      (setq bl (vla-InsertBlock spc (vlax-3D-point (trans p2 1 0)) bNme scl scl scl 0.))   (vla-put-layer bl "2")      (mapcar     (function       (lambda ( att )         (if (eq "TNO" (vla-get-TagString att))           (vla-put-TextString att (strcat pr (itoa *tag*)))         )       )     )     (vlax-invoke bl 'GetAttributes)   )   (setq *tag* (1+ *tag*)) ) (princ));;-----------------------=={ Itemp }==------------------------;;;;                                                            ;;;;  Retrieves the item with index 'item' if present in the    ;;;;  specified collection, else nil                            ;;;;------------------------------------------------------------;;;;  Author: Lee McDonnell, 2010                               ;;;;                                                            ;;;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;;;------------------------------------------------------------;;;;  Arguments:                                                ;;;;  coll - the VLA Collection Object                          ;;;;  item - the index of the item to be retrieved              ;;;;------------------------------------------------------------;;;;  Returns:  the VLA Object at the specified index, else nil ;;;;------------------------------------------------------------;;(defun LM:Itemp ( coll item ) ;; © Lee Mac 2010 (if   (not     (vl-catch-all-error-p       (setq item         (vl-catch-all-apply           (function vla-item) (list coll item)         )       )     )   )   item ));;--------------------=={ ActiveSpace }==---------------------;;;;                                                            ;;;;  Retrieves pointers to the Active Document and Space       ;;;;------------------------------------------------------------;;;;  Author: Lee McDonnell, 2010                               ;;;;                                                            ;;;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;;;------------------------------------------------------------;;;;  Arguments:                                                ;;;;  *doc - quoted symbol other than *doc                      ;;;;  *spc - quoted symbol other than *spc                      ;;;;------------------------------------------------------------;;(defun LM:ActiveSpace ( *doc *spc ) ;; © Lee Mac 2010 (set *spc   (if     (or       (eq AcModelSpace         (vla-get-ActiveSpace           (set *doc             (vla-get-ActiveDocument               (vlax-get-acad-object)             )           )         )       )       (eq :vlax-true (vla-get-MSpace (eval *doc)))     )     (vla-get-ModelSpace (eval *doc))     (vla-get-PaperSpace (eval *doc))   ) ))
回复

使用道具 举报

14

主题

719

帖子

706

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 11:15:55 | 显示全部楼层
Thanks Lee, I like that I can enter the number by hand (need to make breaks in the numbering suit sometimes) in your previous lisp so I stick with that one though :wink:
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-5 21:22 , Processed in 1.050239 second(s), 72 queries .

© 2020-2025 乐筑天下

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