Hi
I want to use Lisp to me to create line types and layers.
but get one wrong return of the Schedule 2
Thank you
Hallo
Ich will den Lisp nutzen um mir Linientypen und Layer anzulegen.
bekomme aber immer ein falsche Rückgabe von der Liste 2
Danke
; Fehler: Fehlerhafter Argumenttyp: listp 500ER
(defun c:listbox ( / *error* UpdateList data dclfile dclhandle )
;; This program demonstrates how to update a secondary list_box based
;; on user selection from a primary list_box.
;; Example courtesy of Lee Mac © 2010 (www.lee-mac.com)
;; Accompanying DCL File:
(setq dclFile "listboxexample.dcl")
;; Ensure this file resides in an AutoCAD Support Path
(defun *error* ( msg )
;; Error Handler - will unload the dialog
;; from memory should the user decide to hit Esc
(if dclHandle (unload_dialog dclHandle))
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **")))
(princ)
)
(defun UpdateList ( key lst )
;; This function updates the list_box associated with the specified key
;; using the contents of the supplied lst
(start_list key)
(mapcar 'add_list lst)
(end_list)
)
;; Data used to Populate List_Boxes:
;; I've chosen to use this list structure because it suits the data,
;; but there are many other possibilities.
(setq Data
'(
("CATV" ("KOKA F6 TSV" "KOKA 7 OK" "LCD 115" "HF 75 C 2-0_9-1 Flex" "KOKA ACE 412 SB" "KOKA ACE 500 SB"
"KOKA ACE 750 SB" "LCM 14" "500er" "7er" "LWL TFC 50" "Ausser Betrieb" "60V" "7er_CATV"))
("LWL" ("10xCAT6" "2xCAT6" "CAT5" "CAT6" "CAT7" "Ethernet 10Mbit" "Ethernet 100Mbit" "Ethernet 1GBit"
"USB" "LWL-Singlemode 8F" "LWL-Singlemode" "LWL-Muldimode" "RS232" "Profi-Bus" "Telefon"
"DVI" "X2X" "Can-Bus" "230V USV" "LWL OM3 MM TS 12x50" "VPN" "DUO 4TB"))
("F-YAY" ("F-YAY 2x2x0.6" "F-YAY 3x2x0.6" "F-YAY 5x2x0.6" "F-YAY 6x2x0.6" "F-YAY 10x2x0.6"
"F-YAY 2x2x0.8" "F-YAY 3x2x0.8" "F-YAY 5x2x0.8" "F-YAY 6x2x0.8" "F-YAY 10x2x0.8"
"F-YAY 20x2x0.6" "F-YAY 30x2x0.6" "F-YAY 50x2x0.6" "F-YAY 100x2x0.6"
"F-YAY 2x2x0.6 verdr."))
)
)
;; Start of Main Routine
;; Lots of Error Trapping to make sure the Dialog Loads:
(cond
( (<= (setq dclHandle (load_dialog dclFile)) 0)
(princ "\n--> DCL File not Found.")
)
( (not (new_dialog "listboxexample" dclHandle))
(setq dclHandle (unload_dialog dclHandle))
(princ "\n--> Dialog Definition not Found.")
)
( t
;; Dialog Loaded Successfully.
(or *Make* (setq *Make* "0"))
(or *Model* (setq *Model* "0"))
;; Set up some default selections, for the first-time running of the program.
;; The variables *Make* & *Model* are intended to be global and hence will
;; remember the user's last selections.
;; Populate the List_Boxes:
;; List_Box 'lst1'
(UpdateList "lst1" (mapcar 'car Data))
(set_tile "lst1" *Make*)
;; List_Box 'lst2'
(UpdateList "lst2" (cadr (nth (atoi *Make*) Data)))
(set_tile "lst2" *Model*)
;; Action_tile Statements:
;; These control what happens when the user interacts with a tile in the dialog.
(action_tile "lst1"
(strcat
"(UpdateList \"lst2\" (setq lst2 (cadr (nth (atoi (setq *Make* $value)) Data))))"
"(setq *Model*"
" (set_tile \"lst2\""
" (if (< (atoi *Model*) (length lst2)) *Model* \"0\")"
" )"
")"
)
)
;; Here, when the user selects an item from 'lst1', the UpdateList subfunction
;; is fired to update the items in list_box 'lst2'.
;; list_box 'lst2' is also set to the value of *Model* if the index is
;; available for the selected item, else the first item is selected.
;; Note that $value is a string containg the index of the item
;; that the user has selected.
(action_tile "lst2" "(setq *Model* $value)")
;; Dialog setup, lets start it:
(start_dialog)
(setq dclHandle (unload_dialog dclHandle))
)
)
(princ)
)
(setq gw (atoi *Model*))
(setq LaLi (nth gw lst2))
(setq LT (read LaLi))
(LM:LoadLinetypes LT)
(command "_-LAYER" "m" lali "Lty" lali lali "fa" "1" lali "ls" "0.30" lali "se" lali "")
;;-------------------=={ Load Linetypes }==-------------------;;
;; ;;
;; Attempts to load a list of linetypes from any linetype ;;
;; definition files (.lin) found in the ACAD Support Path ;;
;;------------------------------------------------------------;;
;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;; Arguments: ;;
;; lts - list of linetypes to load ;;
;;------------------------------------------------------------;;
;; Returns: T if linetypes loaded successfully, else nil ;;
;;------------------------------------------------------------;;
(defun LM:LoadLinetypes ( lts / acapp acdoc aclts aclin ) (vl-load-com)
(setq acdoc (vla-get-ActiveDocument (setq acapp (vlax-get-acad-object)))
aclts (vla-get-Linetypes acdoc)
)
(setq aclin
(apply 'append
(mapcar '(lambda ( directory ) (vl-directory-files directory "*.lin" 1))
(LM:str->lst
(vla-get-SupportPath (vla-get-Files (vla-get-Preferences acapp))) ";"
)
)
)
)
(apply 'and
(mapcar
(function
(lambda ( lt )
(or (tblsearch "LTYPE" lt)
(vl-some
(function
(lambda ( lin )
(vl-catch-all-apply 'vla-load (list aclts lt lin)) (tblsearch "LTYPE" lt)
)
)
aclin
)
)
)
)
lts
)
)
)
(defun LM:str->lst ( str del / pos )
(if (setq pos (vl-string-search del str))
(vl-remove "" (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del)))
(list str)
)
)