Jump to content

error on lisp (no function definition: SF)


sachindkini

Recommended Posts

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 ------ ;;;;;;;;;

Link to comment
Share on other sites

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,

Link to comment
Share on other sites

;;;;;;;;; ------ 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 ---

Link to comment
Share on other sites

;;;;;;;;; ------ 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

Link to comment
Share on other sites

  • 1 year later...

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?

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...