PDA

View Full Version : Calling 2 AutoCAD commands causes an error - function cancelled


tany0070
2007-03-05, 09:59 AM
i actually posted this problem elsewhere before, just thought to ask again since it wasn't really answered. i always encounter this problem when 2 "command" calls are used in a function to call 2 different autoCAD commands like color followed by mirror etc, the error "function cancelled" will occur. does anyone have any ideas why this is happening and what i should do to prevent this.

thanks in advance.

jmcshane
2007-03-05, 12:08 PM
Could you post an example of this code ?

madcadder
2007-03-05, 02:30 PM
Could you post an example of this code ?

without the code i'm going to venture a missing WHILE for CMDACTIVE.
something like this:

(command "_.xline" orientation)
(while (> (getvar "cmdactive") 0)
(command pause)
)


You need to pause the routine to let the one command finish running before calling the next command.

Just a guess based on MY previous errors. :?

tany0070
2007-03-06, 01:32 AM
my coding is as follows:

(defun c:mirrorF ()
(command "_color" 7 "")
(setq cent (getpoint "specify centre"))
(setq x-mirror (list (nth 0 cent) (1+ (nth 1 cent))))
(setq s1 (ssget))
(command "_mirror" s1 "")
)

and another weird thing is that if i try specifying the 2 points for the mirror line and stuff, it also returns a "function cancelled" error. thanks

Opie
2007-03-06, 04:01 AM
Your code was not complete. It canceled out when it attempted to execute the mirror command. You had not supplied the necessary information to complete the command.
(defun c:mirrorF ( / cent x-mirror s1)
(command "_color" 7 "")
(setq cent (getpoint "\nSpecify centre: "))
(setq x-mirror (list (nth 0 cent) (1+ (nth 1 cent))))
(setq s1 (ssget))
(command "_mirror" s1 "" cent x-mirror "n")
)

tany0070
2007-03-06, 05:47 AM
Thanks for the quick reply

Opie
2007-03-06, 05:52 AM
Thanks for the quick reply
No problem. I hope it works in the fashion you expected.

tany0070
2007-03-07, 05:02 AM
yes it does thanks again