乐筑天下

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

[编程交流] 粘土(读取线型)

[复制链接]

31

主题

107

帖子

76

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
155
发表于 2022-7-6 14:43:41 | 显示全部楼层 |阅读模式
你好
 
我修改了这个小Lisp程序的一点下载它从互联网上。
 
无论如何,它的阅读层,并创建它们,并将其设置为当前。
 
我想添加的是,它从我的线型目录中读取线型。。。
 
看一下附带的lisp。
 
这是自述文件。
 
  1. CLAY.lsp ReadMe.txt file.
  2. CLAY allows you to create layer(s) from a master list.  <Master.txt>
  3. Edit the MASTER.txt file to include all of your common layers then run the
  4. CLAY.lsp program in a drawing to instantly create any layer in the master.txt file.
  5. NOTE: CLAY will skip the first three lines inside the MASTER.txt file.

 
这是我的主人。txt文件
 
  1. Layer Name - Do not delete
  2. Color      - Do not delete
  3. Line Type  - Do not delete
  4. STR
  5. 1
  6. Continuous
  7. N

 
请记住,我添加了第四行,因此lisp也可以读取它。。。
现在,如果我想要另一个未加载的线型,lisp将从目录中读取,并在创建时将其创建到图层。
 
这是我写的东西,但是我可以把它放在这个lisp中的什么地方使它起作用呢。
 
  1. (if (not (tblsearch "ltype" LineType))
  2.    (progn
  3.      (setvar "expert" 3)
  4.      (setq ltype_list
  5.      (list
  6.        (strcat "K:\\AIX.lin")
  7.        (strcat "K:\\AIX2.lin")
  8.        (strcat "K:\\AIX3.lin")
  9.      )
  10.      )
  11.      (foreach n ltype_list
  12. (command "linetype" "l" "*" n "")
  13.      )
  14.      (setvar "expert" 0)
  15.    )
  16. )

 
然后在附着的粘土中。lsp lisp添加此
  1. "l" LineType
到(命令“-layer”)-行。。
粘土。lsp
回复

使用道具 举报

15

主题

209

帖子

121

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
163
发表于 2022-7-6 15:06:36 | 显示全部楼层
那么,您要加载给定图层的关联线型吗?这是我用的
  1. ;;; ------------------------------------------------------------------------
  2. ;;;    STDLIB_LOAD_LINETYPE.LSP
  3. ;;;
  4. ;;;    Copyright © December, 2008
  5. ;;;    Timothy G. Spangler
  6. ;;;
  7. ;;;    Permission to use, copy, modify, and distribute this software
  8. ;;;    for any purpose and without fee is hereby granted, provided
  9. ;;;    that the above copyright notice appears in all copies and
  10. ;;;    that both that copyright notice and the limited warranty and
  11. ;;;    restricted rights notice below appear in all supporting
  12. ;;;    documentation.
  13. ;;;
  14. ;;;    STDLIB_LOAD_LINETYPE
  15. ;;;
  16. ;;;                 Description:
  17. ;;;                        Called from a menu pulldown or rightclick menu
  18. ;;;                * (STDLIB_LOAD_LINETYPE <LINETYPE>)
  19. ;;;                <LINETYPE>                        =        STRING        =        Valid linetype
  20. ;;;
  21. ;;;                        Returns:
  22. ;;;                                T if found and loaded otherwise nil
  23. ;;;
  24. ;;; ------------------------------------------------------------------------
  25. ;;; MAIN FUNCTION ;;;;;;;;;;;;;;;;;;;;;;;;;
  26. (defun STDLIB_LOAD_LINETYPE (Linetype / OldCmdEcho LineFiles FullFile Found OpenFile CurrentLine LinePath Result)
  27. ;; Set system variables
  28. (setq OldCmdEcho (getvar "CMDECHO"))
  29. (setvar "CMDECHO" 0)
  30. ;; Load linetype
  31. (if (not (tblsearch "LTYPE" Linetype))
  32.         (progn
  33.                 ;; Check each search path for a .lin file
  34.                 (foreach Path (STR->LIST (getenv "ACAD") ";")
  35.                         (if (setq LineFiles (vl-directory-files Path "*.lin"))
  36.                                 (progn
  37.                                         (foreach File LineFiles
  38.                                                 (setq FullFile (cons (strcat Path "\" File) FullFile))
  39.                                         )
  40.                                         (setq Found (cons Path Found))
  41.                                 )
  42.                         )
  43.                 )
  44.                 ;; Read each line file found and check for the linetype
  45.                 (foreach LineFile FullFile
  46.                         (setq OpenFile (open LineFile "r"))
  47.                         (while (setq CurrentLine (read-line OpenFile))
  48.                                 (if (wcmatch (strcase CurrentLine) (strcat "*" (strcase LineType) "*"))
  49.                                         (setq LinePath Linefile)
  50.                                 )
  51.                         )
  52.                         (close OpenFile)
  53.                 )
  54.                 ;; Load result
  55.                 (if LinePath       
  56.                         (setq Result T)                                       
  57.                         (setq Result nil)
  58.                 )
  59.         )
  60. )
  61. (if Result
  62.         (command "-linetype" "load" Linetype LinePath "")
  63. )
  64. ;; Reset system
  65. (setvar "CMDECHO" OldCmdEcho)
  66. ;; Send Result
  67. Result
  68. )
  69. (princ)

 
只要它是在一个。lin文件应该加载到您的支持路径中。我还没有遇到任何问题。
 
HTH公司
回复

使用道具 举报

31

主题

107

帖子

76

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
155
发表于 2022-7-6 15:28:41 | 显示全部楼层
我觉得很酷,尽管我想使用特定路径中的线型
如上所述。。。
 
我也很难将这两者联系起来
 
这是整个过程的代码:
 
  1. ;;;--- CLAY.lsp - Create layer(s) from a Master List [ Master.txt ]
  2. ;;;
  3. ;;;
  4. ;;;--- Created on 2/27/04 by Jeffery P Sanders
  5. ;;;
  6. ;;;
  7. ;;;--- Modified on 5/3/05
  8. ;;;
  9. ;;;
  10. ;;;
  11. ;;;--- Please read the txt file CLAY_README.txt
  12. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  13. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  14. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   Sort Function   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  15. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  16. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  17. ;;;--- Usage (srt list)
  18. ;;;
  19. (defun srt(alist / n)(setq lcup nil rcup nil)
  20. (defun cts(a b)
  21. (cond
  22.   ((> a b)t)
  23.   ((= a b )t)
  24.   (t nil)
  25. ))
  26. (foreach n alist
  27. (while (and rcup(cts n(car rcup)))(setq lcup(cons(car rcup)lcup)rcup(cdr rcup)))
  28.   (while (and lcup(cts(car lcup)n))(setq rcup(cons(car lcup)rcup)lcup(cdr lcup)))
  29.   (setq rcup(cons n rcup))
  30. )
  31. (append(reverse lcup)rcup)
  32. )
  33. ;;;;;;;;;;;;;;;;;;;;;;;;;;;  End of Sort Function  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  34. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  35. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  36. ;;;;;;;;;;;;;;;;; Function to save the dialog box settings  ;;;;;;;;;;;;;;;;;;;;;;;
  37. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  38. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  39. (defun saveVars()
  40. ;;;--- Setup a list to hold the selected items
  41. (setq layList(list))
  42. ;;;--- Save the list setting
  43. (setq readlist(get_tile "layerlist"))
  44. ;;;--- Setup a variable to run through the list
  45. (setq count 1)
  46. ;;;--- Cycle through the list getting all of the selected items
  47. (while (setq item (read readlist))
  48.    (setq layList(append layList (list (nth item layerList))))
  49.    (while
  50.      (and
  51.        (/= " " (substr readlist count 1))
  52.        (/= ""  (substr readlist count 1))
  53.      )
  54.      (setq count (1+ count))
  55.    )
  56.    (setq readlist (substr readlist count))
  57. )
  58. )
  59. ;;;;;;;;;;;;;;;;;;;;;;; End of saving settings from dialog box ;;;;;;;;;;;;;;;;;;;;;
  60. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  61. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  62. ;;;;;;    Function to get a list of all layer names   ;;;;;;;;
  63. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  64. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  65. (defun getLayerInfo()
  66. ;;;--- Set up an empty list
  67. (setq layerList(list))
  68. ;;;--- Open the text file
  69. (if (findfile "MASTER.txt")
  70.    (progn
  71.      (if (setq fil(open (findfile "MASTER.txt") "r"))
  72.        (progn
  73.          ;;;--- Skip the first three lines        
  74.          (read-line fil)
  75.          (read-line fil)
  76.          (read-line fil)
  77.          ;;;--- Read the lines of data in the text file
  78.          (while (setq a (read-line fil))
  79.            ;;;--- Get the color
  80.            (setq b(read-line fil))
  81.            ;;;--- Get the linetype
  82.            (setq c(read-line fil))
  83. (setq d(read-line fil))
  84.            ;;;--- Add the data to the list
  85.            (setq layerList
  86.              (append
  87.                layerList
  88.                (list (list a b c d))
  89.              )
  90.            )
  91.          )
  92.          ;;;--- Close the file.
  93.          (close fil)
  94.        )
  95.      )
  96.    )
  97. )
  98. ;;;--- Sort the list
  99. ;(setq layerList(srt layerList))
  100. layerList
  101. )
  102. ;;;;;;;;;;;;;;;;;;;;;; End of layer listing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  103. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  104. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  105. ;;;;;;;;888;;;;;;;888;;;;;;;;;;888;;;;;;;;;;;8888888;;;;;;8888;;;888;;;;;;;;;;;;
  106. ;;;;;;;;8888;;;;;8888;;;;;;;;;88888;;;;;;;;;;;;888;;;;;;;;88888;;888;;;;;;;;;;;;
  107. ;;;;;;;;88888;;;88888;;;;;;;;888;888;;;;;;;;;;;888;;;;;;;;888888;888;;;;;;;;;;;;
  108. ;;;;;;;;888888;888888;;;;;;;888;;;888;;;;;;;;;;888;;;;;;;;888;888888;;;;;;;;;;;;
  109. ;;;;;;;;888;88888;888;;;;;;88888888888;;;;;;;;;888;;;;;;;;888;;88888;;;;;;;;;;;;
  110. ;;;;;;;;888;;888;;888;;;;;888;;;;;;;888;;;;;;8888888;;;;;;888;;;8888;;;;;;;;;;;;
  111. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  112. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  113. ;;;;;;;;;;;;;;;;;;;888;;;;;;;;;;;;888888888;;;;;;;;888888888;;;;;;;;;;;;;;;;;;;;
  114. ;;;;;;;;;;;;;;;;;;88888;;;;;;;;;;;888;;;888;;;;;;;;888;;;888;;;;;;;;;;;;;;;;;;;;
  115. ;;;;;;;;;;;;;;;;;888;888;;;;;;;;;;888;;;888;;;;;;;;888;;;888;;;;;;;;;;;;;;;;;;;;
  116. ;;;;;;;;;;;;;;;;888;;;888;;;;;;;;;888888888;;;;;;;;888888888;;;;;;;;;;;;;;;;;;;;
  117. ;;;;;;;;;;;;;;;88888888888;;;;;;;;888;;;;;;;;;;;;;;888;;;;;;;;;;;;;;;;;;;;;;;;;;
  118. ;;;;;;;;;;;;;;888;;;;;;;888;;;;;;;888;;;;;;;;;;;;;;888;;;;;;;;;;;;;;;;;;;;;;;;;;
  119. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  120. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  121. (defun C:CLAY(/ layerList)
  122. ;;;--- Turn off the command echo
  123. (setvar "cmdecho" 0)
  124. ;;;--- Preset an exit string
  125. (setq alertStr "\n CLAY.lsp Complete!")
  126. ;;;--- Get the layer names
  127. (setq layerList(getLayerInfo))
  128. ;;;--- If a master list was found
  129. (if layerList
  130.    (progn
  131.      ;;;--- Load the DCL file
  132.      (setq dcl_id (load_dialog "CLAY.dcl"))
  133.      ;;;--- See if the dialog box is already loaded
  134.      (if (not (new_dialog "CLAY" dcl_id))
  135.        (progn
  136.          (alert "The CLAY.DCL file was not found!")
  137.          (exit)
  138.        )
  139.      )
  140.      ;;;--- Get the layer names
  141.      (setq layNames(list))
  142.      (foreach a layerList
  143.        (setq layNames(append layNames(list (car a))))
  144.      )
  145.      ;;;--- Add the layer names to the dialog box
  146.      (start_list "layerlist" 3)
  147.      (mapcar 'add_list layNames)
  148.      (end_list)
  149.      ;;;--- If an action event occurs, do this function
  150.      (action_tile "cancel" "(setq ddiag 1)(done_dialog)")
  151.      (action_tile "accept" "(setq ddiag 2)(saveVars)(done_dialog)")
  152.      ;;;--- Display the dialog box
  153.      (start_dialog)
  154.      ;;;--- If the cancel button was pressed
  155.      (if (= ddiag 1)
  156.        ;;;--- Set an exit message
  157.        (setq alertStr "\n \n ...CLAY Cancelled. \n ")
  158.      )
  159.      ;;;--- If the "Okay" button was pressed
  160.      (if (= ddiag 2)
  161.        (progn
  162.          ;;;--- If layers were selected from the dialog box
  163.          (if(> (length layList) 0)
  164.            (progn
  165.              ;;;--- Cycle through each layer selected
  166.              (foreach a layList
  167.                ;;;--- If the layer does not exist
  168.                (if(not(tblsearch "LAYER" (car a)))
  169.                  (progn
  170. (if (not (tblsearch "ltype" Linetype))
  171.    (progn
  172.      (setvar "expert" 3)
  173.      (setq ltype_lista
  174.      (list
  175.        (strcat "K:\\CAD\\Linetypes\\AIX.lin")
  176. (strcat "K:\\CAD\\Linetypes\\AIX2.lin")
  177.      )
  178.      )
  179.      (foreach n ltype_lista
  180. (command "linetype" "l" "*" n "")
  181.      )
  182.      (setvar "expert" 0)
  183.    )
  184. )
  185.                    ;;;--- Creat the layer
  186.                    (command "-layer" "new" (car a) "C" (cadr a) (car a) "L" Linetype (car a) "p" d (car a) "s" (car a) "" "")
  187.                    (princ "\nCreated Layer  - ")
  188.                    (princ (car a))
  189.                  )
  190.                  ;;;--- Else the layer already exist so modify it's properties
  191.                  (progn
  192.                    ;;;--- Modify the layer
  193.                    (command "-layer" "C" (cadr a) (car a) "L" Linetype (car a) "p" d (car a) "s" (car a)"" "")
  194.                    (princ "\nModified Layer - ")
  195.                    (princ (car a))
  196.                  )
  197.                )
  198.              )
  199.            )
  200.          )
  201.        )
  202.      )
  203.      ;;;--- Print the exit message
  204.      (princ alertStr)
  205.    )
  206.    ;;;--- If a master list was not generated, inform the user
  207.    (progn
  208.       (setq alertStr "The MASTER list was not found.\nMake sure the file [ MASTER.txt ] is in your search\npath and try again!")
  209.       (setq alertStr (strcat alertStr "\n\nThe master list must be in this format:\n\nLayerName\nColor\nLineType"))
  210.       (setq alertStr (strcat alertStr "\nLayerName\nColor\nLineType\nect.\n\nNote: The program will skip the first three lines."))
  211.       (alert alertStr)
  212.    )
  213. )
  214. ;;;--- reset the command echo
  215. (setvar "cmdecho" 1)
  216. ;;;--- suppress the last echo for a clean exit
  217. (princ)
  218. )  

 
选中上面的创建层。。。
 
这是我的主人。txt文件
STR公司
1.
AIX_品牌-EI30
N
回复

使用道具 举报

31

主题

107

帖子

76

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
155
发表于 2022-7-6 15:43:13 | 显示全部楼层
会是这样吗??
取自粘土。lsp
 
 
  1.               ;;;--- Cycle through each layer selected
  2.              (foreach a layList
  3. (if (not (tblsearch "ltype" [color=red](caddr a))[/color]
  4.    (progn   
  5.      (setvar "expert" 3)
  6.      (setq ltype_lista
  7.      (list
  8.        (strcat "K:\\CAD\\Linetypes\\AIX1.lin")
  9.      )
  10.      )
  11.      (foreach n ltype_lista
  12. (command "linetype" "l" "*" n "")
  13.      )
  14.      (setvar "expert" 0)
  15.    )
  16. ))
回复

使用道具 举报

31

主题

107

帖子

76

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
155
发表于 2022-7-6 15:50:48 | 显示全部楼层
我解决了这个问题。。。
 
这样地::
 
  1. ;;;--- CLAY.lsp - Create layer(s) from a Master List [ Master.txt ]
  2. ;;;
  3. ;;;
  4. ;;;--- Created on 2/27/04 by Jeffery P Sanders
  5. ;;;
  6. ;;;
  7. ;;;--- Modified on 5/3/05
  8. ;;;
  9. ;;;
  10. ;;;
  11. ;;;--- Please read the txt file CLAY_README.txt
  12. (defun Skapalinje ()
  13. (if (not (tblsearch "ltype" (caddr a) ))
  14.    (progn   
  15.      (setvar "expert" 3)
  16.      (setq ltype_lista
  17.      (list
  18.        (strcat "K:\\CAD\\AIX-meny-2008\\Linjetyper\\AIX_brand.lin")
  19. (strcat "K:\\CAD\\AIX-meny-2008\\Linjetyper\\AIX_DetaljSnitt.lin")
  20. (strcat "K:\\CAD\\AIX-meny-2008\\Linjetyper\\AIX_konnektion.lin")
  21. (strcat "K:\\CAD\\AIX-meny-2008\\Linjetyper\\AIX_PktStreck.lin")
  22. (strcat "K:\\CAD\\AIX-meny-2008\\Linjetyper\\AIX_streckad.lin")
  23. (strcat "K:\\CAD\\AIX-meny-2008\\Linjetyper\\AIX_systemlinjer.lin")
  24.      )
  25.      )
  26.      (foreach n ltype_lista
  27. (command "linetype" "l" "*" n "")
  28.      )
  29.      (setvar "expert" 0)
  30.    )
  31. )
  32. )
  33. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  34. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  35. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   Sort Function   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  36. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  37. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  38. ;;;--- Usage (srt list)
  39. ;;;
  40. (defun srt(alist / n)(setq lcup nil rcup nil)
  41. (defun cts(a b)
  42. (cond
  43.   ((> a b)t)
  44.   ((= a b )t)
  45.   (t nil)
  46. ))
  47. (foreach n alist
  48. (while (and rcup(cts n(car rcup)))(setq lcup(cons(car rcup)lcup)rcup(cdr rcup)))
  49.   (while (and lcup(cts(car lcup)n))(setq rcup(cons(car lcup)rcup)lcup(cdr lcup)))
  50.   (setq rcup(cons n rcup))
  51. )
  52. (append(reverse lcup)rcup)
  53. )
  54. ;;;;;;;;;;;;;;;;;;;;;;;;;;;  End of Sort Function  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  55. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  56. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  57. ;;;;;;;;;;;;;;;;; Function to save the dialog box settings  ;;;;;;;;;;;;;;;;;;;;;;;
  58. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  59. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  60. (defun saveVars()
  61. ;;;--- Setup a list to hold the selected items
  62. (setq layList(list))
  63. ;;;--- Save the list setting
  64. (setq readlist(get_tile "layerlist"))
  65. ;;;--- Setup a variable to run through the list
  66. (setq count 1)
  67. ;;;--- Cycle through the list getting all of the selected items
  68. (while (setq item (read readlist))
  69.    (setq layList(append layList (list (nth item layerList))))
  70.    (while
  71.      (and
  72.        (/= " " (substr readlist count 1))
  73.        (/= ""  (substr readlist count 1))
  74.      )
  75.      (setq count (1+ count))
  76.    )
  77.    (setq readlist (substr readlist count))
  78. )
  79. )
  80. ;;;;;;;;;;;;;;;;;;;;;;; End of saving settings from dialog box ;;;;;;;;;;;;;;;;;;;;;
  81. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  82. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  83. ;;;;;;    Function to get a list of all layer names   ;;;;;;;;
  84. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  85. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  86. (defun getLayerInfo()
  87. ;;;--- Set up an empty list
  88. (setq layerList(list))
  89. ;;;--- Open the text file
  90. (if (findfile "K:\\CAD\\AIX-meny-2008\\Lisp\\lager\\MASTERV.txt")
  91.    (progn
  92.      (if (setq fil(open (findfile "K:\\CAD\\AIX-meny-2008\\Lisp\\lager\\MASTERV.txt") "r"))
  93.        (progn
  94.          ;;;--- Skip the first three lines        
  95.          (read-line fil)
  96.          (read-line fil)
  97.          (read-line fil)
  98.          ;;;--- Read the lines of data in the text file
  99.          (while (setq a (read-line fil))
  100.       
  101.            ;;;--- Get the color
  102.            (setq b(read-line fil))
  103.    
  104.            ;;;--- Get the linetype
  105.            (setq c(read-line fil))
  106.    
  107. (setq d(read-line fil))
  108. (setq e(read-line fil))
  109.            ;;;--- Add the data to the list
  110.            (setq layerList
  111.              (append
  112.                layerList
  113.                (list (list a b c d e))
  114.              )
  115.            )
  116.          )
  117.          ;;;--- Close the file.
  118.          (close fil)
  119.        )
  120.      )
  121.    )
  122. )
  123. ;;;--- Sort the list
  124. ;(setq layerList(srt layerList))
  125. layerList
  126. )
  127. ;;;;;;;;;;;;;;;;;;;;;; End of layer listing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  128. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  129. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  130. ;;;;;;;;888;;;;;;;888;;;;;;;;;;888;;;;;;;;;;;8888888;;;;;;8888;;;888;;;;;;;;;;;;
  131. ;;;;;;;;8888;;;;;8888;;;;;;;;;88888;;;;;;;;;;;;888;;;;;;;;88888;;888;;;;;;;;;;;;
  132. ;;;;;;;;88888;;;88888;;;;;;;;888;888;;;;;;;;;;;888;;;;;;;;888888;888;;;;;;;;;;;;
  133. ;;;;;;;;888888;888888;;;;;;;888;;;888;;;;;;;;;;888;;;;;;;;888;888888;;;;;;;;;;;;
  134. ;;;;;;;;888;88888;888;;;;;;88888888888;;;;;;;;;888;;;;;;;;888;;88888;;;;;;;;;;;;
  135. ;;;;;;;;888;;888;;888;;;;;888;;;;;;;888;;;;;;8888888;;;;;;888;;;8888;;;;;;;;;;;;
  136. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  137. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  138. ;;;;;;;;;;;;;;;;;;;888;;;;;;;;;;;;888888888;;;;;;;;888888888;;;;;;;;;;;;;;;;;;;;
  139. ;;;;;;;;;;;;;;;;;;88888;;;;;;;;;;;888;;;888;;;;;;;;888;;;888;;;;;;;;;;;;;;;;;;;;
  140. ;;;;;;;;;;;;;;;;;888;888;;;;;;;;;;888;;;888;;;;;;;;888;;;888;;;;;;;;;;;;;;;;;;;;
  141. ;;;;;;;;;;;;;;;;888;;;888;;;;;;;;;888888888;;;;;;;;888888888;;;;;;;;;;;;;;;;;;;;
  142. ;;;;;;;;;;;;;;;88888888888;;;;;;;;888;;;;;;;;;;;;;;888;;;;;;;;;;;;;;;;;;;;;;;;;;
  143. ;;;;;;;;;;;;;;888;;;;;;;888;;;;;;;888;;;;;;;;;;;;;;888;;;;;;;;;;;;;;;;;;;;;;;;;;
  144. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  145. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  146. (defun C:AIX:SKAPALAGERV(/ layerList)
  147. ;;;--- Turn off the command echo
  148. (setvar "cmdecho" 0)
  149. ;;;--- Preset an exit string
  150. (setq alertStr "\n Skapa lager Klar!")
  151. ;;;--- Get the layer names
  152. (setq layerList(getLayerInfo))
  153. ;;;--- If a master list was found
  154. (if layerList
  155.    (progn
  156.      ;;;--- Load the DCL file
  157.      (setq dcl_id (load_dialog "K:\\CAD\\AIX-meny-2008\\Lisp\\lager\\CLAY.dcl"))
  158.      ;;;--- See if the dialog box is already loaded
  159.      (if (not (new_dialog "CLAYV" dcl_id))
  160.        (progn
  161.          (alert "The CLAY.DCL fil var ej fuinnen!!")
  162.          (exit)
  163.        )
  164.      )
  165.      ;;;--- Get the layer names
  166.      (setq layNames(list))
  167.      (foreach a layerList
  168.        (setq layNames(append layNames(list (car a))))
  169.      )
  170.      ;;;--- Add the layer names to the dialog box
  171.      (start_list "layerlist" 3)
  172.      (mapcar 'add_list layNames)
  173.      (end_list)
  174.      ;;;--- If an action event occurs, do this function
  175.      (action_tile "cancel" "(setq ddiag 1)(done_dialog)")
  176.      (action_tile "accept" "(setq ddiag 2)(saveVars)(done_dialog)")
  177.      ;;;--- Display the dialog box
  178.      (start_dialog)
  179.      ;;;--- If the cancel button was pressed
  180.      (if (= ddiag 1)
  181.        ;;;--- Set an exit message
  182.        (setq alertStr "\n \n ...Skapa Lager Avbruten. \n ")
  183.      )
  184.      ;;;--- If the "Okay" button was pressed
  185.      (if (= ddiag 2)
  186.        (progn
  187.            
  188.          ;;;--- If layers were selected from the dialog box
  189.          (if(> (length layList) 0)
  190.            (progn
  191.              ;;;--- Cycle through each layer selected
  192.              (foreach a layList
  193. (SkapaLinje)
  194.                ;;;--- If the layer does not exist
  195.                (if(not(tblsearch "LAYER" (cadr a)))
  196.                  (progn
  197.      
  198.                    ;;;--- Creat the layer
  199.                    (command "-layer" "new" (cadr a) "C" (cadddr a) (cadr a) "Lt" (caddr a) (cadr a) "p" e (cadr a) "s" (cadr a) "")
  200.                    (princ "\nSkapad Lager - ")
  201.                    (princ (cadr a))
  202.                  )
  203.                  ;;;--- Else the layer already exist so modify it's properties
  204.                  (progn
  205.                    ;;;--- Modify the layer
  206.                    (command "-layer" "C" (cadddr a) (cadr a) "Lt" (caddr a) (cadr a) "p" e (cadr a) "s" (cadr a) "")
  207.                    (princ "\nModifierad Lager - ")
  208.                    (princ (cadr a))
  209.                  )
  210.                )
  211.              )
  212.            )
  213.          )
  214.        )
  215.      )
  216.      ;;;--- Print the exit message
  217.      (princ alertStr)
  218.    )
  219.    ;;;--- If a master list was not generated, inform the user
  220.    (progn
  221.       (setq alertStr "The MASTER list was not found.\nMake sure the file [ MASTER.txt ] is in your search\npath and try again!")
  222.       (setq alertStr (strcat alertStr "\n\nThe master list must be in this format:\n\nLayerName\nColor\nLineType"))
  223.       (setq alertStr (strcat alertStr "\nLayerName\nColor\nLineType\nect.\n\nNote: The program will skip the first three lines."))
  224.       (alert alertStr)
  225.    )
  226. )
  227. ;;;--- reset the command echo
  228. (setvar "cmdecho" 1)
  229. ;;;--- suppress the last echo for a clean exit
  230. (princ)
  231. )  

 
尽管我读过ferom帮助文件,AutoLISP支持car和cdr的连接,深度可达四级。我的txt文件中有5行,最后一行告诉我是否要打印图层。
 
我怎样才能使它发挥作用。。。
一开始我在代码中
(setq e(…作为最后一行…第五行)
在lisp中的命令中
(命令……“p”e(cadr a),该命令应使选定的图层可绘制或不可绘制。。
 
尽管我收到错误消息“选项键盘无效”
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-5 00:18 , Processed in 0.361923 second(s), 62 queries .

© 2020-2025 乐筑天下

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