error: bad function:

error: bad function:

anieves228
Enthusiast Enthusiast
2,571 Views
3 Replies
Message 1 of 4

error: bad function:

anieves228
Enthusiast
Enthusiast

Hi all!

I did a post yesterday about this code, but I got it to work so now I have a different problem. I get an "error: bad function:" after I run it. What would cause the error? See code below. Thanks!

 

	(defun c:plsize()

		(vla-get-canonicalmedianame
		(vla-item (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (getvar 'ctab))
		)
	
	)
	
	(DEFUN C:APDF ()
		
			(SETQ A
			(C:PLSIZE)
			)
		
			(COND 
			
					((EQUAL A "ANSI_full_bleed_A_(8.50_x_11.00_Inches)") ( (C:APPDF) ))
					
					((EQUAL A "ANSI_full_bleed_A_(11.00_x_8.50_Inches)") ( (C:LAPDF) ))
					
					((EQUAL A "ANSI_expand_B_(17.00_x_11.00_Inches)") ( (C:BPDF) ))
					
					((EQUAL A "ANSI_expand_C_(22.00_x_17.00_Inches)") ( (C:CPDF) ))
					
					((EQUAL A "ANSI_expand_D_(34.00_x_22.00_Inches)") ( (C:LPDF) ))
					
					
					(t((ALERT "NO LAYOUTS DETECTED")))
			)
			
	)
0 Likes
Accepted solutions (1)
2,572 Views
3 Replies
Replies (3)
Message 2 of 4

Kent1Cooper
Consultant
Consultant
Accepted solution

@anieves228 wrote:

.... I get an "error: bad function:" after I run it. What would cause the error? ....


 

Change this:

  (t((ALERT "NO LAYOUTS DETECTED")))

to this [remove extra parentheses wrapping]:
  (t (ALERT "NO LAYOUTS DETECTED"))

 

or even just this [if it's the last condition, and only the one thing needs to be done, you don't need the T "trigger"]:

  ((ALERT "NO LAYOUTS DETECTED"))

 

EDIT:  and likewise these:

  ((EQUAL A "ANSI_full_bleed_A_(8.50_x_11.00_Inches)") ( (C:APPDF) ))

to this [and the equivalent for others]:

  ((EQUAL A "ANSI_full_bleed_A_(8.50_x_11.00_Inches)") (C:APPDF))

 

To explain further:

  ( ; this opens the condition

    (EQUAL A "ANSI_full_bleed_A_(8.50_x_11.00_Inches)"); the test expression

    (C:APPDF); this is what to do if the test returns other-than-nil

  ) ; this closes the condition

 

As you had it, the what-to-do was:

  ((C:APPDF))

The first thing after a left parenthesis in this situation needs to be the name of the function that the left parenthesis is opening, but   (C:APPDF)  with parentheses included  is not a function name.

Kent Cooper, AIA
0 Likes
Message 3 of 4

Shneuph
Collaborator
Collaborator
(cond	;begin cond
  (	;cond1
   (= (getvar "ltscale") 1);condition1
   (princ "yes");action 1
  )		;end cond1
  (		;cond2
   T		;condition2
   (princ "hi")	;action 2
  )		;end cond2
)		;end cond

I think it's the format of our cond function

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
0 Likes
Message 4 of 4

anieves228
Enthusiast
Enthusiast

Awesome! thank you so much! It working now!

0 Likes