sachindkini Posted June 26, 2010 Posted June 26, 2010 dear sir error on lisp plz chq Command: ca Select objects: 1 found Select objects: WHERE TO PLACE TEXT: no function definition: SF ;;;;;;;;; ------ Carpet Area Program ------ ;;;;;;;;;(defun c:CA (/ *error* p1 p5 p6 a b c d e fn) (setq oldCM (getvar "CMDECHO") oldos (getvar "OSMODE") ) (defun *error* (msg) (if oldCM (setvar "CMDECHO" oldCM) ) (if oldos (setvar "OSMODE" oldos) ) (princ msg) (princ) ) (setvar "CMDECHO" 0) (setvar "osmode" 0) ;(setvar "osmode" 524) (if (and (setq s (ssget '((0 . "LWPOLYLINE")))) (setq p5 (getpoint "\nWHERE TO PLACE TEXT: ")) ) (progn (setq p5 (polar p5 pi 1250)) (setq p6 (polar p5 0 2500)) ;(setq fn (getstring t "\nFLAT NO.:")) (command "AREA" "E" P1) (setq n 0) (command ".area" "e" (ssname s n)) (SETQ A (GETVAR "AREA")) (SETQ F (SF)) (defun sf (/ sm sf st) (setq sm (getvar "area")) (setq sf (* sm 0.000010764)) (setq sf (rtos sf 2 2)) (SETQ ST (strcat sf " SQ. FT.")) (PRIN1 ST) ) (SETQ B (/ A 1000000)) (SETQ C (RTOS B 2 2)) (SETQ D "CARPET AREA") ;(setq e (strcat FN " = " C " SQ.MT.")) (setq e (strcat "= " C " SQ.MT.")) (setq F (strcat "= " F)) (COMMAND "TEXT" "S" "STANDARD" "f" P5 p6 "250" D "text" "" e "text" "" f "_.rectangle" (mapcar '+ P5 '(-165 440 0)) (mapcar '+ P6 '(165 -1045 0)) ) ; end command ) ;; End Progn (princ "\n>") ) ;; End IF ;; Reset System Variables: (setvar "cmdecho" oldCM) (setvar "osmode" oldos) (princ) ;; Exit Cleanly ) ;; End defun ;;;;;;;;; ------ End Program ------ ;;;;;;;;; Quote
MSasu Posted June 26, 2010 Posted June 26, 2010 This is the trouble-maker line: (SETQ F (SF)) It suppose that you have a function named SF available (defined and loaded) when you run the code above. But his definition is just below his call - please move that definition upper in the code. The interesting part is that if you try to run the original code second time it will work - the function become available. Regards, Quote
VVA Posted June 26, 2010 Posted June 26, 2010 ;;;;;;;;; ------ Carpet Area Program ------ ;;;;;;;;; (defun c:CA (/ *error* p5 p6 a b c d e f s) (setq oldCM (getvar "CMDECHO") oldos (getvar "OSMODE") ) (defun *error* (msg) (if oldCM (setvar "CMDECHO" oldCM)) (if oldos (setvar "OSMODE" oldos)) (princ msg) (princ) ) (setvar "CMDECHO" 0) (setvar "osmode" 0) ;(setvar "osmode" 524) (if (and (setq s (ssget "_:S:E" '((0 . "LWPOLYLINE")))) (setq p5 (getpoint "\nWHERE TO PLACE TEXT: ")) ) (progn (setq p5 (polar p5 pi 1250)) (setq p6 (polar p5 0 2500)) ;(setq fn (getstring t "\nFLAT NO.:")) (command "._area" "_e" (ssname s 0)) (SETQ A (GETVAR "AREA")) (setq f (* A 0.000010764)) (setq f (rtos f 2 2)) (SETQ f (strcat f " SQ. FT.")) (SETQ B (/ A 1000000)) (SETQ C (RTOS B 2 2)) (SETQ D "CARPET AREA") ;(setq e (strcat FN " = " C " SQ.MT.")) (setq e (strcat "= " C " SQ.MT.")) (setq F (strcat "= " F)) (COMMAND "_TEXT" "_S" "STANDARD" "_f" P5 p6 "250" D "_text" "" e "_text" "" f "_.rectangle" (mapcar '+ P5 '(-165 440 0)) (mapcar '+ P6 '(165 -1045 0)) ) ; end command ) ;; End Progn (princ "\n>") ) ;; End IF ;; Reset System Variables: (setvar "cmdecho" oldCM) (setvar "osmode" oldos) (princ) ;; Exit Cleanly ) ;; End defun ;;;;;;;;; ------ End Program --- Quote
sachindkini Posted June 28, 2010 Author Posted June 28, 2010 ;;;;;;;;; ------ Carpet Area Program ------ ;;;;;;;;; (defun c:CA (/ *error* p5 p6 a b c d e f s) (setq oldCM (getvar "CMDECHO") oldos (getvar "OSMODE") ) (defun *error* (msg) (if oldCM (setvar "CMDECHO" oldCM)) (if oldos (setvar "OSMODE" oldos)) (princ msg) (princ) ) (setvar "CMDECHO" 0) (setvar "osmode" 0) ;(setvar "osmode" 524) (if (and (setq s (ssget "_:S:E" '((0 . "LWPOLYLINE")))) (setq p5 (getpoint "\nWHERE TO PLACE TEXT: ")) ) (progn (setq p5 (polar p5 pi 1250)) (setq p6 (polar p5 0 2500)) ;(setq fn (getstring t "\nFLAT NO.:")) (command "._area" "_e" (ssname s 0)) (SETQ A (GETVAR "AREA")) (setq f (* A 0.000010764)) (setq f (rtos f 2 2)) (SETQ f (strcat f " SQ. FT.")) (SETQ B (/ A 1000000)) (SETQ C (RTOS B 2 2)) (SETQ D "CARPET AREA") ;(setq e (strcat FN " = " C " SQ.MT.")) (setq e (strcat "= " C " SQ.MT.")) (setq F (strcat "= " F)) (COMMAND "_TEXT" "_S" "STANDARD" "_f" P5 p6 "250" D "_text" "" e "_text" "" f "_.rectangle" (mapcar '+ P5 '(-165 440 0)) (mapcar '+ P6 '(165 -1045 0)) ) ; end command ) ;; End Progn (princ "\n>") ) ;; End IF ;; Reset System Variables: (setvar "cmdecho" oldCM) (setvar "osmode" oldos) (princ) ;; Exit Cleanly ) ;; End defun ;;;;;;;;; ------ End Program --- dear sir, thx for reply it's working Quote
anishtain4 Posted May 21, 2012 Posted May 21, 2012 out of the blue I'm having this problem, I have two files one of them is the utility and the other is calling some functions form it, the parts of them I'm using is as: utilities.lsp ; New Layer (defun newLayer (LayName Color Ltype Lweight / NewLay) ;loading line type (if (not (tblsearch "LTYPE" Ltype)) (vla-load (vla-get-linetypes activeDoc) Ltype "acadiso.lin")) ; Creating new layer (if (not (tblsearch "Layer" LayName)) (setq NewLay (vla-add LayerTable LayName)) ) (vla-put-color NewLay Color) (vla-put-linetype NewLay Ltype) (vla-put-lineweight NewLay Lweight) ) (defun gGet (name) (cdr (assoc name (vlax-ldata-get modelSpace "mhjv-vars"))) ) Draw.lsp (defun c:Draw_frm_Draw_cmd_SetLayers_OnClicked (/ tot lays newLayer) (newLayer (gGet "greyLay") 9 0 -3) (setvar "Clayer" (gGet "greyLay")) (setq lays (LayList (gGet "greyLay"))) (repeat (setq tot (length lays)) (command ".-LAYMRG" "n" (nth (setq tot (1- tot)) lays) "" "n" (gGet "greyLay") "y") ) (princ) ) As you see the function in draw first calls gGet and then newLayer from utilities, interestingly gGet is being called but when it comes to newLayer it returns "; error: no function definition: NEWLAYER" What am I missing? Quote
anishtain4 Posted May 21, 2012 Posted May 21, 2012 Never mind, got the problem, I have defined newlayer after / in function deifnition Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.