View Full Version : Help w/ fixing code at startup
cadd4la
2006-02-12, 02:47 AM
Hello everyone,
I am having two problems with this lisp code.
The first is that it stop the complete loading of my Startup.lsp file, but the linetype.lsp still works.
I have this code running from a pull-down menu and on my CUI dialog box for this menu on the Macro I have set as ^C^C(Matchline) for the matchline & ^C^C(Limitline) for the Limitline.
This is my AutoCAD text window after startup
Customization file loaded successfully. Customization Group: EDG
Customization file loaded successfully. Customization Group: ACAD
Customization file loaded successfully. Customization Group: EXPRESS
Customization file loaded successfully. Customization Group: SPURGE
Regenerating model.
Command:
AutoCAD Express Tools Copyright © 2002-2004 Autodesk, Inc.
acaddoc.lisp - begin
KyleC menu - begin
KyleC menu Ver. 1.2.3 (01/25/06) loaded and ready to use - © copyright 2006
Eden Design Group
acaddoc.lisp Ver. 3.0 (01/19/06) loaded and ready to use - © copyright 2006
Eden Design Group
EDGAutoCOM.lsp - Version 02/10/06 loaded and ready to use - © copyright 2006
Eden Design Group
EDGSettings.lsp - Version 01/20/06 loaded - © copyright 2004-2006 Eden Design
Group
No scan images or no layer named scan.
Reactors Loaded; error: bad function: "MATCHLINE" <--Problem area
AutoCAD menu utilities loaded.
Command: COMMANDLINE
Command: properties
Command: SHEETSET
Command: TOOLPALETTES
This is what the AutoCAD text window should look after startup.
Customization file loaded successfully. Customization Group: EDG
Customization file loaded successfully. Customization Group: ACAD
Customization file loaded successfully. Customization Group: EXPRESS
Customization file loaded successfully. Customization Group: SPURGE
Regenerating model.
Command:
AutoCAD Express Tools Copyright © 2002-2004 Autodesk, Inc.
acaddoc.lisp - begin
KyleC menu - begin
KyleC menu Ver. 1.2.3 (01/25/06) loaded and ready to use - © copyright 2006
Eden Design Group
acaddoc.lisp Ver. 3.0 (01/19/06) loaded and ready to use - © copyright 2006
Eden Design Group
EDGAutoCOM.lsp - Version 02/10/06 loaded and ready to use - © copyright 2006
Eden Design Group
EDGSettings.lsp - Version 01/20/06 loaded - © copyright 2004-2006 Eden Design
Group
No scan images or no layer named scan.
Reactors Loaded
EDGLocal Startup function Version 02/10/06 completed - © copyright 2004-2006
Eden Design Group
AutoCAD menu utilities loaded.
Command: COMMANDLINE
Command: properties
Command: TOOLPALETTES
Command: SHEETSET
The second problem is the error trapping is not working right - if I press the "esc" key it will stay on the layer that the code is design to make & place the line on as well as it leaves the pline width at what the linetype is set at.
I not to good a coding error trapping so I was hoping that someone would look at that part and fix it for me?
;******** MATCHLINE ********
;=================================================================================================
(defun MATCHLINE ()
;; error function & Routine Exit
(defun *ERROR* (MSG)
(if
(not
(member
MSG
'("console break"
"Function cancelled"
"quit / exit abort"
""
)
)
)
(princ (strcat "nError: " MSG))
) ; endif
;;reset all variables here
(if USEROS
(setvar "osmode" USEROS)
)
(if USERCMD
(setvar "CMDECHO" USERCMD)
)
(setq USEROS NIL
USERCMD NIL
)
) ;end error function (defun *Error* (msg) ; embedded defun
(setq USEROS (getvar "osmode")
USERCMD (getvar "CMDECHO")
userlay (getvar "CLAYER");<- this can be any variable name that you want except for protect LISP keywords. userlay
userpwid (getvar "plinewid") ;<- Get current Pline width setting
)
(setvar "cmdecho" 0) ;<- Change the echo of commands to the textscreen to off
(princ "MAKES A MATCHLINE LINE") ;<- Prints on the command line what the code does.
(setvar "osmode" 129) ;<- Sets the OSNAP "END" & "PER" to on.
(setvar "PLINEWID" 0.125) ;<- Set pline width 1/8"
;(setvar "CELTSCALE" 1) ;<- Set entity base ltscale to 1.
(command "layer" "MAKE" "L-MATCHLINE" "color" "2" "" "Ltype" "dashed" "" "") ;<- Creates a layer named "L-LMT-OF-WRK" with the color yellow and the linetype as dash.
(command "_pline") ;<- execute pline command
(while (> (getvar "cmdactive") 0) ;<- while the user has not exited the pline command
(command pause) ;<- place another pause to allow for additional user input
)
(setvar "osmode" useros) ;<- reset changed variables
(setvar "cmdecho" usercmd) ;<- these reset variables would be better suited in its own function
; (setvar "celtscale" userltsc) ;<- search for a save_sys & restore_sys functions
(setvar "CLAYER" userlay) ;<- CLAYER is the system variable, and userlay is the variable name that contains the previous value.
(setvar "plinewid" userpwid) ;<- in the forums.
(princ) ;<- quietly exit
)
;******** LIMITLINE ********
;=================================================================================================
(defun LIMITLINE ()
;; error function & Routine Exit
(defun *ERROR* (MSG)
(if
(not
(member
MSG
'("console break"
"Function cancelled"
"quit / exit abort"
""
)
)
)
(princ (strcat "nError: " MSG))
) ; endif
;;reset all variables here
(if USEROS
(setvar "osmode" USEROS)
)
(if USERCMD
(setvar "CMDECHO" USERCMD)
)
(setq USEROS NIL
USERCMD NIL
)
) ;end error function (defun *Error* (msg) ; embedded defun
(setq USEROS (getvar "osmode")
USERCMD (getvar "CMDECHO")
userpwid (getvar "plinewid") ;<- Get current Pline width setting
userltsc (getvar "CELTSCALE") ;<- Get current entity based ltscale
userlay (getvar "CLAYER");<- this can be any variable name that you want except for protect LISP keywords.
)
(setvar "cmdecho" 0) ;<- Change the echo of commands to the textscreen to off
(princ "MAKES A LIMIT OF WORK LINE") ;<- Prints on the command line what the code does.
(setvar "osmode" 129) ;<- Sets the OSNAP "END" & "PER" to on.
(setvar "PLINEWID" 0.09375) ;<- Set pline width 3/32"
(setvar "CELTSCALE" 0.5) ;<- Set entity base ltscale to 0.5.
(command "layer" "MAKE" "L-LMT-OF-WRK" "color" "2" "" "Ltype" "dashed" "" "") ;<- Creates a layer named "L-LMT-OF-WRK" with the color yellow and the linetype as dash.
(command "_pline") ;<- execute pline command
(while (> (getvar "cmdactive") 0) ;<- while the user has not exited the pline command
(command pause) ;<- place another pause to allow for additional user input
)
(setvar "osmode" useros) ;<- reset changed variables
(setvar "cmdecho" usercmd) ;<- these reset variables would be better suited in its own function
(setvar "celtscale" userltsc) ;<- search for a save_sys & restore_sys functions
(setvar "plinewid" userpwid) ;<- in the forums.
(setvar "CLAYER" userlay) ;<- CLAYER is the system variable, and userlay is the variable name that contains the previous value.
(princ) ;<- quietly exit
)
I hope someone can help me.
Thanks
Kyle C.
Kyle,
Is your MATCHLINE routine loaded prior to your reactor being loaded?
Your ERROR handler does not include a line to reset the layer. You have stored the current layer name within the userlay variable. You will need to add a line in your error handler to reset that system variable based on this variable. I have attached the error handler that I have been using. I picked it up from the AUGI forums.
;;||||||||||||||||||||||||||||||||||
;; Error Handler
;; Function provided by others
;;||||||||||||||||||||||||||||||||||
(defun
*ERROR*
(MSG)
(if (not
(member
MSG
'("Function cancelled" "console break" "quit / exit abort")
) ;_ end of member
) ;_ end of not
(alert MSG)
) ;_ end of if
(RESTORE_SYS)
(command "_.undo" "end")
(princ)
) ;_ end of defun
I also use the system variable save and restore routines found in that post.
;;||||||||||||||||||||||||||||||||||
;; Set and Save System Variables
;; Function provided by others
;;||||||||||||||||||||||||||||||||||
(defun
SAVE_SYS
(SYSVAR)
(setq *SYSVAR* '()) ; global var list of saved values
(repeat (length SYSVAR)
(setq *SYSVAR*
(append
*SYSVAR*
(list (list (car SYSVAR) (getvar (car SYSVAR))))
) ;_ end of append
) ;_ end of setq
(setq SYSVAR (cdr SYSVAR))
) ;_ end of repeat
) ;_ end of defun
;;||||||||||||||||||||||||||||||||||
;; Restore System Variables
;; Function provided by others
;;||||||||||||||||||||||||||||||||||
(defun
RESTORE_SYS
()
(and (listp *SYSVAR*)
(repeat (length *SYSVAR*)
(setvar (caar *SYSVAR*) (cadar *SYSVAR*))
(setq *SYSVAR* (cdr *SYSVAR*))
) ;_ end of repeat
) ;_ end of and
) ;_ end of defun
This is how I call the save system variables routine. You just need to place the system variables that you need to modify within quotes into a list for the routine.
;;__ Save Settings___
(SAVE_SYS '("CMDECHO" "CLAYER" "CECOLOR" "OSMODE")) ;_ end of SAVE_SYS
You would need to add this to the end of the routine to execute the restoration of the system variables.
(RESTORE_SYS)
kennet.sjoberg
2006-02-13, 12:59 AM
. . .I hope someone can help me. . .
I will try . . .
The problem in your startup routine may depend on a missplaced character in the "MATCHLINE" file that is not identical with the code in the forum, check the file or upload the file for investigation please.
The error trapping problem depends on that you are not telling the error handler to reset the layer.
I have scrambled your code ( sorry for that ) so you can see 3 important text blocks...
in the error handler, in the program start, and in the program end
(defun MATCHLINE (/ USERos USERcmd USERlay USERpwid ) ; <- this is same as setq USERos nil USERcmd nil ...
;; errorhandler
(defun *ERROR* (MSG)
(princ (strcat "nError: " MSG ) )
;; Resettings here may be the same as in the end of the Main Program
;; The if statement is good if the USERxx variable is not set
(if USERos (setvar "OSMODE" USERos ) ( ) )
(if USERcmd (setvar "CMDECHO" USERcmd ) ( ) )
(if USERlay (setvar "CLAYER" USERlay ) ( ) )
(if USERpwid (setvar "PLINEWID" USERpwid ) ( ) )
)
;; Settings, in the start of program, take care of all USER variables that are going to change
(setq USERos (getvar "OSMODE" ) )
(setq USERcmd (getvar "CMDECHO" ) )
(setq USERlay (getvar "CLAYER" ) )
(setq USERpwid (getvar "PLINEWID" ) )
(setvar "OSMODE" 129 )
(setvar "CMDECHO" 0 )
(setvar "PLINEWID" 0.125 )
;; Main Program, do the job.
(princ "MAKES A MATCHLINE LINE" )
(command "layer" "MAKE" "L-MATCHLINE" "color" "2" "" "Ltype" "dashed" "" "" )
(command "_pline" )
(while (> (getvar "CMDACTIVE" ) 0 ) (command pause ) )
;; Resettings, should be oposit to Settings
(setvar "OSMODE" USERos )
(setvar "CMDECHO" USERcmd )
(setvar "CLAYER" USERlay )
(setvar "PLINEWID" USERpwid )
(princ)
)
Hope this helps
: ) Happy Computing !
kennet
cadd4la
2006-02-13, 05:59 PM
kennet,
This is the code that is in my startup.lsp file.
(load "Linetypes")
("MATCHLINE") ("LIMITLINE")
I will try . . .
The problem in your startup routine may depend on a missplaced character in the "MATCHLINE" file that is not identical with the code in the forum, check the file or upload the file for investigation please.
I don't really understanding what your showing me with this code? Can you place the parts you changing into my existing code that I posted.
The error trapping problem depends on that you are not telling the error handler to reset the layer.
I have scrambled your code ( sorry for that ) so you can see 3 important text blocks...
in the error handler, in the program start, and in the program end
(defun MATCHLINE (/ USERos USERcmd USERlay USERpwid ) ; <- this is same as setq USERos nil USERcmd nil ...
;; errorhandler
(defun *ERROR* (MSG)
(princ (strcat "nError: " MSG ) )
;; Resettings here may be the same as in the end of the Main Program
;; The if statement is good if the USERxx variable is not set
(if USERos (setvar "OSMODE" USERos ) ( ) )
(if USERcmd (setvar "CMDECHO" USERcmd ) ( ) )
(if USERlay (setvar "CLAYER" USERlay ) ( ) )
(if USERpwid (setvar "PLINEWID" USERpwid ) ( ) )
)
;; Settings, in the start of program, take care of all USER variables that are going to change
(setq USERos (getvar "OSMODE" ) )
(setq USERcmd (getvar "CMDECHO" ) )
(setq USERlay (getvar "CLAYER" ) )
(setq USERpwid (getvar "PLINEWID ") )
(setvar "OSMODE" 129 )
(setvar "CMDECHO" 0 )
(setvar "PLINEWID" 0.125 )
;; Main Program, do the job.
(princ "MAKES A MATCHLINE LINE" )
(command "layer" "MAKE" "L-MATCHLINE" "color" "2" "" "Ltype" "dashed" "" "" )
(command "_pline" )
(while (> (getvar "CMDACTIVE" ) 0 ) (command pause ) )
;; Resettings, should be oposit to Settings
(setvar "OSMODE" USERos )
(setvar "CMDECHO" USERcmd )
(setvar "CLAYER" USERlay )
(setvar "PLINEWID" USERpwid )
(princ)
)
Hope this helps
: ) Happy Computing !
kennet
cadd4la
2006-02-13, 06:04 PM
Opie,
Yes, the linetype.lsp does load before the reactor.lsp
Is your MATCHLINE routine loaded prior to your reactor being loaded?Is this what your talking about?
;******** MATCHLINE ********
;================================================= ================================================
;;||||||||||||||||||||||||||||||||||
;; Error Handler
;; Function provided by others
;;||||||||||||||||||||||||||||||||||
(defun
*ERROR*
(MSG)
(if (not
(member
MSG
'("Function cancelled" "console break" "quit / exit abort")
) ;_ end of member
) ;_ end of not
(alert MSG)
) ;_ end of if
(RESTORE_SYS)
(command "_.undo" "end")
(princ)
) ;_ end of defun
;;||||||||||||||||||||||||||||||||||
;; Set and Save System Variables
;; Function provided by others
;;||||||||||||||||||||||||||||||||||
(defun
SAVE_SYS
(SYSVAR)
(setq *SYSVAR* '()) ; global var list of saved values
(repeat (length SYSVAR)
(setq *SYSVAR*
(append
*SYSVAR*
(list (list (car SYSVAR) (getvar (car SYSVAR))))
) ;_ end of append
) ;_ end of setq
(setq SYSVAR (cdr SYSVAR))
) ;_ end of repeat
) ;_ end of defun
;;||||||||||||||||||||||||||||||||||
;; Restore System Variables
;; Function provided by others
;;||||||||||||||||||||||||||||||||||
(defun
RESTORE_SYS
()
(and (listp *SYSVAR*)
(repeat (length *SYSVAR*)
(setvar (caar *SYSVAR*) (cadar *SYSVAR*))
(setq *SYSVAR* (cdr *SYSVAR*))
) ;_ end of repeat
) ;_ end of and
) ;_ end of defun
(setq USEROS (getvar "osmode")
USERCMD (getvar "CMDECHO")
userlay (getvar "CLAYER");<- this can be any variable name that you want except for protect LISP keywords. userlay
userpwid (getvar "plinewid") ;<- Get current Pline width setting
)
(setvar "cmdecho" 0) ;<- Change the echo of commands to the textscreen to off
(SAVE_SYS '("CMDECHO" "CLAYER" "CECOLOR" "OSMODE")) ;;;__ Save Settings___ _ end of SAVE_SYS
(princ "MAKES A MATCHLINE LINE") ;<- Prints on the command line what the code does.
(setvar "osmode" 129) ;<- Sets the OSNAP "END" & "PER" to on.
(setvar "PLINEWID" 0.125) ;<- Set pline width 1/8"
;(setvar "CELTSCALE" 1) ;<- Set entity base ltscale to 1.
(command "layer" "MAKE" "L-MATCHLINE" "color" "2" "" "Ltype" "dashed" "" "") ;<- Creates a layer named "L-LMT-OF-WRK" with the color yellow and the linetype as dash.
(command "_pline") ;<- execute pline command
(while (> (getvar "cmdactive") 0) ;<- while the user has not exited the pline command
(command pause) ;<- place another pause to allow for additional user input
)
(setvar "osmode" useros) ;<- reset changed variables
(setvar "cmdecho" usercmd) ;<- these reset variables would be better suited in its own function
; (setvar "celtscale" userltsc) ;<- search for a save_sys & restore_sys functions
(setvar "CLAYER" userlay) ;<- CLAYER is the system variable, and userlay is the variable name that contains the previous value.
(setvar "plinewid" userpwid) ;<- in the forums.
(RESTORE_SYS)
(princ) ;<- quietly exit
)
Kyle C.
;******** MATCHLINE ********
;================================================= ================================================
;;||||||||||||||||||||||||||||||||||
;; Error Handler
;; Function provided by others
;;||||||||||||||||||||||||||||||||||
(defun
*ERROR*
(MSG)
(if (not
(member
MSG
'("Function cancelled" "console break" "quit / exit abort")
) ;_ end of member
) ;_ end of not
(alert MSG)
) ;_ end of if
(RESTORE_SYS) ; <-- If an error does occur, the system variables saved with the save_sys routine will be restored.
(command "_.undo" "end")
(princ)
) ;_ end of defun
;;||||||||||||||||||||||||||||||||||
;; Set and Save System Variables
;; Function provided by others
;;||||||||||||||||||||||||||||||||||
(defun
SAVE_SYS
(SYSVAR)
(setq *SYSVAR* '()) ; global var list of saved values
(repeat (length SYSVAR)
(setq *SYSVAR*
(append
*SYSVAR*
(list (list (car SYSVAR) (getvar (car SYSVAR))))
) ;_ end of append
) ;_ end of setq
(setq SYSVAR (cdr SYSVAR))
) ;_ end of repeat
) ;_ end of defun
;;||||||||||||||||||||||||||||||||||
;; Restore System Variables
;; Function provided by others
;;||||||||||||||||||||||||||||||||||
(defun
RESTORE_SYS
()
(and (listp *SYSVAR*)
(repeat (length *SYSVAR*)
(setvar (caar *SYSVAR*) (cadar *SYSVAR*))
(setq *SYSVAR* (cdr *SYSVAR*))
) ;_ end of repeat
) ;_ end of and
) ;_ end of defun
;--------------------------------
;The variables below are not needed if you utilize the save_sys & restore_sys routines.
(setq USEROS (getvar "osmode")
USERCMD (getvar "CMDECHO")
userlay (getvar "CLAYER");<- this can be any variable name that you want except for protect LISP keywords. userlay
userpwid (getvar "plinewid") ;<- Get current Pline width setting
)
(setvar "cmdecho" 0) ;<- Change the echo of commands to the textscreen to off
;--------------------------------
;Revise the following line to incorporate the system variables you are going to change
(SAVE_SYS '("CMDECHO" "CLAYER" "OSMODE" "PLINEWID")) ;;;__ Save Settings___ _ end of SAVE_SYS
;The above system variables would include all system variables you plan to modify within the full routine.
;--------------------------------
(princ "MAKES A MATCHLINE LINE") ;<- Prints on the command line what the code does.
(setvar "osmode" 129) ;<- Sets the OSNAP "END" & "PER" to on.
(setvar "PLINEWID" 0.125) ;<- Set pline width 1/8"
;(setvar "CELTSCALE" 1) ;<- Set entity base ltscale to 1.
(command "layer" "MAKE" "L-MATCHLINE" "color" "2" "" "Ltype" "dashed" "" "") ;<- Creates a layer named "L-LMT-OF-WRK" with the color yellow and the linetype as dash.
(command "_pline") ;<- execute pline command
(while (> (getvar "cmdactive") 0) ;<- while the user has not exited the pline command
(command pause) ;<- place another pause to allow for additional user input
)
(setvar "osmode" useros) ;<- reset changed variables
(setvar "cmdecho" usercmd) ;<- these reset variables would be better suited in its own function
; (setvar "celtscale" userltsc) ;<- search for a save_sys & restore_sys functions
(setvar "CLAYER" userlay) ;<- CLAYER is the system variable, and userlay is the variable name that contains the previous value.
(setvar "plinewid" userpwid) ;<- in the forums.
(RESTORE_SYS) ;<- This call will restore the (save_sys) AutoCAD system variables that whose variables were saved with the save_sys routine above.
(princ) ;<- quietly exit
)
CAB2k
2006-02-13, 08:19 PM
Opie
Your test for *sysvar* need this as nil will evaluate as true using listp
(and (not (null *sysvar*))
(listp *sysvar*)
cadd4la
2006-02-13, 08:30 PM
Opie,
Is this the way the code needs to look?
;******** MATCHLINE ********
;================================================= ================================================
;;||||||||||||||||||||||||||||||||||
;; Error Handler
;; Function provided by others
;;||||||||||||||||||||||||||||||||||
(defun
*ERROR*
(MSG)
(if (not
(member
MSG
'("Function cancelled" "console break" "quit / exit abort")
) ;_ end of member
) ;_ end of not
(alert MSG)
) ;_ end of if
(RESTORE_SYS) ; <-- If an error does occur, the system variables saved with the save_sys routine will be restored.
(command "_.undo" "end")
(princ)
) ;_ end of defun
;;||||||||||||||||||||||||||||||||||
;; Set and Save System Variables
;; Function provided by others
;;||||||||||||||||||||||||||||||||||
(defun
SAVE_SYS
(SYSVAR)
(setq *SYSVAR* '()) ; global var list of saved values
(repeat (length SYSVAR)
(setq *SYSVAR*
(append
*SYSVAR*
(list (list (car SYSVAR) (getvar (car SYSVAR))))
) ;_ end of append
) ;_ end of setq
(setq SYSVAR (cdr SYSVAR))
) ;_ end of repeat
) ;_ end of defun
;;||||||||||||||||||||||||||||||||||
;; Restore System Variables
;; Function provided by others
;;||||||||||||||||||||||||||||||||||
(defun
RESTORE_SYS
()
(and (listp *SYSVAR*)
(repeat (length *SYSVAR*)
(setvar (caar *SYSVAR*) (cadar *SYSVAR*))
(setq *SYSVAR* (cdr *SYSVAR*))
) ;_ end of repeat
) ;_ end of and
) ;_ end of defun
(setvar "cmdecho" 0) ;<- Change the echo of commands to the textscreen to off
;--------------------------------
;Revise the following line to incorporate the system variables you are going to change
(SAVE_SYS '("CMDECHO" "CLAYER" "OSMODE" "PLINEWID")) ;;;__ Save Settings___ _ end of SAVE_SYS
;The above system variables would include all system variables you plan to modify within the full routine.
;--------------------------------
(princ "MAKES A MATCHLINE LINE") ;<- Prints on the command line what the code does.
(setvar "osmode" 129) ;<- Sets the OSNAP "END" & "PER" to on.
(setvar "PLINEWID" 0.125) ;<- Set pline width 1/8"
;(setvar "CELTSCALE" 1) ;<- Set entity base ltscale to 1.
(command "layer" "MAKE" "L-MATCHLINE" "color" "2" "" "Ltype" "dashed" "" "") ;<- Creates a layer named "L-LMT-OF-WRK" with the color yellow and the linetype as dash.
(command "_pline") ;<- execute pline command
(while (> (getvar "cmdactive") 0) ;<- while the user has not exited the pline command
(command pause) ;<- place another pause to allow for additional user input
)
(setvar "osmode" useros) ;<- reset changed variables
(setvar "cmdecho" usercmd) ;<- these reset variables would be better suited in its own function
; (setvar "celtscale" userltsc) ;<- search for a save_sys & restore_sys functions
(setvar "CLAYER" userlay) ;<- CLAYER is the system variable, and userlay is the variable name that contains the previous value.
(setvar "plinewid" userpwid) ;<- in the forums.
(RESTORE_SYS) ;<- This call will restore the (save_sys) AutoCAD system variables that whose variables were saved with the save_sys routine above.
(princ) ;<- quietly exit
)
If so, then now I getting this onmy AutoCAD text window after startup
Customization file loaded successfully. Customization Group: EDG
Customization file loaded successfully. Customization Group: ACAD
Customization file loaded successfully. Customization Group: EXPRESS
Customization file loaded successfully. Customization Group: SPURGE
Regenerating model.
Command:
AutoCAD Express Tools Copyright © 2002-2004 Autodesk, Inc.
acaddoc.lisp - begin
KyleC menu - begin
KyleC menu Ver. 1.2.3 (01/25/06) loaded and ready to use - © copyright 2006
Eden Design Group
acaddoc.lisp Ver. 3.0 (01/19/06) loaded and ready to use - © copyright 2006
Eden Design Group
EDGAutoCOM.lsp - Version 02/10/06 loaded and ready to use - © copyright 2006
Eden Design Group
EDGSettings.lsp - Version 01/20/06 loaded - © copyright 2004-2006 Eden Design
Group
No scan images or no layer named scan.
Reactors LoadedMAKES A MATCHLINE LINE
Command: COMMANDLINE
Invalid point.
Command: properties
Invalid point.
Command: TOOLPALETTES
Invalid point.
Command: SHEETSET
Invalid point.
Kyle C.
Kyle,
Your code is missing the (defun statement at the beginning of the routine, which was posted in earlier posts.
I am at a loss as to why you are receiving the invalid point response on your command line. What are your reactors supposed to do?
cadd4la
2006-02-13, 09:24 PM
Where is this going in the code?
Opie
Your test for *sysvar* need this as nil will evaluate as true using listp
(and (not (null *sysvar*))
(listp *sysvar*)
Kyle C.
cadd4la
2006-02-13, 10:10 PM
Kyle,
Your code is missing the (defun statement at the beginning of the routine, which was posted in earlier posts.
Is this what you are talking about? If so why was it not in you 9:04 AM post?
;******** MATCHLINE ********
;=================================================
================================================
(defun MATCHLINE () ; added it here?
;;||||||||||||||||||||||||||||||||||
;; Error Handler
;; Function provided by others
;;||||||||||||||||||||||||||||||||||
(defun
*ERROR*
(MSG)
(if (not
(member
MSG
'("Function cancelled" "console break" "quit / exit abort")
) ;_ end of member
) ;_ end of not
(alert MSG)
) ;_ end of if
(RESTORE_SYS) ; <-- If an error does occur, the system variables saved with the save_sys
routine will be restored.
(command "_.undo" "end")
(princ)
) ;_ end of defun
;;||||||||||||||||||||||||||||||||||
;; Set and Save System Variables
;; Function provided by others
;;||||||||||||||||||||||||||||||||||
(defun
SAVE_SYS
(SYSVAR)
(setq *SYSVAR* '()) ; global var list of saved values
(repeat (length SYSVAR)
(setq *SYSVAR*
(append
*SYSVAR*
(list (list (car SYSVAR) (getvar (car SYSVAR))))
) ;_ end of append
) ;_ end of setq
(setq SYSVAR (cdr SYSVAR))
) ;_ end of repeat
) ;_ end of defun
;;||||||||||||||||||||||||||||||||||
;; Restore System Variables
;; Function provided by others
;;||||||||||||||||||||||||||||||||||
(defun
RESTORE_SYS
()
(and (listp *SYSVAR*)
(repeat (length *SYSVAR*)
(setvar (caar *SYSVAR*) (cadar *SYSVAR*))
(setq *SYSVAR* (cdr *SYSVAR*))
) ;_ end of repeat
) ;_ end of and
) ;_ end of defun
(setvar "cmdecho" 0) ;<- Change the echo of commands to the textscreen to off
;--------------------------------
;Revise the following line to incorporate the system variables you are going to change
(SAVE_SYS '("CMDECHO" "CLAYER" "OSMODE" "PLINEWID")) ;;;__ Save Settings___ _ end of SAVE_SYS
;The above system variables would include all system variables you plan to modify within the full
routine.
;--------------------------------
(princ "MAKES A MATCHLINE LINE") ;<- Prints on the command line what the code does.
(setvar "osmode" 129) ;<- Sets the OSNAP "END" & "PER" to on.
(setvar "PLINEWID" 0.125) ;<- Set pline width 1/8"
;(setvar "CELTSCALE" 1) ;<- Set entity base ltscale to 1.
(command "layer" "MAKE" "L-MATCHLINE" "color" "2" "" "Ltype" "dashed" "" "") ;<- Creates a layer
named "L-LMT-OF-WRK" with the color yellow and the linetype as dash.
(command "_pline") ;<- execute pline command
(while (> (getvar "cmdactive") 0) ;<- while the user has not exited the pline command
(command pause) ;<- place another pause to allow for additional user input
)
(setvar "osmode" useros) ;<- reset changed variables
(setvar "cmdecho" usercmd) ;<- these reset variables would be better suited in its own function
; (setvar "celtscale" userltsc) ;<- search for a save_sys & restore_sys functions
(setvar "CLAYER" userlay) ;<- CLAYER is the system variable, and userlay is the variable name
that contains the previous value.
(setvar "plinewid" userpwid) ;<- in the forums.
(RESTORE_SYS) ;<- This call will restore the (save_sys) AutoCAD system variables that whose
variables were saved with the save_sys routine above.
(princ) ;<- quietly exit
)
If so, then now I getting this on my AutoCAD text window after startup
Regenerating model.
AutoCAD Express Tools Copyright © 2002-2004 Autodesk, Inc.
acaddoc.lisp - begin
KyleC menu - begin
KyleC menu Ver. 1.2.3 (01/25/06) loaded and ready to use - © copyright 2006
Eden Design Group
acaddoc.lisp Ver. 3.0 (01/19/06) loaded and ready to use - © copyright 2006
Eden Design Group
EDGAutoCOM.lsp - Version 02/10/06 loaded and ready to use - © copyright 2006
Eden Design Group
EDGSettings.lsp - Version 01/20/06 loaded - © copyright 2004-2006 Eden Design
Group
No scan images or no layer named scan.
Reactors Loaded; error: bad function: "MATCHLINE"
AutoCAD menu utilities loaded.
As I stated before the pull-down menu works but now I am getting this after I hit enter (see attachment).
I then took a look at the code and canceled out this part. Now I don't get the AutoCAD Message box when I hit "enter" and it don't stay on the "l-Matchline" layer and gives you a 1/8" wide pline. So, it looks like it is working.
; (setvar "osmode" useros) ;<- reset changed variables
; (setvar "cmdecho" usercmd) ;<- these reset variables would be better suited in its own function
; (setvar "celtscale" userltsc) ;<- search for a save_sys & restore_sys functions
; (setvar "CLAYER" userlay) ;<- CLAYER is the system variable, and userlay is the variable name that contains the previous value.
; (setvar "plinewid" userpwid) ;<- in the forums.
.....I am at a loss as to why you are receiving the invalid point response on your command line. What are your reactors supposed to do?
I don't think it has anything to do with the reactor code because if I cancel it from loading in my startup.lsp I still get the same message about the Matchline.
Is this what you are talking about? If so why was it not in you 9:04 AM post?
I had copied your routine from the previous post. I did not check that portion of the code, but will try to remember the next time that is needed.
If so, then now I getting this on my AutoCAD text window after startup
As I stated before the pull-down menu works but now I am getting this after I hit enter (see attachment).
I then took a look at the code and canceled out this part. Now I don't get the AutoCAD Message box when I hit "enter" and it don't stay on the "l-Matchline" layer and gives you a 1/8" wide pline. So, it looks like it is working.
[/code]
I made some assumptions that were wrong. You are correct in commenting out those system variable changes based on variables that are not set.
I don't think it has anything to do with the reactor code because if I cancel it from loading in my startup.lsp I still get the same message about the Matchline.I'm confused now. Is it working for you?
cadd4la
2006-02-13, 11:48 PM
Opie,
...I'm confused now. Is it working for you?
The second part of my problem looks to be fixed. Thank you Opie.
...The second problem is the error trapping is not working right - if I press the "esc" key it will stay on the layer that the code is design to make & place the line on as well as it leaves the pline width at what the linetype is set at.
But, I am still have the first problem and I know what you said but this is a open question to the other people reading this thread.
I am at a loss as to why you are receiving the invalid point response on your command line...
...The first is that it stop the complete loading of my Startup.lsp file, but the linetype.lsp still works.
I have this code running from a pull-down menu and on my CUI dialog box for this menu on the Macro I have set as ^C^C(Matchline) for the matchline & ^C^C(Limitline) for the Limitline.
This is my AutoCAD text window after startup
Quote:
Customization file loaded successfully. Customization Group: EDG
Customization file loaded successfully. Customization Group: ACAD
Customization file loaded successfully. Customization Group: EXPRESS
Customization file loaded successfully. Customization Group: SPURGE
Regenerating model.
Command:
AutoCAD Express Tools Copyright © 2002-2004 Autodesk, Inc.
acaddoc.lisp - begin
KyleC menu - begin
KyleC menu Ver. 1.2.3 (01/25/06) loaded and ready to use - © copyright 2006
Eden Design Group
acaddoc.lisp Ver. 3.0 (01/19/06) loaded and ready to use - © copyright 2006
Eden Design Group
EDGAutoCOM.lsp - Version 02/10/06 loaded and ready to use - © copyright 2006
Eden Design Group
EDGSettings.lsp - Version 01/20/06 loaded - © copyright 2004-2006 Eden Design
Group
No scan images or no layer named scan.
Reactors Loaded; error: bad function: "MATCHLINE" <--Problem area
AutoCAD menu utilities loaded.
Command: COMMANDLINE
Command: properties
Command: SHEETSET
Command: TOOLPALETTES Opie,
Do you know what this means? He didn't reply to my question asking what this means.
CAB2k[/b]
Opie
Your test for *sysvar* need this as nil will evaluate as true using listp
Code:
(and (not (null *sysvar*))(listp *sysvar*)
Kyle C.
Hi Kyle,
I know I'm getting into this a little late, but I would suspect (MATCHLINE) is trying to run instead of load in the file that returns:
EDGLocal Startup function Version 02/10/06 completed - © copyright 2004-2006
Eden Design Group
since, refering to:
If so, then now I getting this onmy AutoCAD text window after startup
Customization file loaded successfully. Customization Group: EDG
Customization file loaded successfully. Customization Group: ACAD
Customization file loaded successfully. Customization Group: EXPRESS
Customization file loaded successfully. Customization Group: SPURGE
Regenerating model.
Command:
AutoCAD Express Tools Copyright © 2002-2004 Autodesk, Inc.
acaddoc.lisp - begin
KyleC menu - begin
KyleC menu Ver. 1.2.3 (01/25/06) loaded and ready to use - © copyright 2006
Eden Design Group
acaddoc.lisp Ver. 3.0 (01/19/06) loaded and ready to use - © copyright 2006
Eden Design Group
EDGAutoCOM.lsp - Version 02/10/06 loaded and ready to use - © copyright 2006
Eden Design Group
EDGSettings.lsp - Version 01/20/06 loaded - © copyright 2004-2006 Eden Design
Group
No scan images or no layer named scan.
Reactors LoadedMAKES A MATCHLINE LINE
Command: COMMANDLINE
Invalid point.
Command: properties
Invalid point.
Command: TOOLPALETTES
Invalid point.
Command: SHEETSET
Invalid point.
Kyle C.
Because it princ'ed "MAKES A MATCHLINE LINE" it is apparently trying to run the routine and returns the error. Is this file where you load (MATCHLINE)?
Can you post it or could you look to see if there is a reference to (MATCHLINE) within the file if it isn't used to load it, and if it is used to load it, can you post what it says?
I think that (MATCHLINE) is trying to run, and when autocad tries to run "COMMANDLINE" "properties" "TOOLPALETTES" and "SHEETSET", it fails because (MATCHLINE) is expecting a point instead of text.
I hope this makes sense. Or maybe someone else can be clearer?
Take care,
Tim Creary
CAB2k
2006-02-14, 01:56 AM
;;||||||||||||||||||||||||||||||||||
;; Restore System Variables
;; Function provided by others
;;||||||||||||||||||||||||||||||||||
(defun restore_sys ()
(and (not (null *sysvar*)) ; correction added here
(listp *sysvar*)
(repeat (length *sysvar*)
(setvar (caar *sysvar*) (cadar *sysvar*))
(setq *sysvar* (cdr *sysvar*))
)
)
)
cadd4la
2006-02-14, 02:20 AM
Tim,
....Because it princ'ed "MAKES A MATCHLINE LINE" it is apparently trying to run the routine and returns the error. Is this file where you load (MATCHLINE)?
This was a coding misunderstanding between myself & Opie - this is no longer a problem.
....Can you post it or could you look to see if there is a reference to (MATCHLINE) within the file if it isn't used to load it, and if it is used to load it, can you post what it says?
I don't understand you, the (matchline) is the code that I posted from the beginning if you mean the reactor all that is is code that changes the LTS to the dimscale in model and to 1 when in Layout.
Please see my Today 02:48 PM posting for what I am getting on my AutoCAD text window after startup
Kyle C.
kennet.sjoberg
2006-02-14, 07:50 AM
kennet, . . . I don't really understanding what your showing me with this code? Can you place the parts you changing into my existing code that I posted.
No, the code is your working MATCHLINE code, ( Link ) (http://forums.augi.com/showthread.php?t=33882&page=2#post280668)
a little compressed but easy to read and understand,
and a way point for you to build a working code without error trapping problem.
errorhandler that do not bomb osmode
Settings that take care of user variables
Main Program that do the job, and
Resettings that reset the user environment
: ) Happy Computing !
kennet
Sorry Kyle,
I thought you were still having problems with "invalid point" when commandline, properties, etc. were trying to run.
Take care.
Tim Creary
cadd4la
2006-02-14, 10:08 PM
Kennet,
Thank you I understand now.
I did try your version but I still get the width problem after I stop or hit the "Esc" key, then use the pline command.
Opie's & CAB's help has fixed the second part of the problem, but I do thank you for the help you have given me.
Kyle C.
kennet.sjoberg
2006-02-15, 08:14 AM
. . .I still get the width problem after I stop or hit the "Esc" key, then use the pline command. . .
Do You know what ?
I can not reach the value with (getvar "PLINEWID ")
it must be (getvar "PLINEWID" ) then it should work.
: ) Happy Computing !
kennet
Someone can slap me senseless ~slap~ :-? , OWWW! but, for command line aesthetics, I would replace:
(command "_pline") ;<- execute pline command
(while (> (getvar "cmdactive") 0) ;<- while the user has not exited the pline command
(command pause) ;<- place another pause to allow for additional user input
)
(command "_pline" (getpoint "\nFirst point: "));execute pline; tell 'em it's waitin' for a point
(while (> (getvar "cmdactive") 0)
(princ "\nNext Point: ");let 'em know it wants another
(command pause);pause for subsiquent points
);end while
Just my 2 pieces of muktuk.:grin:
Tim Creary
cadd4la
2006-02-16, 01:59 AM
Kennet,
Thank you,
Do You know what ?
I can not reach the value with (getvar "PLINEWID ")
it must be (getvar "PLINEWID" ) then it should work.
: ) Happy Computing !
kennet
It works great but when I added the second part (Limitline) of the code It still does work but I am getting this at the command line.
Command: (LIMITLINE) MAKES A LIMIT OF WORK LINE
nError: AutoCAD variable setting rejected: "celtscale" nil
;******** LIMITLINE ********
;=================================================================================================
(defun LIMITLINE (/ USERos USERcmd USERlay USERpwid ) ; <- this is same as setq USERos nil USERcmd nil ...
;; errorhandler
(defun *ERROR* (MSG)
(princ (strcat "nError: " MSG ) )
;; Resettings here may be the same as in the end of the Main Program
;; The if statement is good if the USERxx variable is not set
(if USERos (setvar "OSMODE" USERos ) ( ) )
(if USERcmd (setvar "CMDECHO" USERcmd ) ( ) )
(if USERlay (setvar "CLAYER" USERlay ) ( ) )
(if USERpwid (setvar "PLINEWID" USERpwid ) ( ) )
(if userltsc (setvar "CELTSCALE" userltsc ) ( ) ) ;<- Get current entity based ltscale
)
;; Settings, in the start of program, take care of all USER variables that are going to change
(setq USERos (getvar "OSMODE" ) )
(setq USERcmd (getvar "CMDECHO" ) )
(setq USERlay (getvar "CLAYER" ) )
(setq USERpwid (getvar "PLINEWID" ) )
(setvar "OSMODE" 129 )
(setvar "CMDECHO" 0 )
(setvar "PLINEWID" 0.09375 ) ;<- Set pline width 3/32"
(setvar "CELTSCALE" 0.5 ) ;<- Set entity base ltscale to 0.5.
;; Main Program, do the job.
(princ "MAKES A LIMIT OF WORK LINE" )
(command "layer" "MAKE" "L-LMT-OF-WRK" "color" "2" "" "Ltype" "dashed" "" "" );<- Creates a layer named "L-LMT-OF-WRK" with the color yellow and the linetype as dash.
(command "_pline" )
(while (> (getvar "CMDACTIVE" ) 0 ) (command pause ) )
;; Resettings, should be oposit to Settings
(setvar "OSMODE" USERos )
(setvar "CMDECHO" USERcmd )
(setvar "CLAYER" USERlay )
(setvar "PLINEWID" USERpwid )
(setvar "celtscale" userltsc ) ;<- search for a save_sys & restore_sys functions
(princ)
)
Kyle C.
cadd4la
2006-02-16, 02:11 AM
Tim,
Thank you for that addition to the code.
Someone can slap me senseless ~slap~ :-? , OWWW! but, for command line aesthetics, I would replace:
(command "_pline" (getpoint "\nFirst point: "));execute pline; tell 'em it's waitin' for a point
(while (> (getvar "cmdactive") 0)
(princ "\nNext Point: ");let 'em know it wants another
(command pause);pause for subsiquent points
);end while
Just my 2 pieces of muktuk.:grin:
Tim Creary
Kyle C.
It looks like you just forgot to save the variable USERltsc.
;******** LIMITLINE ********
;================================================= ================================================
(defun LIMITLINE (/ USERos USERcmd USERlay USERpwid ) ; <- this is same as setq USERos nil USERcmd nil ...
;; errorhandler
(defun *ERROR* (MSG)
(princ (strcat "nError: " MSG ) )
;; Resettings here may be the same as in the end of the Main Program
;; The if statement is good if the USERxx variable is not set
(if USERos (setvar "OSMODE" USERos ) ( ) )
(if USERcmd (setvar "CMDECHO" USERcmd ) ( ) )
(if USERlay (setvar "CLAYER" USERlay ) ( ) )
(if USERpwid (setvar "PLINEWID" USERpwid ) ( ) )
(if userltsc (setvar "CELTSCALE" userltsc ) ( ) ) ;<- Get current entity based ltscale
)
;; Settings, in the start of program, take care of all USER variables that are going to change
(setq USERos (getvar "OSMODE" ) )
(setq USERcmd (getvar "CMDECHO" ) )
(setq USERlay (getvar "CLAYER" ) )
(setq USERpwid (getvar "PLINEWID" ) )
(setq USERltsc (getvar "CELTSCALE") )
(setvar "OSMODE" 129 )
(setvar "CMDECHO" 0 )
(setvar "PLINEWID" 0.09375 ) ;<- Set pline width 3/32"
(setvar "CELTSCALE" 0.5 ) ;<- Set entity base ltscale to 0.5.
;; Main Program, do the job.
(princ "MAKES A LIMIT OF WORK LINE" )
(command "layer" "MAKE" "L-LMT-OF-WRK" "color" "2" "" "Ltype" "dashed" "" "" );<- Creates a layer named "L-LMT-OF-WRK" with the color yellow and the linetype as dash.
(command "_pline" )
(while (> (getvar "CMDACTIVE" ) 0 ) (command pause ) )
;; Resettings, should be oposit to Settings
(setvar "OSMODE" USERos )
(setvar "CMDECHO" USERcmd )
(setvar "CLAYER" USERlay )
(setvar "PLINEWID" USERpwid )
(setvar "celtscale" userltsc ) ;<- search for a save_sys & restore_sys functions
(princ)
)
I hope this helps,
Tim Creary
cadd4la
2006-02-16, 02:25 AM
Tim,
Thank you, That was it
I should have seen that one. :Oops:
Kyle C.
No problem; I'm glad I could help!
Take care,
Tim Creary
kennet.sjoberg
2006-02-16, 08:06 AM
. . .I should have seen that one. . .
... and do not forget to initzilase the variable that set it to nil when the program has finnished.
(defun LIMITLINE (/ USERos USERcmd USERlay USERpwid USERltsc )
: ) Happy Computing !
kennet
cadd4la
2006-02-16, 09:39 PM
Kennet,
Got it.
Thanks.
Kyle C.
... and do not forget to initzilase the variable that set it to nil when the program has finnished.
(defun LIMITLINE (/ USERos USERcmd USERlay USERpwid USERltsc )
: ) Happy Computing !
kennet
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.