乐筑天下

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

[编程交流] Lisp填写自定义正确

[复制链接]

11

主题

44

帖子

33

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
55
发表于 2022-7-5 23:35:01 | 显示全部楼层 |阅读模式
大家好,
 
我正在努力建立一个lisp,用户可以编辑标题栏,更新revblocks。我们有使用图形属性框上的“自定义”选项卡的模板,该选项卡与我们使用的标题栏相关联。我只是想让用户可以使用这个lisp,而不是每次打开dwgprops框。
 
以下是dwgprops框的外观:
 
003504ysy5yvcfsgsx9gyf.png
 
这是我目前得到的:
 
  1. (defun c:TB ()
  2. (if (setq Opt
  3.      (getint
  4.        "\nDo you want to: 1- Update Titleblock 2- Update RevBlock 3- Update Drawing Titles: "
  5.      )
  6.      );;user input for variable "opt"
  7.    (progn
  8.      (cond
  9. ((= opt 1);;if user picks to update titleblock
  10. (setq titletop (getstring "\nWhat is title top? "))
  11. (setq titlemiddle (getstring "\nWhat is title middle? "))
  12. (setq titlebottom (getstring "\nWhat is title bottom? "))
  13. )
  14. ((= opt 2);;if user picks to update revblock
  15. (setq
  16.    row (getint "\nWhich revision row do you wish to edit? ")
  17. )
  18. (progn
  19.    (cond
  20.      ((= row 1)
  21.       (setq 1rowrev (getstring "\n1st row rev: "))
  22.       (setq 1rowyy (getstring "\n1st row year: "))
  23.       (setq 1rowmm (getstring "\n1st row month: "))
  24.       (setq 1rowdd (getstring "\n1st row day: "))
  25.       (setq 1rdesc (getstring T "\n1st row description: "))
  26.       (setq 1rowby (getstring "\n1st row by: "))
  27.       (setq 1rowchk (getstring "\n1st row chk: "))
  28.       (setq 1roweng (getstring "\n1st row eng: "))
  29.       (setq 1rowapp (getstring "\n1st row app: "))
  30.      )
  31.      ((= row 2)
  32.       (setq 2rowrev (getstring "\n2nd row rev: "))
  33.       (setq 2rowyy (getstring "\n2nd row year: "))
  34.       (setq 2rowmm (getstring "\n2nd row month: "))
  35.       (setq 2rowdd (getstring "\n2nd row day: "))
  36.       (setq 2rdesc (getstring T "\n2nd row description: "))
  37.       (setq 2rowby (getstring "\n2nd row by: "))
  38.       (setq 2rowchk (getstring "\n2nd row chk: "))
  39.       (setq 2roweng (getstring "\n2nd row eng: "))
  40.       (setq 2rowapp (getstring "\n2nd row app: "))
  41.      )
  42.      ((= row 3)
  43.       (setq 3rowrev (getstring "\n3rd row rev: "))
  44.       (setq 3rowyy (getstring "\n3rd row year: "))
  45.       (setq 3rowmm (getstring "\n3rd row month: "))
  46.       (setq 3rowdd (getstring "\n3rd row day: "))
  47.       (setq 3rdesc (getstring T "\n3rd row description: "))
  48.       (setq 3rowby (getstring "\n3rd row by: "))
  49.       (setq 3rowchk (getstring "\n3rd row chk: "))
  50.       (setq 3roweng (getstring "\n3rd row eng: "))
  51.       (setq 3rowapp (getstring "\n3rd row app: "))
  52.      )
  53.      ((= row 4)
  54.       (setq 4rowrev (getstring "\n4th row rev: "))
  55.       (setq 4rowyy (getstring "\n4th row year: "))
  56.       (setq 4rowmm (getstring "\n4th row month: "))
  57.       (setq 4rowdd (getstring "\n4th row day: "))
  58.       (setq 4rdesc (getstring T "\n4th row description: "))
  59.       (setq 4rowby (getstring "\n4th row by: "))
  60.       (setq 4rowchk (getstring "\n4th row chk: "))
  61.       (setq 4roweng (getstring "\n4th row eng: "))
  62.       (setq 4rowapp (getstring "\n4th row app: "))
  63.      )
  64.    );;end cond
  65. );; end progn
  66. );;end opt 2
  67. ((= opt 3);;if user picks to update drawing titles, still figuring this section out
  68. )
  69.      );;end cond
  70.    );;end 1st progn
  71. );;end 1st if
  72. );;end defun

 
我最难弄清楚的是如何将用户输入的值放入正确的自定义图形属性中,这只适用于revbock更新。
 
我也不知道如何将标题用户输入放入正确的图形属性位置(尽管我认为它们密切相关)
 
我确实发现这个列表可能对狩猎有帮助,但我不知道如何把它翻译成有用的东西。。。
 
 
谢谢你的帮助!
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 23:40:28 | 显示全部楼层
使用从文档对象派生的ActiveX SummaryInfo对象的属性和方法:
这里有一个参考:SummaryInfo对象
回复

使用道具 举报

11

主题

44

帖子

33

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
55
发表于 2022-7-5 23:49:46 | 显示全部楼层
 
谢谢李。
 
我对ActiveX没有任何经验,但这是我在黑暗中拍摄的一张照片。
 
  1. (defun c:TB ()
  2. (if (setq Opt
  3.      (getint
  4.        "\nDo you want to: 1- Update Titleblock 2- Update RevBlock 3- Update Drawing Titles: "
  5.      )
  6.      );;user input for variable "opt"
  7.    (progn
  8.      (cond
  9. ((= opt 1);;if user picks to update titleblock
  10. (setq titletop (getstring "\nWhat is title top? "))
  11. (setq titlemiddle (getstring "\nWhat is title middle? "))
  12. (setq titlebottom (getstring "\nWhat is title bottom? "))
  13. )
  14. ((= opt 2);;if user picks to update revblock
  15. (setq
  16.    row (getint "\nWhich revision row do you wish to edit? ")
  17. )
  18. (progn
  19.    (cond
  20.      ((= row 1)
  21.       (setq 1rowrev (getstring "\n1st row rev: "))
  22.       (setq 1rowyy (getstring "\n1st row year: "))
  23.       (setq 1rowmm (getstring "\n1st row month: "))
  24.       (setq 1rowdd (getstring "\n1st row day: "))
  25.       (setq 1rdesc (getstring T "\n1st row description: "))
  26.       (setq 1rowby (getstring "\n1st row by: "))
  27.       (setq 1rowchk (getstring "\n1st row chk: "))
  28.       (setq 1roweng (getstring "\n1st row eng: "))
  29.       (setq 1rowapp (getstring "\n1st row app: "))
  30.       (vla-get-summaryinfo (vla-get-activedocument (vlax-get-acad-object.addcustominfo(1rrev, 1rowrev))))
  31.       )
  32.      ((= row 2)
  33.       (setq 2rowrev (getstring "\n2nd row rev: "))
  34.       (setq 2rowyy (getstring "\n2nd row year: "))
  35.       (setq 2rowmm (getstring "\n2nd row month: "))
  36.       (setq 2rowdd (getstring "\n2nd row day: "))
  37.       (setq 2rdesc (getstring T "\n2nd row description: "))
  38.       (setq 2rowby (getstring "\n2nd row by: "))
  39.       (setq 2rowchk (getstring "\n2nd row chk: "))
  40.       (setq 2roweng (getstring "\n2nd row eng: "))
  41.       (setq 2rowapp (getstring "\n2nd row app: "))
  42.      )
  43.      ((= row 3)
  44.       (setq 3rowrev (getstring "\n3rd row rev: "))
  45.       (setq 3rowyy (getstring "\n3rd row year: "))
  46.       (setq 3rowmm (getstring "\n3rd row month: "))
  47.       (setq 3rowdd (getstring "\n3rd row day: "))
  48.       (setq 3rdesc (getstring T "\n3rd row description: "))
  49.       (setq 3rowby (getstring "\n3rd row by: "))
  50.       (setq 3rowchk (getstring "\n3rd row chk: "))
  51.       (setq 3roweng (getstring "\n3rd row eng: "))
  52.       (setq 3rowapp (getstring "\n3rd row app: "))
  53.      )
  54.      ((= row 4)
  55.       (setq 4rowrev (getstring "\n4th row rev: "))
  56.       (setq 4rowyy (getstring "\n4th row year: "))
  57.       (setq 4rowmm (getstring "\n4th row month: "))
  58.       (setq 4rowdd (getstring "\n4th row day: "))
  59.       (setq 4rdesc (getstring T "\n4th row description: "))
  60.       (setq 4rowby (getstring "\n4th row by: "))
  61.       (setq 4rowchk (getstring "\n4th row chk: "))
  62.       (setq 4roweng (getstring "\n4th row eng: "))
  63.       (setq 4rowapp (getstring "\n4th row app: "))
  64.      )
  65.    );;end cond
  66. );; end progn
  67. );;end opt 2
  68. ((= opt 3);;if user picks to update drawing titles, still figuring this section out
  69. )
  70.      );;end cond
  71.    );;end 1st progn
  72. );;end 1st if
  73. );;end defun

 
我只是在第1行rev中试用了一下,看看它是否能正常工作,然后再尝试全面实施
 
这是我得到的错误;错误:无函数定义:1RREV,
 
你能指出的任何参考资料都能帮助我吗?
 
再次感谢。
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 23:51:13 | 显示全部楼层
仅仅阅读post和我可能是错误的,但可能是基于使用带属性的普通块的注释,对每个变量进行回答似乎很困难,并且作为一种逐行输入类型过于致命。
 
1更新标题栏,仅更改所有标题上要更改的标题的一些预定义行,请参见下面的7
 
2更新版本只需转到布局“更新版本”自动知道块名称,因此搜索下一个可用的空行,然后提示用户输入
 
3更新标题是一种情况,如果你拼写了一个错误的名称或新公司,那么为什么不只是说“输入要更新的行号”“输入信息”,然后在所有块中替换,根据需要重复。
 
4我认为可以选择一个块并返回在块中选择的属性,然后说将所有标题块更新为新值
 
5您可以设置要更新的布局的限制。
 
6可以使用excell链接创建布局/标题栏详细信息。通过这种方式,您可以使用复制和粘贴。电子表格仅适用于您的标题栏,而不适用于任何项目。
 
7我有一个大项目,它会自动更新标题栏中的大约20个项目,这些项目是预定义的,并从dwg中读取其他信息。
回复

使用道具 举报

11

主题

44

帖子

33

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
55
发表于 2022-7-5 23:59:16 | 显示全部楼层
 
有机会再次尝试。。。仍然出现错误。代码见下文。
 
  1. (defun c:TB ()
  2. (vl-load-com)
  3. (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
  4. (setq db (vla-get-Database doc))
  5. (setq si (vla-get-SummaryInfo db))
  6. (if (setq Opt
  7.      (getint
  8.        "\nDo you want to: 1- Update Titleblock 2- Update RevBlock 3- Update Drawing Titles: "
  9.      )
  10.      );;user input for variable "opt"
  11.    (progn
  12.      (cond
  13. ((= opt 1);;if user picks to update titleblock
  14. (setq titletop (getstring "\nWhat is title top? "))
  15. (setq titlemiddle (getstring "\nWhat is title middle? "))
  16. (setq titlebottom (getstring "\nWhat is title bottom? "))
  17. )
  18. ((= opt 2);;if user picks to update revblock
  19. (setq
  20.    row (getint "\nWhich revision row do you wish to edit? ")
  21. )
  22. (progn
  23.    (cond
  24.      ((= row 1)
  25.       (setq 1rowrev (getstring "\n1st row rev: "))
  26.       (setq 1rowyy (getstring "\n1st row year: "))
  27.       (setq 1rowmm (getstring "\n1st row month: "))
  28.       (setq 1rowdd (getstring "\n1st row day: "))
  29.       (setq 1rdesc (getstring T "\n1st row description: "))
  30.       (setq 1rowby (getstring "\n1st row by: "))
  31.       (setq 1rowchk (getstring "\n1st row chk: "))
  32.       (setq 1roweng (getstring "\n1st row eng: "))
  33.       (setq 1rowapp (getstring "\n1st row app: "))
  34.       (vla-SetCustomByIndex(7, 1RREV, 1rowrev))
  35.       )
  36.      ((= row 2)
  37.       (setq 2rowrev (getstring "\n2nd row rev: "))
  38.       (setq 2rowyy (getstring "\n2nd row year: "))
  39.       (setq 2rowmm (getstring "\n2nd row month: "))
  40.       (setq 2rowdd (getstring "\n2nd row day: "))
  41.       (setq 2rdesc (getstring T "\n2nd row description: "))
  42.       (setq 2rowby (getstring "\n2nd row by: "))
  43.       (setq 2rowchk (getstring "\n2nd row chk: "))
  44.       (setq 2roweng (getstring "\n2nd row eng: "))
  45.       (setq 2rowapp (getstring "\n2nd row app: "))
  46.      )
  47.      ((= row 3)
  48.       (setq 3rowrev (getstring "\n3rd row rev: "))
  49.       (setq 3rowyy (getstring "\n3rd row year: "))
  50.       (setq 3rowmm (getstring "\n3rd row month: "))
  51.       (setq 3rowdd (getstring "\n3rd row day: "))
  52.       (setq 3rdesc (getstring T "\n3rd row description: "))
  53.       (setq 3rowby (getstring "\n3rd row by: "))
  54.       (setq 3rowchk (getstring "\n3rd row chk: "))
  55.       (setq 3roweng (getstring "\n3rd row eng: "))
  56.       (setq 3rowapp (getstring "\n3rd row app: "))
  57.      )
  58.      ((= row 4)
  59.       (setq 4rowrev (getstring "\n4th row rev: "))
  60.       (setq 4rowyy (getstring "\n4th row year: "))
  61.       (setq 4rowmm (getstring "\n4th row month: "))
  62.       (setq 4rowdd (getstring "\n4th row day: "))
  63.       (setq 4rdesc (getstring T "\n4th row description: "))
  64.       (setq 4rowby (getstring "\n4th row by: "))
  65.       (setq 4rowchk (getstring "\n4th row chk: "))
  66.       (setq 4roweng (getstring "\n4th row eng: "))
  67.       (setq 4rowapp (getstring "\n4th row app: "))
  68.      )
  69.    );;end cond
  70. );; end progn
  71. );;end opt 2
  72. ((= opt 3);;if user picks to update drawing titles, still figuring this section out
  73. )
  74.      );;end cond
  75.    );;end 1st progn
  76. );;end 1st if
  77. );;end defun

 
这是我遇到的错误:
 
 
这是我正在使用的参考页。。。还有这个
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-6 00:02:18 | 显示全部楼层
 
请将其替换为以下内容,然后重试。
 
  1. (vla-SetCustomByIndex si 7 1RREV 1rowrev)

 
虽然我不确定键的值和1RREV、1ROWREV的值
回复

使用道具 举报

11

主题

44

帖子

33

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
55
发表于 2022-7-6 00:09:17 | 显示全部楼层
 
1RREV是在第一个修订行的“图形特性”的“自定义特性”选项卡中设置的名称。如果有帮助的话。
 
更新了代码,这是我得到的错误:
 
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-6 00:14:17 | 显示全部楼层
你有一个额外的括号,变量1RREV没有值,它应该是一个字符串,更重要的是,本地化你的变量。
回复

使用道具 举报

11

主题

44

帖子

33

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
55
发表于 2022-7-6 00:15:37 | 显示全部楼层
 
我运行了VLIDE检查,但括号中没有任何内容。我已经更新了代码来本地化变量,但仍然出现同样的错误。更新代码见下文。
 
  1. (defun c:TB (/ doc db si opt titletop titlemiddle titlebottom row
  2.      1rowrev 1rowyy 1rowmm 1rowdd 1rowdesc 1rowby 1rowchk 1roweng 1rowapp
  3.      2rowrev 2rowyy 2rowmm 2rowdd 2rowdesc 2rowby 2rowchk 2roweng 2rowapp
  4.      3rowrev 3rowyy 3rowmm 3rowdd 3rowdesc 3rowby 3rowchk 3roweng 3rowapp
  5.      4rowrev 4rowyy 4rowmm 4rowdd 4rowdesc 4rowby 4rowchk 4roweng 4rowapp
  6.      )
  7. (vl-load-com)
  8. (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
  9. (setq db (vla-get-Database doc))
  10. (setq si (vla-get-SummaryInfo db))
  11. (if (setq Opt
  12.      (getint
  13.        "\nDo you want to: 1- Update Titleblock 2- Update RevBlock 3- Update Drawing Titles: "
  14.      )
  15.      );;user input for variable "opt"
  16.    (progn
  17.      (cond
  18. ((= opt 1);;if user picks to update titleblock
  19. (setq titletop (getstring "\nWhat is title top? "))
  20. (setq titlemiddle (getstring "\nWhat is title middle? "))
  21. (setq titlebottom (getstring "\nWhat is title bottom? "))
  22. )
  23. ((= opt 2);;if user picks to update revblock
  24. (setq
  25.    row (getint "\nWhich revision row do you wish to edit? ")
  26. )
  27. (progn
  28.    (cond
  29.      ((= row 1)
  30.       (setq 1rowrev (getstring "\n1st row rev: "))
  31.       (setq 1rowyy (getstring "\n1st row year: "))
  32.       (setq 1rowmm (getstring "\n1st row month: "))
  33.       (setq 1rowdd (getstring "\n1st row day: "))
  34.       (setq 1rdesc (getstring T "\n1st row description: "))
  35.       (setq 1rowby (getstring "\n1st row by: "))
  36.       (setq 1rowchk (getstring "\n1st row chk: "))
  37.       (setq 1roweng (getstring "\n1st row eng: "))
  38.       (setq 1rowapp (getstring "\n1st row app: "))
  39.       (vla-SetCustomByIndex si 7 1RREV 1rowrev)
  40.       )
  41.      ((= row 2)
  42.       (setq 2rowrev (getstring "\n2nd row rev: "))
  43.       (setq 2rowyy (getstring "\n2nd row year: "))
  44.       (setq 2rowmm (getstring "\n2nd row month: "))
  45.       (setq 2rowdd (getstring "\n2nd row day: "))
  46.       (setq 2rdesc (getstring T "\n2nd row description: "))
  47.       (setq 2rowby (getstring "\n2nd row by: "))
  48.       (setq 2rowchk (getstring "\n2nd row chk: "))
  49.       (setq 2roweng (getstring "\n2nd row eng: "))
  50.       (setq 2rowapp (getstring "\n2nd row app: "))
  51.      )
  52.      ((= row 3)
  53.       (setq 3rowrev (getstring "\n3rd row rev: "))
  54.       (setq 3rowyy (getstring "\n3rd row year: "))
  55.       (setq 3rowmm (getstring "\n3rd row month: "))
  56.       (setq 3rowdd (getstring "\n3rd row day: "))
  57.       (setq 3rdesc (getstring T "\n3rd row description: "))
  58.       (setq 3rowby (getstring "\n3rd row by: "))
  59.       (setq 3rowchk (getstring "\n3rd row chk: "))
  60.       (setq 3roweng (getstring "\n3rd row eng: "))
  61.       (setq 3rowapp (getstring "\n3rd row app: "))
  62.      )
  63.      ((= row 4)
  64.       (setq 4rowrev (getstring "\n4th row rev: "))
  65.       (setq 4rowyy (getstring "\n4th row year: "))
  66.       (setq 4rowmm (getstring "\n4th row month: "))
  67.       (setq 4rowdd (getstring "\n4th row day: "))
  68.       (setq 4rdesc (getstring T "\n4th row description: "))
  69.       (setq 4rowby (getstring "\n4th row by: "))
  70.       (setq 4rowchk (getstring "\n4th row chk: "))
  71.       (setq 4roweng (getstring "\n4th row eng: "))
  72.       (setq 4rowapp (getstring "\n4th row app: "))
  73.      )
  74.    );;end cond
  75. );; end progn
  76. );;end opt 2
  77. ((= opt 3);;if user picks to update drawing titles, still figuring this section out
  78. )
  79.      );;end cond
  80.    );;end 1st progn
  81. );;end 1st if
  82. );;end defun
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-6 00:21:53 | 显示全部楼层
 
同样,变量1RREV是nil,它应该是字符串。或者变量名必须是1rowrev
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-11 00:39 , Processed in 0.657341 second(s), 75 queries .

© 2020-2025 乐筑天下

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