乐筑天下

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

[编程交流] 协助更新Lisp routi

[复制链接]

5

主题

33

帖子

28

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 15:02:29 | 显示全部楼层 |阅读模式
你好
我有一个很长的Lisp程序程序,多年来没有更新过。这是严格为自定义字段插入,我不记得如何编辑它。我创建了一个diesel表达式,用于我尝试做的事情,即在文件名中添加破折号,并删除CAD文件中DWG#'s的最后4个字符。我制作了一个包含在下面的diesel表达式,但它对于使用MacAttEdit来说太长了,所以如果有人能理解的话,我想把它添加到这个lisp例程中。或者,如果有人知道如何缩短Diesel表达式,因为我只是一个新手。
 
我们当前的文件名是(28个字符):
AB12345AB1234ABCA123456789-1
 
DWG#为(前24个字符加5个破折号,因此为29个字符):
AB-12345-AB1234-ABC-A12-12345
 
Diesel表达式(我知道很长):
  1. %<\AcDiesel $(substr,$(getvar,DWGNAME),1,2)-$(substr,$(getvar,DWGNAME),3,5)-$(substr,$(getvar,DWGNAME),8,6)-$(substr,$(getvar,DWGNAME),14,3)-$(substr,$(getvar,DWGNAME),17,3)-$(substr,$(getvar,DWGNAME),20,5)>%

 
带有自定义插入的Lisp:
  1. (defun c:updatetitleblock ( /
  2.    ;;local variables
  3.    acadObject
  4.    acadDocument
  5.    dProps
  6.    customPropertyName
  7. customPropertyNamecpchem
  8.    revCustomPropertyName
  9.    projectCustomPropertyName
  10.    folderCustomPropertyName
  11.    folderCustomPropertyName2
  12.    KeyCount
  13.    KeyValue
  14.    strDrawingName
  15.    strRevNum
  16.    strDrawingNameNoSpaces
  17. left20characters
  18. left21characters
  19. left22characters
  20. left23characters
  21. left24characters
  22. left25characters
  23. left26characters
  24. left27characters
  25. left28characters
  26. left2characters
  27. left18characters
  28.    )
  29.    
  30.    
  31. ;;sets the document properties
  32. (setq acadObject (vlax-get-acad-object)
  33.      acadDocument (vla-get-ActiveDocument acadObject)
  34.      dProps (vlax-get-Property acadDocument 'SummaryInfo)
  35.      customPropertyName "DRAWING No. (from file name)"
  36.   customPropertyNamecpchem "filename sans characters after penultimate dash"
  37.      revCustomPropertyName "REV (from file name)"
  38.      projectCustomPropertyName "PROJECT NO (from file name)"
  39.      projectCustomPropertyName2 "file name before underscore"
  40.      folderCustomPropertyName "last character of folder"
  41.      folderCustomPropertyName2 "last 2 characters of folder"
  42.   left20characters "filename (left 20 characters)"
  43.   left21characters "filename (left 21 characters)"
  44.   left22characters "filename (left 22 characters)"
  45.   left23characters "filename (left 23 characters)"
  46.   left24characters "filename (left 24 characters)"
  47.   left25characters "filename (left 25 characters)"
  48.   left26characters "filename (left 26 characters)"
  49.   left27characters "filename (left 27 characters)"
  50.   left28characters "filename (left 28 characters)"
  51.   left2characters "filename (left 2 characters)"
  52.   left18characters "filename (left 18 characters)"
  53. )
  54. ;;sets a couple variables so that we can determine whether the property exists
  55. (setq KeyCount 0 KeyValue nil)
  56. ;;while KeyValue is blank and KeyCount is less than number of properties
  57. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  58.   ;;get info about that property
  59.   (vla-GetCustomByIndex
  60.      dProps
  61.      KeyCount
  62.      'TempKeyName
  63.      'TempKeyValue
  64.   )
  65.   ;;if the property name matches the name we want, set KeyValue to it's value
  66.   (if        (= TempKeyName customPropertyName)
  67.      (setq KeyValue TempKeyValue)
  68.   )
  69.   ;;increment KayCount
  70.   (setq KeyCount (1+ KeyCount))
  71. )
  72. ;;
  73. ;;now we add the property if it wasn't there already
  74. (if (= KeyValue nil) (vla-addcustominfo dProps customPropertyName "REOPEN DRAWING TO UPDATE")  )
  75. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  76. ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left20characters;;;;;;;;;;;;;;;;;;;;;;
  77. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  78. ;;sets a couple variables so that we can determine whether the property exists
  79. (setq KeyCount 0 KeyValue nil)
  80. ;;while KeyValue is blank and KeyCount is less than number of properties
  81. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  82.   ;;get info about that property
  83.   (vla-GetCustomByIndex
  84.      dProps
  85.      KeyCount
  86.      'TempKeyName
  87.      'TempKeyValue
  88.   )
  89.   ;;if the property name matches the name we want, set KeyValue to it's value
  90.   (if        (= TempKeyName left20characters)
  91.      (setq KeyValue TempKeyValue)
  92.   )
  93.   ;;increment KayCount
  94.   (setq KeyCount (1+ KeyCount))
  95. )
  96. ;;
  97. ;;now we add the property if it wasn't there already
  98. (if (= KeyValue nil) (vla-addcustominfo dProps left20characters "REOPEN DRAWING TO UPDATE")  )
  99. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  100. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  101. ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left21characters;;;;;;;;;;;;;;;;;;;;;;
  102. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  103. ;;sets a couple variables so that we can determine whether the property exists
  104. (setq KeyCount 0 KeyValue nil)
  105. ;;while KeyValue is blank and KeyCount is less than number of properties
  106. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  107.   ;;get info about that property
  108.   (vla-GetCustomByIndex
  109.      dProps
  110.      KeyCount
  111.      'TempKeyName
  112.      'TempKeyValue
  113.   )
  114.   ;;if the property name matches the name we want, set KeyValue to it's value
  115.   (if        (= TempKeyName left21characters)
  116.      (setq KeyValue TempKeyValue)
  117.   )
  118.   ;;increment KayCount
  119.   (setq KeyCount (1+ KeyCount))
  120. )
  121. ;;
  122. ;;now we add the property if it wasn't there already
  123. (if (= KeyValue nil) (vla-addcustominfo dProps left21characters "REOPEN DRAWING TO UPDATE")  )
  124. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  125. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  126. ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left22characters;;;;;;;;;;;;;;;;;;;;;;
  127. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  128. ;;sets a couple variables so that we can determine whether the property exists
  129. (setq KeyCount 0 KeyValue nil)
  130. ;;while KeyValue is blank and KeyCount is less than number of properties
  131. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  132.   ;;get info about that property
  133.   (vla-GetCustomByIndex
  134.      dProps
  135.      KeyCount
  136.      'TempKeyName
  137.      'TempKeyValue
  138.   )
  139.   ;;if the property name matches the name we want, set KeyValue to it's value
  140.   (if        (= TempKeyName left22characters)
  141.      (setq KeyValue TempKeyValue)
  142.   )
  143.   ;;increment KayCount
  144.   (setq KeyCount (1+ KeyCount))
  145. )
  146. ;;
  147. ;;now we add the property if it wasn't there already
  148. (if (= KeyValue nil) (vla-addcustominfo dProps left22characters "REOPEN DRAWING TO UPDATE")  )
  149. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  150. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  151. ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left23characters;;;;;;;;;;;;;;;;;;;;;;
  152. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  153. ;;sets a couple variables so that we can determine whether the property exists
  154. (setq KeyCount 0 KeyValue nil)
  155. ;;while KeyValue is blank and KeyCount is less than number of properties
  156. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  157.   ;;get info about that property
  158.   (vla-GetCustomByIndex
  159.      dProps
  160.      KeyCount
  161.      'TempKeyName
  162.      'TempKeyValue
  163.   )
  164.   ;;if the property name matches the name we want, set KeyValue to it's value
  165.   (if        (= TempKeyName left23characters)
  166.      (setq KeyValue TempKeyValue)
  167.   )
  168.   ;;increment KayCount
  169.   (setq KeyCount (1+ KeyCount))
  170. )
  171. ;;
  172. ;;now we add the property if it wasn't there already
  173. (if (= KeyValue nil) (vla-addcustominfo dProps left23characters "REOPEN DRAWING TO UPDATE")  )
  174. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  175. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  176. ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left24characters;;;;;;;;;;;;;;;;;;;;;;
  177. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  178. ;;sets a couple variables so that we can determine whether the property exists
  179. (setq KeyCount 0 KeyValue nil)
  180. ;;while KeyValue is blank and KeyCount is less than number of properties
  181. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  182.   ;;get info about that property
  183.   (vla-GetCustomByIndex
  184.      dProps
  185.      KeyCount
  186.      'TempKeyName
  187.      'TempKeyValue
  188.   )
  189.   ;;if the property name matches the name we want, set KeyValue to it's value
  190.   (if        (= TempKeyName left24characters)
  191.      (setq KeyValue TempKeyValue)
  192.   )
  193.   ;;increment KayCount
  194.   (setq KeyCount (1+ KeyCount))
  195. )
  196. ;;
  197. ;;now we add the property if it wasn't there already
  198. (if (= KeyValue nil) (vla-addcustominfo dProps left24characters "REOPEN DRAWING TO UPDATE")  )
  199. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  200. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  201. ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left25characters;;;;;;;;;;;;;;;;;;;;;;
  202. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  203. ;;sets a couple variables so that we can determine whether the property exists
  204. (setq KeyCount 0 KeyValue nil)
  205. ;;while KeyValue is blank and KeyCount is less than number of properties
  206. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  207.   ;;get info about that property
  208.   (vla-GetCustomByIndex
  209.      dProps
  210.      KeyCount
  211.      'TempKeyName
  212.      'TempKeyValue
  213.   )
  214.   ;;if the property name matches the name we want, set KeyValue to it's value
  215.   (if        (= TempKeyName left25characters)
  216.      (setq KeyValue TempKeyValue)
  217.   )
  218.   ;;increment KayCount
  219.   (setq KeyCount (1+ KeyCount))
  220. )
  221. ;;
  222. ;;now we add the property if it wasn't there already
  223. (if (= KeyValue nil) (vla-addcustominfo dProps left25characters "REOPEN DRAWING TO UPDATE")  )
  224. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  225. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  226. ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left26characters;;;;;;;;;;;;;;;;;;;;;;
  227. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  228. ;;sets a couple variables so that we can determine whether the property exists
  229. (setq KeyCount 0 KeyValue nil)
  230. ;;while KeyValue is blank and KeyCount is less than number of properties
  231. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  232.   ;;get info about that property
  233.   (vla-GetCustomByIndex
  234.      dProps
  235.      KeyCount
  236.      'TempKeyName
  237.      'TempKeyValue
  238.   )
  239.   ;;if the property name matches the name we want, set KeyValue to it's value
  240.   (if        (= TempKeyName left26characters)
  241.      (setq KeyValue TempKeyValue)
  242.   )
  243.   ;;increment KayCount
  244.   (setq KeyCount (1+ KeyCount))
  245. )
  246. ;;
  247. ;;now we add the property if it wasn't there already
  248. (if (= KeyValue nil) (vla-addcustominfo dProps left26characters "REOPEN DRAWING TO UPDATE")  )
  249. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  250. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  251. ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left27characters;;;;;;;;;;;;;;;;;;;;;;
  252. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  253. ;;sets a couple variables so that we can determine whether the property exists
  254. (setq KeyCount 0 KeyValue nil)
  255. ;;while KeyValue is blank and KeyCount is less than number of properties
  256. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  257.   ;;get info about that property
  258.   (vla-GetCustomByIndex
  259.      dProps
  260.      KeyCount
  261.      'TempKeyName
  262.      'TempKeyValue
  263.   )
  264.   ;;if the property name matches the name we want, set KeyValue to it's value
  265.   (if        (= TempKeyName left27characters)
  266.      (setq KeyValue TempKeyValue)
  267.   )
  268.   ;;increment KayCount
  269.   (setq KeyCount (1+ KeyCount))
  270. )
  271. ;;
  272. ;;now we add the property if it wasn't there already
  273. (if (= KeyValue nil) (vla-addcustominfo dProps left27characters "REOPEN DRAWING TO UPDATE")  )
  274. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  275. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  276. ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left28characters;;;;;;;;;;;;;;;;;;;;;;
  277. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  278. ;;sets a couple variables so that we can determine whether the property exists
  279. (setq KeyCount 0 KeyValue nil)
  280. ;;while KeyValue is blank and KeyCount is less than number of properties
  281. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  282.   ;;get info about that property
  283.   (vla-GetCustomByIndex
  284.      dProps
  285.      KeyCount
  286.      'TempKeyName
  287.      'TempKeyValue
  288.   )
  289.   ;;if the property name matches the name we want, set KeyValue to it's value
  290.   (if        (= TempKeyName left28characters)
  291.      (setq KeyValue TempKeyValue)
  292.   )
  293.   ;;increment KayCount
  294.   (setq KeyCount (1+ KeyCount))
  295. )
  296. ;;
  297. ;;now we add the property if it wasn't there already
  298. (if (= KeyValue nil) (vla-addcustominfo dProps left28characters "REOPEN DRAWING TO UPDATE")  )
  299. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  300. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  301. ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left2characters;;;;;;;;;;;;;;;;;;;;;;
  302. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  303. ;;sets a couple variables so that we can determine whether the property exists
  304. (setq KeyCount 0 KeyValue nil)
  305. ;;while KeyValue is blank and KeyCount is less than number of properties
  306. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  307.   ;;get info about that property
  308.   (vla-GetCustomByIndex
  309.      dProps
  310.      KeyCount
  311.      'TempKeyName
  312.      'TempKeyValue
  313.   )
  314.   ;;if the property name matches the name we want, set KeyValue to it's value
  315.   (if        (= TempKeyName left2characters)
  316.      (setq KeyValue TempKeyValue)
  317.   )
  318.   ;;increment KayCount
  319.   (setq KeyCount (1+ KeyCount))
  320. )
  321. ;;
  322. ;;now we add the property if it wasn't there already
  323. (if (= KeyValue nil) (vla-addcustominfo dProps left2characters "REOPEN DRAWING TO UPDATE")  )
  324. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  325. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  326. ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR left18characters;;;;;;;;;;;;;;;;;;;;;;
  327. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  328. ;;sets a couple variables so that we can determine whether the property exists
  329. (setq KeyCount 0 KeyValue nil)
  330. ;;while KeyValue is blank and KeyCount is less than number of properties
  331. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  332.   ;;get info about that property
  333.   (vla-GetCustomByIndex
  334.      dProps
  335.      KeyCount
  336.      'TempKeyName
  337.      'TempKeyValue
  338.   )
  339.   ;;if the property name matches the name we want, set KeyValue to it's value
  340.   (if        (= TempKeyName left18characters)
  341.      (setq KeyValue TempKeyValue)
  342.   )
  343.   ;;increment KayCount
  344.   (setq KeyCount (1+ KeyCount))
  345. )
  346. ;;
  347. ;;now we add the property if it wasn't there already
  348. (if (= KeyValue nil) (vla-addcustominfo dProps left18characters "REOPEN DRAWING TO UPDATE")  )
  349. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  350. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  351. ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR CPchem;;;;;;;;;;;;;;;;;;;;;;
  352. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  353. ;;sets a couple variables so that we can determine whether the property exists
  354. (setq KeyCount 0 KeyValue nil)
  355. ;;while KeyValue is blank and KeyCount is less than number of properties
  356. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  357.   ;;get info about that property
  358.   (vla-GetCustomByIndex
  359.      dProps
  360.      KeyCount
  361.      'TempKeyName
  362.      'TempKeyValue
  363.   )
  364.   ;;if the property name matches the name we want, set KeyValue to it's value
  365.   (if        (= TempKeyName customPropertyNamecpchem)
  366.      (setq KeyValue TempKeyValue)
  367.   )
  368.   ;;increment KayCount
  369.   (setq KeyCount (1+ KeyCount))
  370. )
  371. ;;
  372. ;;now we add the property if it wasn't there already
  373. (if (= KeyValue nil) (vla-addcustominfo dProps customPropertyNamecpchem "REOPEN DRAWING TO UPDATE")  )
  374. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  375. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  376. ;;;;;;;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR REV;;;;;;;;;;;;;;;;;;;;;;
  377. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  378. ;;sets a couple variables so that we can determine whether the property exists
  379. (setq KeyCount 0 KeyValue nil)
  380. ;;while KeyValue is blank and KeyCount is less than number of properties
  381. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  382.   ;;get info about that property
  383.   (vla-GetCustomByIndex
  384.      dProps
  385.      KeyCount
  386.      'TempKeyName
  387.      'TempKeyValue
  388.   )
  389.   ;;if the property name matches the name we want, set KeyValue to it's value
  390.   (if        (= TempKeyName revCustomPropertyName)
  391.      (setq KeyValue TempKeyValue)
  392.   )
  393.   ;;increment KayCount
  394.   (setq KeyCount (1+ KeyCount))
  395. )
  396. ;;
  397. ;;now we add the property if it wasn't there already
  398. (if (= KeyValue nil) (vla-addcustominfo dProps revCustomPropertyName "REOPEN DRAWING TO UPDATE")  )
  399. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  400. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  401. ;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR folderLastDigit;;;;;;;;;;;;;;;;
  402. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  403. ;;sets a couple variables so that we can determine whether the property exists
  404. (setq KeyCount 0 KeyValue nil)
  405. ;;while KeyValue is blank and KeyCount is less than number of properties
  406. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  407.   ;;get info about that property
  408.   (vla-GetCustomByIndex
  409.      dProps
  410.      KeyCount
  411.      'TempKeyName
  412.      'TempKeyValue
  413.   )
  414.   ;;if the property name matches the name we want, set KeyValue to it's value
  415.   (if        (= TempKeyName folderCustomPropertyName)
  416.      (setq KeyValue TempKeyValue)
  417.   )
  418.   ;;increment KayCount
  419.   (setq KeyCount (1+ KeyCount))
  420. )
  421. ;;
  422. ;;now we add the property if it wasn't there already
  423. (if (= KeyValue nil) (vla-addcustominfo dProps folderCustomPropertyName "REOPEN DRAWING TO UPDATE")  )
  424. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  425. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  426. ;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR project number;;;;;;;;;;;;;;;;
  427. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  428. ;;sets a couple variables so that we can determine whether the property exists
  429. (setq KeyCount 0 KeyValue nil)
  430. ;;while KeyValue is blank and KeyCount is less than number of properties
  431. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  432.   ;;get info about that property
  433.   (vla-GetCustomByIndex
  434.      dProps
  435.      KeyCount
  436.      'TempKeyName
  437.      'TempKeyValue
  438.   )
  439.   ;;if the property name matches the name we want, set KeyValue to it's value
  440.   (if        (= TempKeyName projectCustomPropertyName)
  441.      (setq KeyValue TempKeyValue)
  442.   )
  443.   ;;increment KayCount
  444.   (setq KeyCount (1+ KeyCount))
  445. )
  446. ;;
  447. ;;now we add the property if it wasn't there already
  448. (if (= KeyValue nil) (vla-addcustominfo dProps projectCustomPropertyName "REOPEN DRAWING TO UPDATE")  )
  449. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  450. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  451. ;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR project number;;;;;;;;;;;;;;;;
  452. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  453. ;;sets a couple variables so that we can determine whether the property exists
  454. (setq KeyCount 0 KeyValue nil)
  455. ;;while KeyValue is blank and KeyCount is less than number of properties
  456. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  457.   ;;get info about that property
  458.   (vla-GetCustomByIndex
  459.      dProps
  460.      KeyCount
  461.      'TempKeyName
  462.      'TempKeyValue
  463.   )
  464.   ;;if the property name matches the name we want, set KeyValue to it's value
  465.   (if        (= TempKeyName projectCustomPropertyName2)
  466.      (setq KeyValue TempKeyValue)
  467.   )
  468.   ;;increment KayCount
  469.   (setq KeyCount (1+ KeyCount))
  470. )
  471. ;;
  472. ;;now we add the property if it wasn't there already
  473. (if (= KeyValue nil) (vla-addcustominfo dProps projectCustomPropertyName2 "REOPEN DRAWING TO UPDATE")  )
  474. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  475. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  476. ;;;;;;;;;;;;SAME THING AS ABOVE, BUT FOR project number;;;;;;;;;;;;;;;;
  477. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  478. ;;sets a couple variables so that we can determine whether the property exists
  479. (setq KeyCount 0 KeyValue nil)
  480. ;;while KeyValue is blank and KeyCount is less than number of properties
  481. (while (and (null KeyValue) (< KeyCount (vla-NumCustomInfo dProps)))
  482.   ;;get info about that property
  483.   (vla-GetCustomByIndex
  484.      dProps
  485.      KeyCount
  486.      'TempKeyName
  487.      'TempKeyValue
  488.   )
  489.   ;;if the property name matches the name we want, set KeyValue to it's value
  490.   (if        (= TempKeyName folderCustomPropertyName2)
  491.      (setq KeyValue TempKeyValue)
  492.   )
  493.   ;;increment KayCount
  494.   (setq KeyCount (1+ KeyCount))
  495. )
  496. ;;
  497. ;;now we add the property if it wasn't there already
  498. (if (= KeyValue nil) (vla-addcustominfo dProps folderCustomPropertyName2 "REOPEN DRAWING TO UPDATE")  )
  499. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  500. ;;sets strDrawingName as the name of the current drawing
  501. (setq strDrawingName (getvar "dwgname"))
  502. ;;resets strRevNum
  503. (setq strRevNum "")
  504. ;;makes strDrawingName uppercase
  505. (setq strDrawingName (strcase strDrawingName))
  506. ;;if the drawing name ends in .DWG, take off the last 4 characters
  507. (if (= (substr strDrawingName (- (strlen strDrawingName) 3) (strlen strDrawingName)) ".DWG")
  508.   (setq strDrawingName (substr strDrawingName 1 (- (strlen strDrawingName) 4)))
  509.   (setq strDrawingName strDrawingName)
  510. )
  511. ;;makes strDrawingNameNoSpaces
  512. (setq strDrawingNameNoSpaces strDrawingName)
  513. (while (/= strDrawingNameNoSpaces (vl-string-subst "" " " strDrawingNameNoSpaces)) (setq strDrawingNameNoSpaces (vl-string-subst "" " " strDrawingNameNoSpaces)))
  514. ;;makes all the set-length filenames
  515. (setq strleft20characters (substr strDrawingNameNoSpaces 1 20))
  516. (setq strleft21characters (substr strDrawingNameNoSpaces 1 21))
  517. (setq strleft22characters (substr strDrawingNameNoSpaces 1 22))
  518. (setq strleft23characters (substr strDrawingNameNoSpaces 1 23))
  519. (setq strleft24characters (substr strDrawingNameNoSpaces 1 24))
  520. (setq strleft25characters (substr strDrawingNameNoSpaces 1 25))
  521. (setq strleft26characters (substr strDrawingNameNoSpaces 1 26))
  522. (setq strleft27characters (substr strDrawingNameNoSpaces 1 27))
  523. (setq strleft28characters (substr strDrawingNameNoSpaces 1 28))
  524. (setq strleft2characters (substr strDrawingNameNoSpaces 1 2))
  525. (setq strleft18characters (substr strDrawingNameNoSpaces 1 18))
  526. ;;makes strDrawingNamecpchem
  527. (setq strDrawingNamecpchem strDrawingNameNoSpaces)
  528. (if (= (substr strDrawingNamecpchem (- (strlen strDrawingNamecpchem) 1) 1) "-") (setq strDrawingNamecpchem (substr strDrawingNamecpchem 1 (- (strlen strDrawingNamecpchem) 2)))
  529. (if (= (substr strDrawingNamecpchem (- (strlen strDrawingNamecpchem) 2) 1) "-") (setq strDrawingNamecpchem (substr strDrawingNamecpchem 1 (- (strlen strDrawingNamecpchem) 3)))
  530.         (if (= (substr strDrawingNamecpchem (- (strlen strDrawingNamecpchem) 3) 1) "-") (setq strDrawingNamecpchem (substr strDrawingNamecpchem 1 (- (strlen strDrawingNamecpchem) 4))))
  531. )
  532. )
  533. (if (= (substr strDrawingNamecpchem (- (strlen strDrawingNamecpchem) 1) 1) "-") (setq strDrawingNamecpchem (substr strDrawingNamecpchem 1 (- (strlen strDrawingNamecpchem) 2)))
  534. (if (= (substr strDrawingNamecpchem (- (strlen strDrawingNamecpchem) 2) 1) "-") (setq strDrawingNamecpchem (substr strDrawingNamecpchem 1 (- (strlen strDrawingNamecpchem) 3)))
  535.         (if (= (substr strDrawingNamecpchem (- (strlen strDrawingNamecpchem) 3) 1) "-") (setq strDrawingNamecpchem (substr strDrawingNamecpchem 1 (- (strlen strDrawingNamecpchem) 4))))
  536. )
  537. )
  538. ;;does stuff to get rid of revision number
  539. (if (= nil (vl-string-search "REV" strDrawingName))
  540.   ;;unless there is no rev, in which get rid of trailing numbers
  541.   ;;if the last three digits of DrawingNameNoSpaces has a dash or a period or an underscore
  542.   (if (/= (substr strDrawingNameNoSpaces (- (strlen strDrawingNameNoSpaces) 2) 3) (vl-string-subst "" "." (vl-string-subst "" "_" (vl-string-subst "" "-" (substr strDrawingNameNoSpaces (- (strlen strDrawingNameNoSpaces) 2) 3)))))
  543.      (while (/= "_" (substr strDrawingName (strlen strDrawingName) 1) "-" (substr strDrawingName (strlen strDrawingName) 1) ".")
  544.         (setq strRevNum (strcat (substr strDrawingName (strlen strDrawingName) 1) strRevNum)
  545.               strDrawingName (substr strDrawingName 1 (- (strlen strDrawingName) 1))
  546.         )
  547.      )
  548.      ;;otherwise, if the last four digits are a dash and 3 numbers
  549.      (if (= (vl-string-right-trim "0123456789" (substr strDrawingNameNoSpaces (- (strlen strDrawingNameNoSpaces) 3) 4)) "-")
  550.        (progn
  551.           (setq strRevNum (substr strDrawingNameNoSpaces (- (strlen strDrawingNameNoSpaces) 2) 3)
  552.                 strDrawingName (substr strDrawingName 1 (- (strlen strDrawingName) 4))
  553.           )
  554.        )
  555.      )
  556.   )
  557.   ;;gets rid of everything past the REV
  558.   (setq strRevNum (substr strDrawingName (+ 4 (vl-string-search "REV" strDrawingName)) (- (+ 1 (strlen strDrawingName)) (vl-string-search "REV" strDrawingName)))
  559.         strDrawingName (substr strDrawingName 1 (vl-string-search "REV" strDrawingName)))
  560. )
  561. ;;gets rid of trailing spaces and dashes
  562. (setq strDrawingName (vl-string-right-trim " -._(" strDrawingName))
  563. (setq strRevNum (vl-string-right-trim " -._()" strRevNum))
  564. ;;gets rid of #. or ##.from beginning of drawing name
  565. (if (or (= (substr strDrawingName 2 1) ".") (= (substr strDrawingName 3 1) "."))
  566.   ;;gets rid of opening digits
  567.   (setq strDrawingName (vl-string-left-trim "0123456789" strDrawingName))
  568.   ;;otherwise do nothing
  569.   (setq strDrawingName strDrawingName)
  570. )
  571. ;;gets rid of leading spaces and dashes
  572. (setq strDrawingName (vl-string-left-trim " -._)" strDrawingName))
  573. (setq strRevNum (vl-string-left-trim " -._()" strRevNum))
  574. ;;gets rid of leading zeros from drawing rev
  575. (if (and (= (substr strRevNum 1 1) "0") (> (strlen strRevNum) 1)) (setq strRevNum (substr strRevNum 2 (- (strlen strRevNum) 1)))  )
  576. (if (and (= (substr strRevNum 1 1) "0") (> (strlen strRevNum) 1)) (setq strRevNum (substr strRevNum 2 (- (strlen strRevNum) 1)))  )
  577. (if (and (= (substr strRevNum 1 1) "0") (> (strlen strRevNum) 1)) (setq strRevNum (substr strRevNum 2 (- (strlen strRevNum) 1)))  )
  578. ;;sets the property to our formatted name
  579. (vla-SetCustomByKey dProps left20characters strleft20characters)
  580. (vla-SetCustomByKey dProps left21characters strleft21characters)
  581. (vla-SetCustomByKey dProps left22characters strleft22characters)
  582. (vla-SetCustomByKey dProps left23characters strleft23characters)
  583. (vla-SetCustomByKey dProps left24characters strleft24characters)
  584. (vla-SetCustomByKey dProps left25characters strleft25characters)
  585. (vla-SetCustomByKey dProps left26characters strleft26characters)
  586. (vla-SetCustomByKey dProps left27characters strleft27characters)
  587. (vla-SetCustomByKey dProps left28characters strleft28characters)
  588. (vla-SetCustomByKey dProps left2characters strleft2characters)
  589. (vla-SetCustomByKey dProps left18characters strleft18characters)
  590. (vla-SetCustomByKey dProps customPropertyNamecpchem strDrawingNamecpchem)
  591. (vla-SetCustomByKey dProps customPropertyName strDrawingName)
  592. (vla-SetCustomByKey dProps revCustomPropertyName strRevNum)
  593. (vla-SetCustomByKey dProps folderCustomPropertyName (substr(getvar "dwgprefix") (- (strlen (getvar "dwgprefix")) 1) 1))
  594. (vla-SetCustomByKey dProps folderCustomPropertyName2 (substr(getvar "dwgprefix") (- (strlen (getvar "dwgprefix")) 2) 2))
  595. (vla-SetCustomByKey dProps projectCustomPropertyName (vl-string-right-trim " -._()" (substr strDrawingName 1 10)))
  596. (vla-SetCustomByKey dProps projectCustomPropertyName2 (vl-string-right-trim " -._()" (substr strDrawingName 1 (vl-string-search "_" strDrawingName))))
  597. ;;forces update
  598. (command "updatefield" "all" "")
  599. )
  600. (vl-load-com)
  601. (c:updatetitleblock)
  602. (princ)

 
谢谢你的帮助,如果我能找到答案,我会在这里重新发布。
回复

使用道具 举报

5

主题

33

帖子

28

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 15:07:12 | 显示全部楼层
如果有人想使用lisp和diesel表达式,顺便提一下。很高兴能找到缩短Diesel表达式的方法,因为它很长。
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-5 15:11:12 | 显示全部楼层
当然可以短得多。
 
如果随附示例图形文件,则发布的长代码更有意义。
回复

使用道具 举报

5

主题

33

帖子

28

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 15:14:44 | 显示全部楼层
 
一个pic就足够了,因为它只是一个字段插入,如下图所示。如果有办法缩短diesel表达式或将其“添加”到lisp例程中,这将很有帮助。lisp很长,因为其中有许多自定义字段插入。在下面的图片中,我在DWG编号上插入了一个内容。但是Diesel表达式太长,所以我不想将其添加到lisp例程中。同样在这种情况下,前两个字母后面有7个数字,而不是我最初发布的5个数字。“SA”字符后有5或7位数字,其余数字相同。谢谢你的帮助!
 
160234ntwmvfjxjwqrvmtn.jpg
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 15:16:01 | 显示全部楼层
你为什么不先用破折号来命名文件?
回复

使用道具 举报

5

主题

33

帖子

28

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 15:19:36 | 显示全部楼层
 
同意,不由我决定,这是客户标准。。。。。
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-5 15:23:47 | 显示全部楼层
我甚至认为这并不难。
 
 
为什么是7而不是5?还是4平?
 
这正是我们要求提供样图的原因。在你贴的那张照片上,图片的名字是什么?
 
还有这个
160235qwdwf5fw3wgwk190.png
 
这一切意味着什么?
回复

使用道具 举报

5

主题

33

帖子

28

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 15:27:31 | 显示全部楼层
随附的是DWG文件。不确定DWG属性的图片是如何出现的,因为我附加了标题栏的图片。无论如何,文件名在下面,没有任何更改。我之前提供了diesel表达式和一个包含其他插入的lisp文件。
 
SA2144283FA2006PLCE02010301-0
SA2144283FA2006PLCE02010301-0。图纸
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-5 15:28:23 | 显示全部楼层
 
这样,我们可以看到标题栏在自定义属性中引用了哪些其他字段表达式
 
 
作为启动器
 
  1. (substr
  2. (apply
  3.    'strcat
  4.    (mapcar
  5.      '(lambda (n)
  6.         (strcat "-" (substr (getvar 'dwgname) (car n) (cadr n)))
  7.         )
  8.      '((1 2) (3 5) (8 6) (14 3) (17 3) (20 5))
  9.      )
  10.    )
  11. 2
  12. )
  13. ("-AB" "-12345" "-AB1234" "-ABC" "-A12" "-34567")
  14. "AB-12345-AB1234-ABC-A12-34567"

 
可以将值赋给自定义特性,然后将其用作字段值,而不是Diesel表达式。甚至可以将lisp变量作为字段表达式,[在我看来要容易得多]
 
你还没有解释为什么有时候是5而不是7,你能解释更多吗?
 
 
 
-我在这里看到了一种模式[LPB]
 
LM会喜欢的
回复

使用道具 举报

5

主题

33

帖子

28

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 15:32:31 | 显示全部楼层
你还没有解释为什么有时候是5而不是7,你能解释更多吗?
 
 
这是客户对其文件名的要求。旧项目在“SA”后有5位数字,所有新项目和未来项目在“SA”后有7位数字。除此之外,剩余的字符数永远不会改变。
 
谢谢,我将尝试将其添加到lisp例程中。它变得如此满以至于很难记住在哪里添加它,哈哈。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-15 00:47 , Processed in 2.688159 second(s), 74 queries .

© 2020-2025 乐筑天下

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