乐筑天下

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

[编程交流] 具有访问权限的活动命令

[复制链接]

15

主题

64

帖子

49

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-5 16:46:00 | 显示全部楼层 |阅读模式
大家好,
 
我正在修改我在网上找到的一个LiSP,我已经能够找出我想要更改的大部分内容。我遇到的一个问题是主动命令。当LiSP调用revcloud命令时,我无法访问revcloud设置。如何修改代码以允许此操作。见图片。如果你看这张照片。png你会看到设置显示不同,我注意到我可以键入a、s或t,我可以更改设置,但它们在正常命令下不会显示。(蓝色字母表示要键入的内容,请参阅pic commandsettings.png)我担心这会让用户感到困惑。
 
任何帮助都将不胜感激。
 
非常感谢。
 
  1. (   (setq *rev*
  2.                (cond
  3.                    (   (= "" (setq rv (getstring t (strcat "\nSpecify Revision Number" (if *rev* (strcat " <" *rev* ">: ") ": ")))))
  4.                        *rev*
  5.                    )
  6.                    (   rv   )
  7.                )
  8.            )                     
  9.            (command "_.revcloud")
  10.            (while (= 1 (logand 1 (getvar 'cmdactive))) (command "\"))
  11.            (setvar 'cmdecho 0)
  12.            (setvar 'attreq  0)
  13.            (setq el (entlast))
  14.            (princ "\nSpecify Insertion Point for Revision Block: ")
  15.            (command "_.-insert" bn "_S" 1.0 "_R" 0.0 "\")
  16.            (if (not (eq el (setq el (entlast))))
  17.                (progn
  18.                    (setq el (entget (entnext el)))
  19.                    (if (entmod (subst (cons 1 *rev*) (assoc 1 el) el))
  20.                        (entupd (cdr (assoc -1 el)))
  21.                    )
  22.                )
  23.            )

174600r3szxeded7djezw2.png
174602ea44i88tlmf9uymt.png
回复

使用道具 举报

20

主题

338

帖子

323

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
100
发表于 2022-7-5 17:08:07 | 显示全部楼层
如果你能够完整地发布你的代码,这会有所帮助。当我测试您列出的内容时,我得到了REVCLOUD的选项。
回复

使用道具 举报

15

主题

64

帖子

49

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-5 17:29:52 | 显示全部楼层
很抱歉,我已经在下面粘贴了完整的代码。请记住,它仍然需要一点清理和TLC。。。
 
  1. (defun c:rv ( / *error* doc layers ent ar bn cm el fn rv )
  2. (vl-load-com)
  3. ;;Set the active document
  4. (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
  5. ;;Set the active layer list
  6. (setq layers (vla-get-layers (vla-get-ActiveDocument(vlax-get-acad-object))))
  7. ;;Get the current layer and store it for reuse
  8. (setq olayer (vlax-variant-value (vla-getvariable (vla-get-activedocument (vlax-get-acad-object)) "clayer")))
  9. ;;Set start of undo mark
  10.    (vla-startundomark doc)
  11. ;;Create the layer for revisions if it does not exist
  12.    (foreach lay '("T-ANNO-REVS-TEXT")
  13.        (   (if (setq ent (tblobjname "layer" lay))
  14.                (lambda ( lst ) (entmod (cons (cons -1 ent) lst)))
  15.                entmake
  16.            )
  17.            (list
  18.               '(000 . "LAYER")
  19.               '(100 . "AcDbSymbolTableRecord")
  20.               '(100 . "AcDbLayerTableRecord")
  21.               '(070 . 0)
  22.               '(062 . 241)
  23.                (cons 002 lay)
  24.            )
  25.        )
  26.    )
  27. (vlax-for l layers
  28. (progn
  29.        
  30.        (member (strcase (vla-get-name l)) '("T-ANNO-REVS-TEXT"))
  31.         (vlax-put-property l 'PlotStyleName "B040(7)")
  32. )
  33. )
  34. ;;set layer to T-ANNO-REVS-TEXT
  35. (setvar "CLAYER" "T-ANNO-REVS-TEXT")
  36. ;;Set the revision cloud attribute block
  37.    (setq bn "revisionblock")
  38.    
  39. ;;Error handling for break, cancel, or exit
  40.    (defun *error* ( msg )
  41.        (if cm (setvar 'cmdecho cm))
  42.        (if ar (setvar 'attreq ar))
  43.        (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
  44.            (princ (strcat "\nError: " msg))
  45.                 (setvar "CLAYER" olayer)
  46.        )
  47.        (princ)
  48.    )
  49.    (setq cm (getvar 'cmdecho)
  50.          ar (getvar 'attreq)
  51.    )
  52.    (cond
  53.        (   (not
  54.                (or (tblsearch "BLOCK" bn)
  55.                    (and
  56.                        (setq fn (findfile (strcat bn ".dwg")))
  57.                        (progn
  58.                            (setvar 'cmdecho 0)
  59.                            (command "_.-insert" fn nil)
  60.                            (setvar 'cmdecho cm)
  61.                            (tblsearch "BLOCK" bn)
  62.                        )
  63.                    )
  64.                )
  65.            )
  66.            (princ (strcat "\n" bn ".dwg not found."))
  67.        )
  68.        (   (zerop (logand 2 (cdr (assoc 70 (tblsearch "BLOCK" bn)))))
  69.            (princ (strcat "\n" bn " not attributed."))
  70.        )
  71.        (   (setq *rev*
  72.                (cond
  73.                    (   (= "" (setq rv (getstring t (strcat "\nSpecify Revision Number" (if *rev* (strcat " <" *rev* ">: ") ": ")))))
  74.                        *rev*
  75.                    )
  76.                    (   rv   )
  77.                )
  78.            )                     
  79.            (command "_.revcloud")
  80.            (while (= 1 (logand 1 (getvar 'cmdactive))) (command "\"))
  81.            (setvar 'cmdecho 0)
  82.            (setvar 'attreq  0)
  83.            (setq el (entlast))
  84.            (princ "\nSpecify Insertion Point for Revision Block: ")
  85.            (command "_.-insert" bn "_S" 1.0 "_R" 0.0 "\")
  86.            (if (not (eq el (setq el (entlast))))
  87.                (progn
  88.                    (setq el (entget (entnext el)))
  89.                    (if (entmod (subst (cons 1 *rev*) (assoc 1 el) el))
  90.                        (entupd (cdr (assoc -1 el)))
  91.                    )
  92.                )
  93.            )
  94.            (setvar 'attreq  ar)
  95.            (setvar 'cmdecho cm)
  96.        )
  97.    )   
  98.    (princ)
  99. ;;Restore old layer
  100. (vla-setvariable (vla-get-activedocument (vlax-get-acad-object)) "clayer" olayer)
  101. ;;Set end of undo mark
  102. (vla-endundomark doc)
  103. )
  104. (princ)
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:44:24 | 显示全部楼层
稍微短一点真的不需要使用vl
 
  1. (setq olayer (vlax-variant-value (vla-getvariable (vla-get-activedocument (vlax-get-acad-object)) "clayer")))
  2. (setq olayer (getvar "clayer"))
  3. (vla-setvariable (vla-get-activedocument (vlax-get-acad-object)) "clayer" olayer)
  4. (setvar "clayer" olayer)
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:54:46 | 显示全部楼层
通过谷歌找到这个
 
  1. So I used:
  2. (command "revcloud" "A" (* 0.3125 (getvar "DIMSCALE")) "")
  3. It's probably a bit messy: I'm not the greatest at LISP. After the user runs this once, the arc length will then scale with the dimscale automatically. The trick is telling the tool that the arc length should always be 0.3125 of the dimscale.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 13:58 , Processed in 0.521680 second(s), 65 queries .

© 2020-2025 乐筑天下

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