the_lone_wolf
16-11-07, 01:17 PM
Anyone out there know anything about LISP? specifically autolisp. this little routine i wrote:
(defun C:implay ()
(if (setq file (open "H:/AutoCAD Tools/Linetypes/layers.txt" "r"))
(progn
(while (read-line file)
(setq
linestring (read-line file)
layername (substr linestring 1 30)
layercolour (atoi (substr linestring 31 10))
layerlinetype (substr linestring 41 20)
layerlineweight (substr linestring 61 10)
) ;setq
(command "-layer" "M" layername "L" layerlinetype "" "LW" layerlineweight "" "C" layercolour "" "")
) ;while
) ;progn
(princ "\n Error - File not found!")
) ;if
(princ)
) ;defun
should import layer names, linetypes, weights and clolours into a new autocad drawingfrom a text file "layers.txt," :
EAVES 210 LOCAL_GOVERNMENT 0.13
G528_M_CASTINGS 7 Continuous 0.18
G910_M_SITE_INFO 7 Continuous 0.18
G917_M_EXIST_BLDG 174 Continuous 0.35
G923_M_SPOT_HEIGHT 7 Continuous 0.18
G930_M_LAND_DRAINAGE 10 COUNTY_BOUNDARY_2 0.18
G936_M_VALVES 7 Continuous 0.18
G941_M_TREE_EXIST 90 Continuous 0.18
G950_M_ROADS_CHANGESURFACE 25 Continuous 0.25
G950_M_ROADS_PAVING 7 EASEMENT_2 0.25
G952_M_KERBS 170 Continuous 0.25
G952_M_KERBS_DROP 170 DOT_2_0MM 0.25
G967_M_COMMS 7 Continuous 0.18
G970_M_HARDSCAPE 7 Continuous 0.18
G971_M_FENCING 75 FENCE 0.25
G978_M_LIGHTING 7 Continuous 0.18
G995_M_VEGETATION 84 HEDGE_1 0.25
ROADMARKINGS-CENTRELINE 7 04 0.25
ROADMARKINGS-GENERIC 7 Continuous 0.18
TEXT 7 Continuous 0.20
Z030_M_GRIDS 7 Continuous 0.20
but it crashes giving the error:
; error: bad argument type: stringp nil
when entering the layername to apply the colour to. it only does this however, when trying to apply it to the TEXT layer, all the ones previously work fine, and if i remove the TEXT line from layers.txt it completes just fine
i even tried adding a caveat to the script to change the layername "TEXT " to "TEXT" immideately after the main group of set quotients:
(if (= layername "TEXT ") (setq layername (substr layername 1 4))) ;if
but this didn't change anything
any ideas? nerd/geek jokes on the back of an x-men comic please:smt023
(defun C:implay ()
(if (setq file (open "H:/AutoCAD Tools/Linetypes/layers.txt" "r"))
(progn
(while (read-line file)
(setq
linestring (read-line file)
layername (substr linestring 1 30)
layercolour (atoi (substr linestring 31 10))
layerlinetype (substr linestring 41 20)
layerlineweight (substr linestring 61 10)
) ;setq
(command "-layer" "M" layername "L" layerlinetype "" "LW" layerlineweight "" "C" layercolour "" "")
) ;while
) ;progn
(princ "\n Error - File not found!")
) ;if
(princ)
) ;defun
should import layer names, linetypes, weights and clolours into a new autocad drawingfrom a text file "layers.txt," :
EAVES 210 LOCAL_GOVERNMENT 0.13
G528_M_CASTINGS 7 Continuous 0.18
G910_M_SITE_INFO 7 Continuous 0.18
G917_M_EXIST_BLDG 174 Continuous 0.35
G923_M_SPOT_HEIGHT 7 Continuous 0.18
G930_M_LAND_DRAINAGE 10 COUNTY_BOUNDARY_2 0.18
G936_M_VALVES 7 Continuous 0.18
G941_M_TREE_EXIST 90 Continuous 0.18
G950_M_ROADS_CHANGESURFACE 25 Continuous 0.25
G950_M_ROADS_PAVING 7 EASEMENT_2 0.25
G952_M_KERBS 170 Continuous 0.25
G952_M_KERBS_DROP 170 DOT_2_0MM 0.25
G967_M_COMMS 7 Continuous 0.18
G970_M_HARDSCAPE 7 Continuous 0.18
G971_M_FENCING 75 FENCE 0.25
G978_M_LIGHTING 7 Continuous 0.18
G995_M_VEGETATION 84 HEDGE_1 0.25
ROADMARKINGS-CENTRELINE 7 04 0.25
ROADMARKINGS-GENERIC 7 Continuous 0.18
TEXT 7 Continuous 0.20
Z030_M_GRIDS 7 Continuous 0.20
but it crashes giving the error:
; error: bad argument type: stringp nil
when entering the layername to apply the colour to. it only does this however, when trying to apply it to the TEXT layer, all the ones previously work fine, and if i remove the TEXT line from layers.txt it completes just fine
i even tried adding a caveat to the script to change the layername "TEXT " to "TEXT" immideately after the main group of set quotients:
(if (= layername "TEXT ") (setq layername (substr layername 1 4))) ;if
but this didn't change anything
any ideas? nerd/geek jokes on the back of an x-men comic please:smt023