Hi Forum,
i try to push my 2D Workflow with some Lisp Routines.
The following Routine imports new Blocks with filled out Attributes multiple times from an txt File. Works fine so far.
But i have some questions. I use the German Version of ACAD so...
1. After the routine is finished a message comes up in the console "; Fehler: Fehlerhafter Argumenttyp: stringp nil" Whereīs the Problem? I did not find anything. The Routine works as i wish.
2. How can i use Chars in a String e.g. ä,ü. and so on? see this row (command "layer" "m" "BLOCKS" "FA" "T" "0,255,0" "" "L" "Continuous" "" "") i have to define the colour in RGB, because it dont work with "GRÜN" for green
3. What i have to do, to insert a block from a Folder on my hdd, and not from my existing blocks in my drawing?
4. What i have to do, to update blockattributes or Blocks if something has changed in my txt file
5. What i have to do, to use the table entities from a sql db and not from a txtfile?
Thanks a lot!
;~******************************************************************************
;~* FILE NAME:BLOCKSIN.lsp
;~* FUNCTION: INSERT BLOCKS WITH ATTRIBUTES INTO DRAWINGS AND FILL ATTRIBUTES
;~* WRITTEN BY: SOUI21
;~* REVISIONS: Version Alpha:
;~******************************************************************************
;#1a----------- layer layer & text & text settings settings ------------
;create and set ;create and set layer layer to blocks to blocks - create romans text style
(command "layer" "m" "BLOCKS" "FA" "T" "0,255,0" "" "L" "Continuous" "" "") (command "stil" "romans" "romans" "0.125" "1" "" "" "" "")
;#1b----------- DEFINING VARIABLE SETTINGS
; capture user settings
(setq atd
(getvar "attdia")) ;attribute dialog box
; change to what settings need to be
(setvar "osmode" 0) ;osnap to none (setvar "attreq" 1) ;ask for attribute values on insert (setvar "attdia" 0) ;issues command prompts for data
;set starting points for inserts and not nil
(setq xval
1.0) ;initial x (setq yval
30.0) ;initial y (setq eqdata
"notnil") ;dummy variable
;prompt user for the location of the data file
(princ "\n Please Enter Name of Data File - Include the path and extension")
;#3----------- *** while motor data ***
(setq eqdatal
(open eqdataf
"r")) ;open data file
(while (/= eqdata
nil) ;while data continue
(setq eqdat
(sparse eqdatac
";")) ;#3a---------- do not do not change anything 3 - 3a
(setq EQPID
(nth 0 eqdat
) ;EQUIPMENT ID NEWIO
(nth 2 eqdat
) ;DESCRIPTION BN
(nth 3 eqdat
) ;BLOCKNAME
) ;end setq
;insert tag & text
(setq blkinpnt
(list xval yval
)) ;create xy insert point for tag
(command "_insert" BN blkinpnt
"1" "" "" EQPID EQTAG NEWIO
) ;set new point
(setq yval
(- yval
30.0)) ;y Point
(setq xval
(+ xval
30.0)) )
) ;End if
) ;end while
(close "eqdataf") ;CLOSES THE OPEN DATA FILE
) ;end defun
;------------------------------
;SPARSE Function (from bryan)
(defun sparse
(s asep
/ slen ll temp cnt
) (< cnt slen)
(if (= (substr s cnt
1) asep
) ;test if character is a seperator (setq ll
(cons temp ll
) ;then adds var to list temp "")
) ;end if
) ;end while
) ;return list ll in order data was read
;------------------------------------