dworrall
1st Jul 2005, 07:04 pm
Can anyone help me figure out why this doesn't work every time?
I use it to get x,y coordinates. I use AutoCAD 2006.
any help would be greatly appreciated.
here is the program
(defun c:map2 ()
(command "style" "Arial" "Arial" "" "" "" "N" "N")
(command "layer" "m" "coords" "")
(command "layer" "c" "2" "coords" "")
(command "osnap" "int,cen,endp")
(setq origin (getpoint "\nSelect point for origin of drawing: "))
(command "osnap" "off")
(command "move" "all" "" origin "0.00,0.00")
(command "zoom" "e")
(command "osnap" "int,cen,end")
(setq mapscale (getreal "\nEnter the drawing scale: 1 inch = "))
(setq wellfile (getfiled "Select file for coordinate list" "" "txt" 1))
(setq a (open wellfile "w"))
(textpage)
(print)
(print)
(print "This program will print the location of all blocks with a")
(print "'NAME' attribute. It will then prompt the user to select")
(print "any additional items for the coordinate list")
(setq go (getreal "\nPress return to continue"))
(setq b (open "tplatter.txt" "w")) ;creates template file
(write-line "NAME C015000" b) ;for ATTEXT command
(write-line "BL:X N009002" b)
(write-line "BL:Y N009002" b)
(close b)
(command "attext" "sdf" "tplatter.txt" "blinfo.txt")
(setq c (open "blinfo.txt" "r")) ;Exports block attributes to
(setq fileline (read-line c)) ;blinfo.txt file
(setq i 0)
(while fileline
(setq name1 (substr fileline 1 15)) ;Opens blinfo.txt file and
(setq x1 (substr fileline 16 9)) ;extracts necessary information,
(setq x1 (/ (distof x1 2) 12)) ;transforming coordinates into
(setq y1 (substr fileline 25 9)) ;decimal units and writing result
(setq y1 (/ (distof y1 2) 12)) ;to specified coordinate file
(setq newline (strcat name1 " " (rtos x1 2 1) "' " (rtos y1 2 1) "'"))
(write-line newline a)
(coordout x1 y1)
(setq fileline (read-line c))
(setq i (1+ i))
)
(close c)
(textscr)
(textpage)
(print)
(print (strcat (itoa i) " items were entered into the coordinate list."))
(print)
(initget 1 "Y N")
(setq stopgo (getkword "Would you like to select more items for the coordinate list? (Y/N) "))
(if (= stopgo "Y") (individselect))
(if (= stopgo "N") (graphscr))
(close a)
)
here is the error I get...
Command: _appload map2.lsp successfully loaded.
Command:
Command:
Command: map2
style Enter name of text style or [?] <ARIAL>: Arial
Existing style. Full font name = Arial
Specify full font name or font filename (TTF or SHX) <ARIAL.TTF>: Arial Specify
height of text <0'-0">: Specify width factor <1>:
Specify obliquing angle <0.00>: Display text backwards? [Yes/No] <N>: N Display
text upside-down? [Yes/No] <N>: N
"ARIAL" is now the current text style.
Command: layer
Current layer: "0"
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
m
Enter name for new layer (becomes the current layer) <0>: coords Enter an
option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
Command: layer
Current layer: "coords"
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
c
New color [Truecolor/COlorbook] : 2
Enter name list of layer(s) for color 2 (yellow) <coords>: coords Enter an
option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
Command: osnap
Current osnap modes: End,Mid,Cen,Quad,Int,Ins
Enter list of object snap modes: int,cen,endp
Command:
Select point for origin of drawing: 0,0
osnap
Current osnap modes: End,Cen,Int
Enter list of object snap modes: off
Command: move
Select objects: all 281 found
7 were not in current space.
Select objects:
Specify base point or [Displacement] <Displacement>: Specify second point or
<use first point as displacement>: 0.00,0.00
Command: zoom
Specify corner of window, enter a scale factor (nX or nXP), or
[All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: e
Command: osnap Enter list of object snap modes: int,cen,end
Command:
Enter the drawing scale: 1 inch = 60
"This program will print the location of all blocks with a"
"'NAME' attribute. It will then prompt the user to select"
"any additional items for the coordinate list"
Press return to continue
attext Enter extraction type or enable object selection [Cdf/Sdf/Dxf/Objects]
<C>: sdf
Enter template file name <\\seneca7\darrick$\tplatter.txt>: tplatter.txt Enter
extract file name <M:\CASEY\6188707A>: blinfo.txt 0 records in extract file.
Command: ; error: bad argument type: FILE nil
Command:
I use it to get x,y coordinates. I use AutoCAD 2006.
any help would be greatly appreciated.
here is the program
(defun c:map2 ()
(command "style" "Arial" "Arial" "" "" "" "N" "N")
(command "layer" "m" "coords" "")
(command "layer" "c" "2" "coords" "")
(command "osnap" "int,cen,endp")
(setq origin (getpoint "\nSelect point for origin of drawing: "))
(command "osnap" "off")
(command "move" "all" "" origin "0.00,0.00")
(command "zoom" "e")
(command "osnap" "int,cen,end")
(setq mapscale (getreal "\nEnter the drawing scale: 1 inch = "))
(setq wellfile (getfiled "Select file for coordinate list" "" "txt" 1))
(setq a (open wellfile "w"))
(textpage)
(print)
(print)
(print "This program will print the location of all blocks with a")
(print "'NAME' attribute. It will then prompt the user to select")
(print "any additional items for the coordinate list")
(setq go (getreal "\nPress return to continue"))
(setq b (open "tplatter.txt" "w")) ;creates template file
(write-line "NAME C015000" b) ;for ATTEXT command
(write-line "BL:X N009002" b)
(write-line "BL:Y N009002" b)
(close b)
(command "attext" "sdf" "tplatter.txt" "blinfo.txt")
(setq c (open "blinfo.txt" "r")) ;Exports block attributes to
(setq fileline (read-line c)) ;blinfo.txt file
(setq i 0)
(while fileline
(setq name1 (substr fileline 1 15)) ;Opens blinfo.txt file and
(setq x1 (substr fileline 16 9)) ;extracts necessary information,
(setq x1 (/ (distof x1 2) 12)) ;transforming coordinates into
(setq y1 (substr fileline 25 9)) ;decimal units and writing result
(setq y1 (/ (distof y1 2) 12)) ;to specified coordinate file
(setq newline (strcat name1 " " (rtos x1 2 1) "' " (rtos y1 2 1) "'"))
(write-line newline a)
(coordout x1 y1)
(setq fileline (read-line c))
(setq i (1+ i))
)
(close c)
(textscr)
(textpage)
(print)
(print (strcat (itoa i) " items were entered into the coordinate list."))
(print)
(initget 1 "Y N")
(setq stopgo (getkword "Would you like to select more items for the coordinate list? (Y/N) "))
(if (= stopgo "Y") (individselect))
(if (= stopgo "N") (graphscr))
(close a)
)
here is the error I get...
Command: _appload map2.lsp successfully loaded.
Command:
Command:
Command: map2
style Enter name of text style or [?] <ARIAL>: Arial
Existing style. Full font name = Arial
Specify full font name or font filename (TTF or SHX) <ARIAL.TTF>: Arial Specify
height of text <0'-0">: Specify width factor <1>:
Specify obliquing angle <0.00>: Display text backwards? [Yes/No] <N>: N Display
text upside-down? [Yes/No] <N>: N
"ARIAL" is now the current text style.
Command: layer
Current layer: "0"
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
m
Enter name for new layer (becomes the current layer) <0>: coords Enter an
option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
Command: layer
Current layer: "coords"
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
c
New color [Truecolor/COlorbook] : 2
Enter name list of layer(s) for color 2 (yellow) <coords>: coords Enter an
option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
Command: osnap
Current osnap modes: End,Mid,Cen,Quad,Int,Ins
Enter list of object snap modes: int,cen,endp
Command:
Select point for origin of drawing: 0,0
osnap
Current osnap modes: End,Cen,Int
Enter list of object snap modes: off
Command: move
Select objects: all 281 found
7 were not in current space.
Select objects:
Specify base point or [Displacement] <Displacement>: Specify second point or
<use first point as displacement>: 0.00,0.00
Command: zoom
Specify corner of window, enter a scale factor (nX or nXP), or
[All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: e
Command: osnap Enter list of object snap modes: int,cen,end
Command:
Enter the drawing scale: 1 inch = 60
"This program will print the location of all blocks with a"
"'NAME' attribute. It will then prompt the user to select"
"any additional items for the coordinate list"
Press return to continue
attext Enter extraction type or enable object selection [Cdf/Sdf/Dxf/Objects]
<C>: sdf
Enter template file name <\\seneca7\darrick$\tplatter.txt>: tplatter.txt Enter
extract file name <M:\CASEY\6188707A>: blinfo.txt 0 records in extract file.
Command: ; error: bad argument type: FILE nil
Command: