Results 1 to 9 of 9

Thread: Calling 2 AutoCAD commands causes an error - function cancelled

  1. #1
    100 Club
    Join Date
    2007-02
    Posts
    148
    Login to Give a bone
    0

    Default Calling 2 AutoCAD commands causes an error - function cancelled

    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.

  2. #2
    100 Club
    Join Date
    2003-11
    Location
    Dublin, Ireland.
    Posts
    152
    Login to Give a bone
    0

    Default Re: Calling 2 AutoCAD commands causes an error - function cancelled

    Could you post an example of this code ?

  3. #3
    AUGI Addict madcadder's Avatar
    Join Date
    2000-11
    Location
    Too far from the beach
    Posts
    1,054
    Login to Give a bone
    0

    Default Re: Calling 2 AutoCAD commands causes an error - function cancelled

    Quote Originally Posted by madcadder
    Could you post an example of this code ?
    without the code i'm going to venture a missing WHILE for CMDACTIVE.
    something like this:
    Code:
    (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.

  4. #4
    100 Club
    Join Date
    2007-02
    Posts
    148
    Login to Give a bone
    0

    Default Re: Calling 2 AutoCAD commands causes an error - function cancelled

    my coding is as follows:

    Code:
    (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
    Last edited by Opie; 2007-03-06 at 02:51 AM. Reason: [code] tags added

  5. #5
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

    Default Re: Calling 2 AutoCAD commands causes an error - function cancelled

    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.
    Code:
    (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")
    )
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  6. #6
    100 Club
    Join Date
    2007-02
    Posts
    148
    Login to Give a bone
    0

    Default Re: Calling 2 AutoCAD commands causes an error - function cancelled

    Thanks for the quick reply

  7. #7
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

    Default Re: Calling 2 AutoCAD commands causes an error - function cancelled

    Quote Originally Posted by tany0070
    Thanks for the quick reply
    No problem. I hope it works in the fashion you expected.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  8. #8
    100 Club
    Join Date
    2007-02
    Posts
    148
    Login to Give a bone
    0

    Default Re: Calling 2 AutoCAD commands causes an error - function cancelled

    yes it does thanks again

  9. #9
    Login to Give a bone
    0

    Default Re: Calling 2 AutoCAD commands causes an error - function cancelled

    Hello Opie,

    When I used "LABEL POSITION" command, at that time continuously I got an "error-function-cancelled". Please help me sir!!

    My code is below,

    *******************************************************************************
    Code:
    (defun c:lbl ()
      (setq objs (ssget))
      (setq ref_point (getpoint "pick a point"))
      (setq ref_pointx (car ref_point))
      (setq ss_len (sslength objs))
      (setq count 0)
      (repeat ss_len
        (setq obj (ssname objs count))
        (setq objp (entget obj))
        (setq objc (assoc 10 objp))
        (setq objx (car (cdr objc)))
        (setq objy (car (cdr (cdr objc))))
        (setq objj (assoc 72 objp))
        (setq objh (assoc 40 objp))
    
        (progn
          (setq objj_new (cons 72 0))
          (setq objp (subst objj_new objj objp))
          (entmod objp)
    
          (setq objc_11 (cons 11 (list 0 0 0)))
          (setq objc_10 (cons 10 (list ref_pointx objy 0)))
    
          (setq objp (subst objc_10 (assoc 10 objp) objp))
          (setq objp (subst objc_11 (assoc 11 objp) objp))
          (entmod objp)
        )
        (setq count (+ count 1))
      )
    )
    
    (defun c:lbr ()
      (setq objs (ssget))
      (setq ref_point (getpoint "pick a point"))
      (setq ref_pointx (car ref_point))
      (setq ss_len (sslength objs))
      (setq count 0)
      (repeat ss_len
        (setq obj (ssname objs count))
        (setq objp (entget obj))
        (setq objc (assoc 10 objp))
        (setq objx (car (cdr objc)))
        (setq objy (car (cdr (cdr objc))))
        (setq objj (assoc 72 objp))
        (setq objh (assoc 40 objp))
    
        (progn
          (setq objj_new (cons 72 2))
          (setq objp (subst objj_new objj objp))
          (entmod objp)
    
          (setq objp (entget obj))
          (setq objc_new (assoc 10 objp))
          (setq objx_new (car (cdr objc_new)))
          (setq objx_delta (abs objx_new))
    
          (setq objc_x1 (- ref_pointx objx_delta))
          (setq objc_x2 ref_pointx)
          (setq objc_y1 objy)
          (setq objc_y2 objy)
    
          (setq objc_10 (cons 10 (list objc_x1 objc_y1 0)))
          (setq objc_11 (cons 11 (list objc_x2 objc_y2 0)))
    
          (setq objp (subst objc_10 objc_new objp))
          (setq objp (subst objc_11 (assoc 11 objp) objp))
          (entmod objp)
        )
        (setq count (+ count 1))
      )
    )
    
    ***************************************************************************************
    
    (defun c:1()
      (command "ucs" "world")
    (setq objs (ssget))
      (Setq scalef (/ (cdr(assoc 40(entget(ssname objs 0))))9))
      (setq x_x (* scalef 4.0))
      (setq y_y (* scalef 4.0))
      (setq text_gap (* scalef 16.0))
      (setq text_height (* scalef 9.0))
      (setq ss_len (sslength objs))
      (setq osm (getvar "osmode"))
      (command "osnap" "qui,end")
      (setq cxy (getpoint "pick a point"))
      (command "osmode" 0)
      (setq cx (car cxy))
      (setq cy (car (cdr cxy)))
      (setq count 0)
    
      (repeat ss_len
        (if	(= count 0)
          (progn
    	(setq tx1 (+ cx x_x))
    	(setq ty1
    	       (+ cy
    		  (/ (+ (* (- ss_len 1.0) text_gap) text_height)
    		     2
    		  )
    	       )
    	)
    	(setq tx2 tx1)
    	(setq ty2 (- ty1 text_height))
          )
          (setq ty2 (- ty2 text_gap))
        )
    
        (setq obj (ssname objs count))
        (setq objp (entget obj))
    
    
        (setq objj_new (cons 72 0))
    
        (setq objc_11 (cons 11 (list 0 0 0)))
        (setq objc_10 (cons 10 (list tx2 ty2 0)))
    
        (setq objp (subst objc_10 (assoc 10 objp) objp))
        (setq objp (subst objc_11 (assoc 11 objp) objp))
        (setq objp (subst objj_new (assoc 72 objp) objp))
        (entmod objp)
    
        (setq count (+ count 1))
    
      )
    
      ;(setvar "osmode" osm)
      (setq lpx1 (+ cx (* 12.0 SCALEF)))
      (setq lpx2 cx)
      (setq lpx3 cx)
      (setq lpx4 lpx1)
    
      (setq lpy1 (+ ty1 x_x))
      (setq lpy2 lpy1)
      (setq	lpy3
    	 (- ty1
    	    (+ (+ (* text_gap (- count 1)) text_height) (* scalef 5.0))
    	 )
      )
      (setq lpy4 lpy3)
    
      (setq lp1 (list lpx1 lpy1))
      (setq lp2 (list lpx2 lpy2))
      (setq lp3 (list lpx3 lpy3))
      (setq lp4 (list lpx4 lpy4))
      (setq clay (getvar "clayer"))
      (setvar "clayer" "0-25text")
       (if(> ss_len 1)
        (progn
         (command "pline" lp1 lp2 lp3 lp4 "")
         )
        )
      (setvar "clayer" clay)
    )
    
    ******************************************************
    (defun c:2()
      (command "ucs" "World")
      ;(c:xpl)
      (setq objs (ssget))
      (setq 
    	scalef(/ (cdr(assoc 40(entget(ssname objs 0))))9))
        (setq x_x (* scalef 4.0))
      (setq y_y (* scalef 4.0))
      (setq text_gap (* scalef 16.0))
      (setq text_height (* scalef 9.0))
      (setq ss_len (sslength objs))
      (setq osm (getvar "osmode"))
      (command "osnap" "qui,end")
      (setq cxy (getpoint "pick a point"))
      (command "osmode" 0)
      (setq cx (car cxy))
      (setq cy (car (cdr cxy)))
      (setq count 0)
    
      (repeat ss_len
        (if	(= count 0)
          (progn
    	(setq tx1 (- cx x_x))
    	(setq ty1
    	       (+ cy
    		  (/ (+ (* (- ss_len 1.0) text_gap) text_height)
    		     2
    		  )
    	       )
    	)
    	(setq tx2 tx1)
    	(setq ty2 (- ty1 text_height))
          )
          (setq ty2 (- ty2 text_gap))
        )
    
        (setq obj (ssname objs count))
        (setq objp (entget obj))
    
        (setq objj_new (cons 72 2))
        (setq objp (subst objj_new (assoc 72 objp) objp))
        (entmod objp)
    
        (setq objp (entget obj))
        (setq objj (assoc 10 objp))
        (setq objjj (assoc 11 objp))
        (setq objjx (car (cdr objj)))
        (setq objjjx (car (cdr objjj)))
        (setq deltaxx (- objjjx objjx))
    
    
        (setq objc_11 (cons 11 (list tx2 ty2 0)))
        (setq objc_10 (cons 10 (list (- tx2 deltaxx) ty2 0)))
    
        (setq objp (subst objc_10 (assoc 10 objp) objp))
        (setq objp (subst objc_11 (assoc 11 objp) objp))
    
        (entmod objp)
    
        (setq count (+ count 1))
    
      )
    
      (setvar "osmode" osm)
      (setq lpx1 (- cx (* SCALEF 12.0)))
      (setq lpx2 cx)
      (setq lpx3 cx)
      (setq lpx4 lpx1)
    
      (setq lpy1 (+ ty1 x_x))
      (setq lpy2 lpy1)
      (setq	lpy3
    	 (- ty1
    	    (+ (+ (* text_gap (- count 1)) text_height) (* scalef 5.0))
    	 )
      )
      (setq lpy4 lpy3)
    
      (setq lp1 (list lpx1 lpy1))
      (setq lp2 (list lpx2 lpy2))
      (setq lp3 (list lpx3 lpy3))
      (setq lp4 (list lpx4 lpy4))
    
      (setq clay (getvar "clayer"))
      (setvar "clayer" "0-25text")
       (if(> ss_len 1)
        (progn
         (command "pline" lp1 lp2 lp3 lp4 "")
         )
        )
      (setvar "clayer" clay)
    )
    
    ******************************************************
    
    (DEFUN C:33 (/ d pt1 pt2 pt3); start of ext
     (load "error")
     (initerr)
     (adderr
      (list 'setvar "osmode" (getvar "osmode"))
     ) 
     (adderr
      (list 'setvar "orthomode" (getvar "orthomode"))
     )
     (adderr
      (list 'command "layer" "s" (getvar "clayer") "")
     )
     (setvar "cmdecho" 0)
     (setq sc (getvar "DIMSCALE"));REV 9-21-98
     (setvar "orthomode" 0)
     (setq d (* 0.046875 sc))
     (command "osnap" "int,center")
     (command "layer" "s" "0-25text" "")		
     (setq pt1 (getpoint "\nFirst point: "))
     (command "osnap" "none")
     (setq pt2 (getpoint pt1 "\nSecond point: "))
     (setq exangle(angle pt1 pt2))
     (setq newpt1(polar pt1 exangle d))
     (command ".line" newpt1 pt2 "")
     (command "circle" pt1 d)
     (setvar "orthomode" 1)
     (setq pt3 (getpoint pt2 "\nExtension line location and length: "))
     (command ".line" pt2 pt3 "")
     (reset nil)
    ) ; end of ext
    Last edited by Opie; 2018-08-20 at 04:14 PM. Reason: [code] tags added

Similar Threads

  1. Calling a LISP function in many drawings
    By daniel.j.wright112877 in forum AutoLISP
    Replies: 12
    Last Post: 2012-10-05, 09:48 PM
  2. Commands being cancelled-why?
    By mrrhbjr in forum ACA General
    Replies: 4
    Last Post: 2010-05-29, 12:58 AM
  3. Boolean Operation error - a null solid has been created. cancelled
    By danzashishimai in forum AutoCAD 3D (2007 and above)
    Replies: 12
    Last Post: 2007-04-17, 10:18 PM
  4. Calling commands
    By Chad Smith in forum Revit - API
    Replies: 1
    Last Post: 2007-03-02, 08:01 PM
  5. Help with Sub Function and calling it from main Function
    By avinash00002002 in forum VBA/COM Interop
    Replies: 1
    Last Post: 2006-06-21, 02:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •