粘土(读取线型)
你好我修改了这个小Lisp程序的一点下载它从互联网上。
无论如何,它的阅读层,并创建它们,并将其设置为当前。
我想添加的是,它从我的线型目录中读取线型。。。
看一下附带的lisp。
这是自述文件。
CLAY.lsp ReadMe.txt file.
CLAY allows you to create layer(s) from a master list.<Master.txt>
Edit the MASTER.txt file to include all of your common layers then run the
CLAY.lsp program in a drawing to instantly create any layer in the master.txt file.
NOTE: CLAY will skip the first three lines inside the MASTER.txt file.
这是我的主人。txt文件
Layer Name - Do not delete
Color - Do not delete
Line Type- Do not delete
STR
1
Continuous
N
请记住,我添加了第四行,因此lisp也可以读取它。。。
现在,如果我想要另一个未加载的线型,lisp将从目录中读取,并在创建时将其创建到图层。
这是我写的东西,但是我可以把它放在这个lisp中的什么地方使它起作用呢。
(if (not (tblsearch "ltype" LineType))
(progn
(setvar "expert" 3)
(setq ltype_list
(list
(strcat "K:\\AIX.lin")
(strcat "K:\\AIX2.lin")
(strcat "K:\\AIX3.lin")
)
)
(foreach n ltype_list
(command "linetype" "l" "*" n "")
)
(setvar "expert" 0)
)
)
然后在附着的粘土中。lsp lisp添加此
"l" LineType到(命令“-layer”)-行。。
粘土。lsp 那么,您要加载给定图层的关联线型吗?这是我用的
;;; ------------------------------------------------------------------------
;;; STDLIB_LOAD_LINETYPE.LSP
;;;
;;; Copyright © December, 2008
;;; Timothy G. Spangler
;;;
;;; Permission to use, copy, modify, and distribute this software
;;; for any purpose and without fee is hereby granted, provided
;;; that the above copyright notice appears in all copies and
;;; that both that copyright notice and the limited warranty and
;;; restricted rights notice below appear in all supporting
;;; documentation.
;;;
;;; STDLIB_LOAD_LINETYPE
;;;
;;; Description:
;;; Called from a menu pulldown or rightclick menu
;;; * (STDLIB_LOAD_LINETYPE <LINETYPE>)
;;; <LINETYPE> = STRING = Valid linetype
;;;
;;; Returns:
;;; T if found and loaded otherwise nil
;;;
;;; ------------------------------------------------------------------------
;;; MAIN FUNCTION ;;;;;;;;;;;;;;;;;;;;;;;;;
(defun STDLIB_LOAD_LINETYPE (Linetype / OldCmdEcho LineFiles FullFile Found OpenFile CurrentLine LinePath Result)
;; Set system variables
(setq OldCmdEcho (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
;; Load linetype
(if (not (tblsearch "LTYPE" Linetype))
(progn
;; Check each search path for a .lin file
(foreach Path (STR->LIST (getenv "ACAD") ";")
(if (setq LineFiles (vl-directory-files Path "*.lin"))
(progn
(foreach File LineFiles
(setq FullFile (cons (strcat Path "\\" File) FullFile))
)
(setq Found (cons Path Found))
)
)
)
;; Read each line file found and check for the linetype
(foreach LineFile FullFile
(setq OpenFile (open LineFile "r"))
(while (setq CurrentLine (read-line OpenFile))
(if (wcmatch (strcase CurrentLine) (strcat "*" (strcase LineType) "*"))
(setq LinePath Linefile)
)
)
(close OpenFile)
)
;; Load result
(if LinePath
(setq Result T)
(setq Result nil)
)
)
)
(if Result
(command "-linetype" "load" Linetype LinePath "")
)
;; Reset system
(setvar "CMDECHO" OldCmdEcho)
;; Send Result
Result
)
(princ)
只要它是在一个。lin文件应该加载到您的支持路径中。我还没有遇到任何问题。
HTH公司 我觉得很酷,尽管我想使用特定路径中的线型
如上所述。。。
我也很难将这两者联系起来
这是整个过程的代码:
;;;--- CLAY.lsp - Create layer(s) from a Master List [ Master.txt ]
;;;
;;;
;;;--- Created on 2/27/04 by Jeffery P Sanders
;;;
;;;
;;;--- Modified on 5/3/05
;;;
;;;
;;;
;;;--- Please read the txt file CLAY_README.txt
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Sort Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;--- Usage (srt list)
;;;
(defun srt(alist / n)(setq lcup nil rcup nil)
(defun cts(a b)
(cond
((> a b)t)
((= a b )t)
(t nil)
))
(foreach n alist
(while (and rcup(cts n(car rcup)))(setq lcup(cons(car rcup)lcup)rcup(cdr rcup)))
(while (and lcup(cts(car lcup)n))(setq rcup(cons(car lcup)rcup)lcup(cdr lcup)))
(setq rcup(cons n rcup))
)
(append(reverse lcup)rcup)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;End of Sort Function;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;; Function to save the dialog box settings;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun saveVars()
;;;--- Setup a list to hold the selected items
(setq layList(list))
;;;--- Save the list setting
(setq readlist(get_tile "layerlist"))
;;;--- Setup a variable to run through the list
(setq count 1)
;;;--- Cycle through the list getting all of the selected items
(while (setq item (read readlist))
(setq layList(append layList (list (nth item layerList))))
(while
(and
(/= " " (substr readlist count 1))
(/= ""(substr readlist count 1))
)
(setq count (1+ count))
)
(setq readlist (substr readlist count))
)
)
;;;;;;;;;;;;;;;;;;;;;;; End of saving settings from dialog box ;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; Function to get a list of all layer names ;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun getLayerInfo()
;;;--- Set up an empty list
(setq layerList(list))
;;;--- Open the text file
(if (findfile "MASTER.txt")
(progn
(if (setq fil(open (findfile "MASTER.txt") "r"))
(progn
;;;--- Skip the first three lines
(read-line fil)
(read-line fil)
(read-line fil)
;;;--- Read the lines of data in the text file
(while (setq a (read-line fil))
;;;--- Get the color
(setq b(read-line fil))
;;;--- Get the linetype
(setq c(read-line fil))
(setq d(read-line fil))
;;;--- Add the data to the list
(setq layerList
(append
layerList
(list (list a b c d))
)
)
)
;;;--- Close the file.
(close fil)
)
)
)
)
;;;--- Sort the list
;(setq layerList(srt layerList))
layerList
)
;;;;;;;;;;;;;;;;;;;;;; End of layer listing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;888;;;;;;;888;;;;;;;;;;888;;;;;;;;;;;8888888;;;;;;8888;;;888;;;;;;;;;;;;
;;;;;;;;8888;;;;;8888;;;;;;;;;88888;;;;;;;;;;;;888;;;;;;;;88888;;888;;;;;;;;;;;;
;;;;;;;;88888;;;88888;;;;;;;;888;888;;;;;;;;;;;888;;;;;;;;888888;888;;;;;;;;;;;;
;;;;;;;;888888;888888;;;;;;;888;;;888;;;;;;;;;;888;;;;;;;;888;888888;;;;;;;;;;;;
;;;;;;;;888;88888;888;;;;;;88888888888;;;;;;;;;888;;;;;;;;888;;88888;;;;;;;;;;;;
;;;;;;;;888;;888;;888;;;;;888;;;;;;;888;;;;;;8888888;;;;;;888;;;8888;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;888;;;;;;;;;;;;888888888;;;;;;;;888888888;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;88888;;;;;;;;;;;888;;;888;;;;;;;;888;;;888;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;888;888;;;;;;;;;;888;;;888;;;;;;;;888;;;888;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;888;;;888;;;;;;;;;888888888;;;;;;;;888888888;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;88888888888;;;;;;;;888;;;;;;;;;;;;;;888;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;888;;;;;;;888;;;;;;;888;;;;;;;;;;;;;;888;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun C:CLAY(/ layerList)
;;;--- Turn off the command echo
(setvar "cmdecho" 0)
;;;--- Preset an exit string
(setq alertStr "\n CLAY.lsp Complete!")
;;;--- Get the layer names
(setq layerList(getLayerInfo))
;;;--- If a master list was found
(if layerList
(progn
;;;--- Load the DCL file
(setq dcl_id (load_dialog "CLAY.dcl"))
;;;--- See if the dialog box is already loaded
(if (not (new_dialog "CLAY" dcl_id))
(progn
(alert "The CLAY.DCL file was not found!")
(exit)
)
)
;;;--- Get the layer names
(setq layNames(list))
(foreach a layerList
(setq layNames(append layNames(list (car a))))
)
;;;--- Add the layer names to the dialog box
(start_list "layerlist" 3)
(mapcar 'add_list layNames)
(end_list)
;;;--- If an action event occurs, do this function
(action_tile "cancel" "(setq ddiag 1)(done_dialog)")
(action_tile "accept" "(setq ddiag 2)(saveVars)(done_dialog)")
;;;--- Display the dialog box
(start_dialog)
;;;--- If the cancel button was pressed
(if (= ddiag 1)
;;;--- Set an exit message
(setq alertStr "\n \n ...CLAY Cancelled. \n ")
)
;;;--- If the "Okay" button was pressed
(if (= ddiag 2)
(progn
;;;--- If layers were selected from the dialog box
(if(> (length layList) 0)
(progn
;;;--- Cycle through each layer selected
(foreach a layList
;;;--- If the layer does not exist
(if(not(tblsearch "LAYER" (car a)))
(progn
(if (not (tblsearch "ltype" Linetype))
(progn
(setvar "expert" 3)
(setq ltype_lista
(list
(strcat "K:\\CAD\\Linetypes\\AIX.lin")
(strcat "K:\\CAD\\Linetypes\\AIX2.lin")
)
)
(foreach n ltype_lista
(command "linetype" "l" "*" n "")
)
(setvar "expert" 0)
)
)
;;;--- Creat the layer
(command "-layer" "new" (car a) "C" (cadr a) (car a) "L" Linetype (car a) "p" d (car a) "s" (car a) "" "")
(princ "\nCreated Layer- ")
(princ (car a))
)
;;;--- Else the layer already exist so modify it's properties
(progn
;;;--- Modify the layer
(command "-layer" "C" (cadr a) (car a) "L" Linetype (car a) "p" d (car a) "s" (car a)"" "")
(princ "\nModified Layer - ")
(princ (car a))
)
)
)
)
)
)
)
;;;--- Print the exit message
(princ alertStr)
)
;;;--- If a master list was not generated, inform the user
(progn
(setq alertStr "The MASTER list was not found.\nMake sure the file [ MASTER.txt ] is in your search\npath and try again!")
(setq alertStr (strcat alertStr "\n\nThe master list must be in this format:\n\nLayerName\nColor\nLineType"))
(setq alertStr (strcat alertStr "\nLayerName\nColor\nLineType\nect.\n\nNote: The program will skip the first three lines."))
(alert alertStr)
)
)
;;;--- reset the command echo
(setvar "cmdecho" 1)
;;;--- suppress the last echo for a clean exit
(princ)
)
选中上面的创建层。。。
这是我的主人。txt文件
STR公司
1.
AIX_品牌-EI30
N 会是这样吗??
取自粘土。lsp
;;;--- Cycle through each layer selected
(foreach a layList
(if (not (tblsearch "ltype" (caddr a))
(progn
(setvar "expert" 3)
(setq ltype_lista
(list
(strcat "K:\\CAD\\Linetypes\\AIX1.lin")
)
)
(foreach n ltype_lista
(command "linetype" "l" "*" n "")
)
(setvar "expert" 0)
)
)) 我解决了这个问题。。。
这样地::
;;;--- CLAY.lsp - Create layer(s) from a Master List [ Master.txt ]
;;;
;;;
;;;--- Created on 2/27/04 by Jeffery P Sanders
;;;
;;;
;;;--- Modified on 5/3/05
;;;
;;;
;;;
;;;--- Please read the txt file CLAY_README.txt
(defun Skapalinje ()
(if (not (tblsearch "ltype" (caddr a) ))
(progn
(setvar "expert" 3)
(setq ltype_lista
(list
(strcat "K:\\CAD\\AIX-meny-2008\\Linjetyper\\AIX_brand.lin")
(strcat "K:\\CAD\\AIX-meny-2008\\Linjetyper\\AIX_DetaljSnitt.lin")
(strcat "K:\\CAD\\AIX-meny-2008\\Linjetyper\\AIX_konnektion.lin")
(strcat "K:\\CAD\\AIX-meny-2008\\Linjetyper\\AIX_PktStreck.lin")
(strcat "K:\\CAD\\AIX-meny-2008\\Linjetyper\\AIX_streckad.lin")
(strcat "K:\\CAD\\AIX-meny-2008\\Linjetyper\\AIX_systemlinjer.lin")
)
)
(foreach n ltype_lista
(command "linetype" "l" "*" n "")
)
(setvar "expert" 0)
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Sort Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;--- Usage (srt list)
;;;
(defun srt(alist / n)(setq lcup nil rcup nil)
(defun cts(a b)
(cond
((> a b)t)
((= a b )t)
(t nil)
))
(foreach n alist
(while (and rcup(cts n(car rcup)))(setq lcup(cons(car rcup)lcup)rcup(cdr rcup)))
(while (and lcup(cts(car lcup)n))(setq rcup(cons(car lcup)rcup)lcup(cdr lcup)))
(setq rcup(cons n rcup))
)
(append(reverse lcup)rcup)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;End of Sort Function;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;; Function to save the dialog box settings;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun saveVars()
;;;--- Setup a list to hold the selected items
(setq layList(list))
;;;--- Save the list setting
(setq readlist(get_tile "layerlist"))
;;;--- Setup a variable to run through the list
(setq count 1)
;;;--- Cycle through the list getting all of the selected items
(while (setq item (read readlist))
(setq layList(append layList (list (nth item layerList))))
(while
(and
(/= " " (substr readlist count 1))
(/= ""(substr readlist count 1))
)
(setq count (1+ count))
)
(setq readlist (substr readlist count))
)
)
;;;;;;;;;;;;;;;;;;;;;;; End of saving settings from dialog box ;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; Function to get a list of all layer names ;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun getLayerInfo()
;;;--- Set up an empty list
(setq layerList(list))
;;;--- Open the text file
(if (findfile "K:\\CAD\\AIX-meny-2008\\Lisp\\lager\\MASTERV.txt")
(progn
(if (setq fil(open (findfile "K:\\CAD\\AIX-meny-2008\\Lisp\\lager\\MASTERV.txt") "r"))
(progn
;;;--- Skip the first three lines
(read-line fil)
(read-line fil)
(read-line fil)
;;;--- Read the lines of data in the text file
(while (setq a (read-line fil))
;;;--- Get the color
(setq b(read-line fil))
;;;--- Get the linetype
(setq c(read-line fil))
(setq d(read-line fil))
(setq e(read-line fil))
;;;--- Add the data to the list
(setq layerList
(append
layerList
(list (list a b c d e))
)
)
)
;;;--- Close the file.
(close fil)
)
)
)
)
;;;--- Sort the list
;(setq layerList(srt layerList))
layerList
)
;;;;;;;;;;;;;;;;;;;;;; End of layer listing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;888;;;;;;;888;;;;;;;;;;888;;;;;;;;;;;8888888;;;;;;8888;;;888;;;;;;;;;;;;
;;;;;;;;8888;;;;;8888;;;;;;;;;88888;;;;;;;;;;;;888;;;;;;;;88888;;888;;;;;;;;;;;;
;;;;;;;;88888;;;88888;;;;;;;;888;888;;;;;;;;;;;888;;;;;;;;888888;888;;;;;;;;;;;;
;;;;;;;;888888;888888;;;;;;;888;;;888;;;;;;;;;;888;;;;;;;;888;888888;;;;;;;;;;;;
;;;;;;;;888;88888;888;;;;;;88888888888;;;;;;;;;888;;;;;;;;888;;88888;;;;;;;;;;;;
;;;;;;;;888;;888;;888;;;;;888;;;;;;;888;;;;;;8888888;;;;;;888;;;8888;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;888;;;;;;;;;;;;888888888;;;;;;;;888888888;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;88888;;;;;;;;;;;888;;;888;;;;;;;;888;;;888;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;888;888;;;;;;;;;;888;;;888;;;;;;;;888;;;888;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;888;;;888;;;;;;;;;888888888;;;;;;;;888888888;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;88888888888;;;;;;;;888;;;;;;;;;;;;;;888;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;888;;;;;;;888;;;;;;;888;;;;;;;;;;;;;;888;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun C:AIX:SKAPALAGERV(/ layerList)
;;;--- Turn off the command echo
(setvar "cmdecho" 0)
;;;--- Preset an exit string
(setq alertStr "\n Skapa lager Klar!")
;;;--- Get the layer names
(setq layerList(getLayerInfo))
;;;--- If a master list was found
(if layerList
(progn
;;;--- Load the DCL file
(setq dcl_id (load_dialog "K:\\CAD\\AIX-meny-2008\\Lisp\\lager\\CLAY.dcl"))
;;;--- See if the dialog box is already loaded
(if (not (new_dialog "CLAYV" dcl_id))
(progn
(alert "The CLAY.DCL fil var ej fuinnen!!")
(exit)
)
)
;;;--- Get the layer names
(setq layNames(list))
(foreach a layerList
(setq layNames(append layNames(list (car a))))
)
;;;--- Add the layer names to the dialog box
(start_list "layerlist" 3)
(mapcar 'add_list layNames)
(end_list)
;;;--- If an action event occurs, do this function
(action_tile "cancel" "(setq ddiag 1)(done_dialog)")
(action_tile "accept" "(setq ddiag 2)(saveVars)(done_dialog)")
;;;--- Display the dialog box
(start_dialog)
;;;--- If the cancel button was pressed
(if (= ddiag 1)
;;;--- Set an exit message
(setq alertStr "\n \n ...Skapa Lager Avbruten. \n ")
)
;;;--- If the "Okay" button was pressed
(if (= ddiag 2)
(progn
;;;--- If layers were selected from the dialog box
(if(> (length layList) 0)
(progn
;;;--- Cycle through each layer selected
(foreach a layList
(SkapaLinje)
;;;--- If the layer does not exist
(if(not(tblsearch "LAYER" (cadr a)))
(progn
;;;--- Creat the layer
(command "-layer" "new" (cadr a) "C" (cadddr a) (cadr a) "Lt" (caddr a) (cadr a) "p" e (cadr a) "s" (cadr a) "")
(princ "\nSkapad Lager - ")
(princ (cadr a))
)
;;;--- Else the layer already exist so modify it's properties
(progn
;;;--- Modify the layer
(command "-layer" "C" (cadddr a) (cadr a) "Lt" (caddr a) (cadr a) "p" e (cadr a) "s" (cadr a) "")
(princ "\nModifierad Lager - ")
(princ (cadr a))
)
)
)
)
)
)
)
;;;--- Print the exit message
(princ alertStr)
)
;;;--- If a master list was not generated, inform the user
(progn
(setq alertStr "The MASTER list was not found.\nMake sure the file [ MASTER.txt ] is in your search\npath and try again!")
(setq alertStr (strcat alertStr "\n\nThe master list must be in this format:\n\nLayerName\nColor\nLineType"))
(setq alertStr (strcat alertStr "\nLayerName\nColor\nLineType\nect.\n\nNote: The program will skip the first three lines."))
(alert alertStr)
)
)
;;;--- reset the command echo
(setvar "cmdecho" 1)
;;;--- suppress the last echo for a clean exit
(princ)
)
尽管我读过ferom帮助文件,AutoLISP支持car和cdr的连接,深度可达四级。我的txt文件中有5行,最后一行告诉我是否要打印图层。
我怎样才能使它发挥作用。。。
一开始我在代码中
(setq e(…作为最后一行…第五行)
在lisp中的命令中
(命令……“p”e(cadr a),该命令应使选定的图层可绘制或不可绘制。。
尽管我收到错误消息“选项键盘无效”
页:
[1]