Jump to content

clay (read linetype)


au-s

Recommended Posts

Hello,

 

I modified this little lisp a bit downloading it from the internet.

 

Anyways Its reading layers and creates them and set them current.

 

What I want to add is that it reads linetypes from my linetype directory...

 

Take a look at the attached lisp.

 

Here is the readme file.

 

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.

 

Here is my Master.txt

 

Layer Name - Do not delete
Color      - Do not delete
Line Type  - Do not delete
STR
1
Continuous
N

 

Rememeber I added the fourth line so the lisp reads it as well...

Now, if I want to have another linetype that is not loaded the lisp reads from a directory and creates it to the layer while making it.

 

This is something I wrote but where can I put it in this lisp to make it functional.

 

(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)
   )
 )

 

Then in the attached CLAY.lsp lisp add this

"l" LineType

to the (command "-layer") - line..

CLAY.lsp

Link to comment
Share on other sites

So you want to load the associated linetype for a given layer? Here is what I use

;;; ------------------------------------------------------------------------
;;;    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)

 

As long as it is in a .lin file in your support path it should load it. I haven't had any problems yet.

 

HTH

Link to comment
Share on other sites

I find it cool, allthough I want to use linetypes from my specific path

stated above...

 

I have also problem connecting those two together :)

 

This is the code the whole thing:

 

;;;--- 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)
)  

 

Check above create the layer...

 

This is my MASTER.txt

STR

1

AIX_Brand-EI30

N

Link to comment
Share on other sites

Can it be something like this??

Taken from CLAY.lsp

 

 

              ;;;--- Cycle through each layer selected
             (foreach a layList
 (if (not (tblsearch "ltype" [color=red](caddr a))[/color]
   (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)
   )
 ))

Link to comment
Share on other sites

I solved this one out ...

 

like this ::

 

;;;--- 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)
)  

 

Allthough I read ferom help files that AutoLISP supports concatenations of car and cdr up to four levels deep. I have 5 rows in my txt file and the last one tells if the layer will be printed or not.

 

How can I make it functional...

In the beginning I have in the code

(setq e(... as the last line... fifth

and in the command in the lisp I make

(command ...... "p" e (cadr a) which should make the layer slected plotable or not ..

 

Allthough I get the error message Invalid option keyboard

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...