Jump to content

Recommended Posts

Posted

I have been trying to write something in Autolisp; however I keep getting an error, which I don't understand at all.

In case of the code here, I would get error "bad function: (*coordinates provided by the getpoint function, that is highlighted bellow*)

The error does not depend on the function placed on the spot, no matter the function I get the error with the name of the argument of said function, but I don't understand why.

Could someone, please explain why this is the case? Thanks a lot.

 

(if (eq (getkword "\nChceš to napsat? [Ano/Ne] <Ne>:") "Ano")
        (
            (setq text_sour (getpoint "\n Kam chceš text?"))            Any function placed here prompts the error, everything after procedes fine
            (initget "mm^2 m^2")
              (if (eq (getkword "\nVe čtverečních metrech nebo milimetrech? [m^2/mm^2] <mm^2>:") "m^2")
                    (command "_text" text_sour "3" "0" plocham2);if m^2
                     (command "_text" text_sour "3" "0" plochamm2);if mm^2
               );if
    );if ano
  );if

 

The whole code:

 

(defun c:otp (/ objekt)
  (setq uchstar (getvar "OSMODE"))    ;úchyty
  (setq hladstar (getvar "CLAYER"))    ;hladiny
  (setvar "OSMODE" 0)
  (command "_-layer" "y" "pomocné" "" "v" "n" "")
  (command "_-layer" "i" "pomocné" "")
  (command "_boundary"
       (getpoint "\nOkolo čeho chceš tu oblast?")
       ""
  )
  (command "_region" "l" "")
  (setq objekt "l")
  (command "_area" "o" objekt)        ;plocha krivky
  (setq plochamm2 (getvar "area"))    ;v milimetrech ^2
  (setq plocham2 (* plochamm2 0.000001)) ;prevod na metry
  (subteziste)                ;ta subfce teziste
  (initget "Ano Ne")
  (if (eq (getkword "\nChceš to napsat? [Ano/Ne] <Ne>:") "Ano")
        (
            (setq text_sour (getpoint "\n Kam chceš text?"))
            (initget "mm^2 m^2")
              (if (eq (getkword "\nVe čtverečních metrech nebo milimetrech? [m^2/mm^2] <mm^2>:") "m^2")
                	(command "_text" text_sour "3" "0" plocham2);if m^2
            	 	(command "_text" text_sour "3" "0" plochamm2);if mm^2
     		  );if
    );if ano
  );if
  (setvar "CLAYER" hladstar)
  (setvar "OSMODE" uchstar)
  (print
    "\nPředpokládá se kreslící jednotka = 1 mm. (Plocha v m^2 je řenásobená 10^-6)"
  )
)
Posted

Try

 

(if (eq (getkword "\nChceš to napsat? [Ano/Ne] <Ne>:") "Ano")
        (progn

 

Posted
11 hours ago, BIGAL said:

Try

 

(if (eq (getkword "\nChceš to napsat? [Ano/Ne] <Ne>:") "Ano")
        (progn

 

That works, thanks.

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