Another ; error: bad function: Please help

Another ; error: bad function: Please help

anieves228
Enthusiast Enthusiast
1,844 Views
9 Replies
Message 1 of 10

Another ; error: bad function: Please help

anieves228
Enthusiast
Enthusiast

Hello all! I received an ; error: bad function: I'm not sure why this time. Too many conditions maybe? Any help would be appreciated.

 

Thanks!

 

	(defun c:plsize()

		(vla-get-canonicalmedianame
		(vla-item (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (getvar 'ctab))
		)
	)

(DEFUN C:plsizeall ()
		
		(SETQ D
			(C:PLSIZE)
		)
		
		(COND 	
	
			((EQUAL D "ISO_full_bleed_B5_(250.00_x_176.00_MM)")		("ISO full bleed B5 (250.00 x 176.00 MM)"))
			((EQUAL D "ISO_full_bleed_B5_(176.00_x_250.00_MM)")		("ISO full bleed B5 (176.00 x 250.00 MM)"))
			((EQUAL D "ISO_full_bleed_B4_(353.00_x_250.00_MM)")		("ISO full bleed B4 (353.00 x 250.00 MM)"))
			((EQUAL D "ISO_full_bleed_B4_(250.00_x_353.00_MM)")		("ISO full bleed B4 (250.00 x 353.00 MM)"))
			((EQUAL D "ISO_full_bleed_B3_(500.00_x_353.00_MM)")		("ISO full bleed B3 (500.00 x 353.00 MM)"))
			((EQUAL D "ISO_full_bleed_B3_(353.00_x_500.00_MM)")		("ISO full bleed B3 (353.00 x 500.00 MM)"))
			((EQUAL D "ISO_full_bleed_B2_(707.00_x_500.00_MM)")		("ISO full bleed B2 (707.00 x 500.00 MM)"))
			((EQUAL D "ISO_full_bleed_B2_(500.00_x_707.00_MM)")		("ISO full bleed B2 (500.00 x 707.00 MM)"))
			((EQUAL D "ISO_full_bleed_B1_(1000.00_x_707.00_MM)")	("ISO full bleed B1 (1000.00 x 707.00 MM)"))
			((EQUAL D "ISO_full_bleed_B1_(707.00_x_1000.00_MM)")	("ISO full bleed B1 (707.00 x 1000.00 MM)"))
			((EQUAL D "ISO_full_bleed_B0_(1414.00_x_1000.00_MM)")	("ISO full bleed B0 (1414.00 x 1000.00 MM)"))
			((EQUAL D "ISO_full_bleed_B0_(1000.00_x_1414.00_MM)")	("ISO full bleed B0 (1000.00 x 1414.00 MM)"))
			((EQUAL D "ISO_full_bleed_A5_(210.00_x_148.00_MM)")		("ISO full bleed A5 (210.00 x 148.00 MM)"))
			((EQUAL D "ISO_full_bleed_A5_(148.00_x_210.00_MM)")		("ISO full bleed A5 (148.00 x 210.00 MM)"))
			((EQUAL D "ISO_full_bleed_2A0_(1189.00_x_1682.00_MM)")	("ISO full bleed 2A0 (1189.00 x 1682.00 MM)"))
			((EQUAL D "ISO_full_bleed_4A0_(1682.00_x_2378.00_MM)")	("ISO full bleed 4A0 (1682.00 x 2378.00 MM)"))
			((EQUAL D "ISO_full_bleed_A4_(297.00_x_210.00_MM)")		("ISO full bleed A4 (297.00 x 210.00 MM)"))
			((EQUAL D "ISO_full_bleed_A4_(210.00_x_297.00_MM)")		("ISO full bleed A4 (210.00 x 297.00 MM)"))
			((EQUAL D "ISO_full_bleed_A3_(420.00_x_297.00_MM)")		("ISO full bleed A3 (420.00 x 297.00 MM)"))
			((EQUAL D "ISO_full_bleed_A3_(297.00_x_420.00_MM)")		("ISO full bleed A3 (297.00 x 420.00 MM)"))
			((EQUAL D "ISO_full_bleed_A2_(594.00_x_420.00_MM)")		("ISO full bleed A2 (594.00 x 420.00 MM)"))
			((EQUAL D "ISO_full_bleed_A2_(420.00_x_594.00_MM)")		("ISO full bleed A2 (420.00 x 594.00 MM)"))
			((EQUAL D "ISO_full_bleed_A1_(841.00_x_594.00_MM)")		("ISO full bleed A1 (841.00 x 594.00 MM)"))
			((EQUAL D "ISO_full_bleed_A1_(594.00_x_841.00_MM)")		("ISO full bleed A1 (594.00 x 841.00 MM)"))
			((EQUAL D "ISO_full_bleed_A0_(841.00_x_1189.00_MM)")	("ISO full bleed A0 (841.00 x 1189.00 MM)"))
			((EQUAL D "ARCH_full_bleed_E1_(30.00_x_42.00_Inches)")	("ARCH full bleed E1 (30.00 x 42.00 Inches)"))
			((EQUAL D "ARCH_full_bleed_E_(36.00_x_48.00_Inches)")	("ARCH full bleed E (36.00 x 48.00 Inches)"))
			((EQUAL D "ARCH_full_bleed_D_(36.00_x_24.00_Inches)")	("ARCH full bleed D (36.00 x 24.00 Inches)"))
			((EQUAL D "ARCH_full_bleed_D_(24.00_x_36.00_Inches)")	("ARCH full bleed D (24.00 x 36.00 Inches)"))
			((EQUAL D "ARCH_full_bleed_C_(24.00_x_18.00_Inches)")	("ARCH full bleed C (24.00 x 18.00 Inches)"))
			((EQUAL D "ARCH_full_bleed_C_(18.00_x_24.00_Inches)")	("ARCH full bleed C (18.00 x 24.00 Inches)"))
			((EQUAL D "ARCH_full_bleed_B_(18.00_x_12.00_Inches)")	("ARCH full bleed B (18.00 x 12.00 Inches)"))
			((EQUAL D "ARCH_full_bleed_B_(12.00_x_18.00_Inches)")	("ARCH full bleed B (12.00 x 18.00 Inches)"))
			((EQUAL D "ARCH_full_bleed_A_(12.00_x_9.00_Inches)")	("ARCH full bleed A (12.00 x 9.00 Inches)"))
			((EQUAL D "ARCH_full_bleed_A_(9.00_x_12.00_Inches)")	("ARCH full bleed A (9.00 x 12.00 Inches)"))
			((EQUAL D "ANSI_full_bleed_F_(28.00_x_40.00_Inches)")	("ANSI full bleed F (28.00 x 40.00 Inches)"))
			((EQUAL D "ANSI_full_bleed_E_(34.00_x_44.00_Inches)")	("ANSI full bleed E (34.00 x 44.00 Inches)"))
			((EQUAL D "ANSI_full_bleed_D_(34.00_x_22.00_Inches)")	("ANSI full bleed D (34.00 x 22.00 Inches)"))
			((EQUAL D "ANSI_full_bleed_D_(22.00_x_34.00_Inches)")	("ANSI full bleed D (22.00 x 34.00 Inches)"))
			((EQUAL D "ANSI_full_bleed_C_(22.00_x_17.00_Inches)")	("ANSI full bleed C (22.00 x 17.00 Inches)"))
			((EQUAL D "ANSI_full_bleed_C_(17.00_x_22.00_Inches)")	("ANSI full bleed C (17.00 x 22.00 Inches)"))
			((EQUAL D "ANSI_full_bleed_B_(17.00_x_11.00_Inches)")	("ANSI full bleed B (17.00 x 11.00 Inches)"))
			((EQUAL D "ANSI_full_bleed_B_(11.00_x_17.00_Inches)")	("ANSI full bleed B (11.00 x 17.00 Inches)"))
			((EQUAL D "ANSI_full_bleed_A_(11.00_x_8.50_Inches)")	("ANSI full bleed A (11.00 x 8.50 Inches)"))
			((EQUAL D "ANSI_full_bleed_A_(8.50_x_11.00_Inches)")	("ANSI full bleed A (8.50 x 11.00 Inches)"))
			((EQUAL D "ISO_expand_A0_(841.00_x_1189.00_MM)")		("ISO expand A0 (841.00 x 1189.00 MM)"))
			((EQUAL D "ISO_A0_(841.00_x_1189.00_MM)")				("ISO A0 (841.00 x 1189.00 MM)"))
			((EQUAL D "ISO_expand_A1_(841.00_x_594.00_MM)")			("ISO expand A1 (841.00 x 594.00 MM)"))
			((EQUAL D "ISO_expand_A1_(594.00_x_841.00_MM)")			("ISO expand A1 (594.00 x 841.00 MM)"))
			((EQUAL D "ISO_A1_(841.00_x_594.00_MM)")				("ISO A1 (841.00 x 594.00 MM)"))
			((EQUAL D "ISO_A1_(594.00_x_841.00_MM)")				("ISO A1 (594.00 x 841.00 MM)"))
			((EQUAL D "ISO_expand_A2_(594.00_x_420.00_MM)")			("ISO expand A2 (594.00 x 420.00 MM)"))
			((EQUAL D "ISO_expand_A2_(420.00_x_594.00_MM)")			("ISO expand A2 (420.00 x 594.00 MM)"))
			((EQUAL D "ISO_A2_(594.00_x_420.00_MM)")				("ISO A2 (594.00 x 420.00 MM)"))
			((EQUAL D "ISO_A2_(420.00_x_594.00_MM)")				("ISO A2 (420.00 x 594.00 MM)"))
			((EQUAL D "ISO_expand_A3_(420.00_x_297.00_MM)")			("ISO expand A3 (420.00 x 297.00 MM)"))
			((EQUAL D "ISO_expand_A3_(297.00_x_420.00_MM)")			("ISO expand A3 (297.00 x 420.00 MM)"))
			((EQUAL D "ISO_A3_(420.00_x_297.00_MM)")				("ISO A3 (420.00 x 297.00 MM)"))
			((EQUAL D "ISO_A3_(297.00_x_420.00_MM)")				("ISO A3 (297.00 x 420.00 MM)"))
			((EQUAL D "ISO_expand_A4_(297.00_x_210.00_MM)")			("ISO expand A4 (297.00 x 210.00 MM)"))
			((EQUAL D "ISO_expand_A4_(210.00_x_297.00_MM)")			("ISO expand A4 (210.00 x 297.00 MM)"))
			((EQUAL D "ISO_A4_(297.00_x_210.00_MM)")				("ISO A4 (297.00 x 210.00 MM)"))
			((EQUAL D "ISO_A4_(210.00_x_297.00_MM)")				("ISO A4 (210.00 x 297.00 MM)"))
			((EQUAL D "ARCH_expand_E1_(30.00_x_42.00_Inches)")		("ARCH expand E1 (30.00 x 42.00 Inches)"))
			((EQUAL D "ARCH_E1_(30.00_x_42.00_Inches)")				("ARCH E1 (30.00 x 42.00 Inches)"))
			((EQUAL D "ARCH_expand_E_(36.00_x_48.00_Inches)")		("ARCH expand E (36.00 x 48.00 Inches)"))
			((EQUAL D "ARCH_E_(36.00_x_48.00_Inches)")				("ARCH E (36.00 x 48.00 Inches)"))
			((EQUAL D "ARCH_expand_D_(36.00_x_24.00_Inches)")		("ARCH expand D (36.00 x 24.00 Inches)"))
			((EQUAL D "ARCH_expand_D_(24.00_x_36.00_Inches)")		("ARCH expand D (24.00 x 36.00 Inches)"))
			((EQUAL D "ARCH_D_(36.00_x_24.00_Inches)")				("ARCH D (36.00 x 24.00 Inches)"))
			((EQUAL D "ARCH_D_(24.00_x_36.00_Inches)")				("ARCH D (24.00 x 36.00 Inches)"))
			((EQUAL D "ARCH_expand_C_(24.00_x_18.00_Inches)")		("ARCH expand C (24.00 x 18.00 Inches)"))
			((EQUAL D "ARCH_expand_C_(18.00_x_24.00_Inches)")		("ARCH expand C (18.00 x 24.00 Inches)"))
			((EQUAL D "ARCH_C_(24.00_x_18.00_Inches)")				("ARCH C (24.00 x 18.00 Inches)"))
			((EQUAL D "ARCH_C_(18.00_x_24.00_Inches)")				("ARCH C (18.00 x 24.00 Inches)"))
			((EQUAL D "ANSI_expand_E_(34.00_x_44.00_Inches)")		("ANSI expand E (34.00 x 44.00 Inches)"))
			((EQUAL D "ANSI_E_(34.00_x_44.00_Inches)")				("ANSI E (34.00 x 44.00 Inches)"))
			((EQUAL D "ANSI_expand_D_(34.00_x_22.00_Inches)")		("ANSI expand D (34.00 x 22.00 Inches)"))
			((EQUAL D "ANSI_expand_D_(22.00_x_34.00_Inches)")		("ANSI expand D (22.00 x 34.00 Inches)"))
			((EQUAL D "ANSI_D_(34.00_x_22.00_Inches)")				("ANSI D (34.00 x 22.00 Inches)"))
			((EQUAL D "ANSI_D_(22.00_x_34.00_Inches)")				("ANSI D (22.00 x 34.00 Inches)"))
			((EQUAL D "ANSI_expand_C_(22.00_x_17.00_Inches)")		("ANSI expand C (22.00 x 17.00 Inches)"))
			((EQUAL D "ANSI_expand_C_(17.00_x_22.00_Inches)")		("ANSI expand C (17.00 x 22.00 Inches)"))
			((EQUAL D "ANSI_C_(22.00_x_17.00_Inches)")				("ANSI C (22.00 x 17.00 Inches)"))
			((EQUAL D "ANSI_C_(17.00_x_22.00_Inches)")				("ANSI C (17.00 x 22.00 Inches)"))
			((EQUAL D "ANSI_expand_B_(17.00_x_11.00_Inches)")		("ANSI expand B (17.00 x 11.00 Inches)"))
			((EQUAL D "ANSI_expand_B_(11.00_x_17.00_Inches)")		("ANSI expand B (11.00 x 17.00 Inches)"))
			((EQUAL D "ANSI_B_(17.00_x_11.00_Inches)")				("ANSI B (17.00 x 11.00 Inches)"))
			((EQUAL D "ANSI B (11.00 x 17.00 Inches)")				("ANSI B (11.00 x 17.00 Inches)"))
			((EQUAL D "ANSI_expand_A_(11.00_x_8.50_Inches)")		("ANSI expand A (11.00 x 8.50 Inches)"))
			((EQUAL D "ANSI_expand_A_(8.50_x_11.00_Inches)")		("ANSI expand A (8.50 x 11.00 Inches)"))
			((EQUAL D "ANSI_A_(11.00_x_8.50_Inches)")				("ANSI A (11.00 x 8.50 Inches)"))
			((EQUAL D "ANSI_A_(8.50_x_11.00_Inches)")				("ANSI A (8.50 x 11.00 Inches)"))

			(ALERT "NO LAYOUTS DETECTED \nCHECK LAYOUT ORIENTATION")
		)
	)
0 Likes
1,845 Views
9 Replies
Replies (9)
Message 2 of 10

cadffm
Consultant
Consultant

Open a new file or re-open the current file, then try it again. Still the same issue/message?

Sebastian

0 Likes
Message 3 of 10

anieves228
Enthusiast
Enthusiast

opened and closed my current file and tried a new one. Still the same problem.

0 Likes
Message 4 of 10

john.uhden
Mentor
Mentor

I noticed that each of your conditions is returning a list with a string inside.

I think AutoLisp is interpreting the list as calling a function, and of course there is no function named "ISO full bleed..."

How about if you ditch the parentheses and return just the string?

Then again, if all you are trying to do is replace underscores with spaces, then why not just...

(vl-string-translate "_" " " D)
?

John F. Uhden

Message 5 of 10

ВeekeeCZ
Consultant
Consultant

Perhaps little shorter version:

 

(defun c:plsize () (vl-string-translate "_" " " (vla-item (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (getvar 'ctab))))

 

...well, @john.uhden  noticed that too.  +1

Message 6 of 10

CodeDing
Mentor
Mentor

@anieves228 ,

 

I agree with @john.uhden ... Your issue, for example, take items like these:

...
((EQUAL D "ISO_full_bleed_B5_(250.00_x_176.00_MM)") ("ISO full bleed B5 (250.00 x 176.00 MM)")) ((EQUAL D "ISO_full_bleed_B5_(176.00_x_250.00_MM)") ("ISO full bleed B5 (176.00 x 250.00 MM)"))
...

...and remove the Red parentheses...

...
((EQUAL D "ISO_full_bleed_B5_(250.00_x_176.00_MM)") "ISO full bleed B5 (250.00 x 176.00 MM)")
((EQUAL D "ISO_full_bleed_B5_(176.00_x_250.00_MM)") "ISO full bleed B5 (176.00 x 250.00 MM)")
...

See if that helps.

 

Best,

~DD

Message 7 of 10

anieves228
Enthusiast
Enthusiast

Ah ok that makes sense.

 

I'm still new to lips. I don't understand VL or have done it yet. I found that portion online. 

0 Likes
Message 8 of 10

john.uhden
Mentor
Mentor

I am pleased to see that you are following my top two mottos...

1.  You've got to start somewhere.

2.  If you don't know, ask.

(my third one would get me in trouble for profanity)

John F. Uhden

Message 9 of 10

ВeekeeCZ
Consultant
Consultant

Sometimes you need search for one but get the pair-one. For such a task might be better to use an associated list.

The thing is that you list your pairs first, then search by a unique key with function (assoc)... then you need to het another member of a pair (cdr).... this approach is very typical for LISP.

 

(DEFUN C:plsizeall ()

  (SETQ LST '(("ISO_full_bleed_B5_(250.00_x_176.00_MM)" . "ISO full bleed B5 (250.00 x 176.00 MM)")
              ("ISO_full_bleed_B5_(176.00_x_250.00_MM)" . "ISO full bleed B5 (176.00 x 250.00 MM)")
              ("ISO_full_bleed_B4_(353.00_x_250.00_MM)" . "ISO full bleed B4 (353.00 x 250.00 MM)")
              ("ISO_full_bleed_B4_(250.00_x_353.00_MM)" . "ISO full bleed B4 (250.00 x 353.00 MM)")))
  
  (SETQ D
         ;(C:PLSIZE)
         "ISO_full_bleed_B5_(176.00_x_250.00_MM)"
        )

  (if (setq a (assoc D LST))
    (cdr a)
    (ALERT "NO LAYOUTS DETECTED \nCHECK LAYOUT ORIENTATION")))
0 Likes
Message 10 of 10

ronjonp
Mentor
Mentor

This is how I'd grab that data ( based off of @ВeekeeCZ  example above ). IMO There is no need to duplicate data within the list.

  (setq	lst '("ISO_full_bleed_B5_(250.00_x_176.00_MM)"
	      "ISO_full_bleed_B5_(176.00_x_250.00_MM)"
	      "ISO_full_bleed_B4_(353.00_x_250.00_MM)"
	      "ISO_full_bleed_B4_(250.00_x_353.00_MM)"
	     )
  )
  (setq d "ISO_full_bleed_B4_(353.00_x_250.00_MM)")
  (alert (vl-string-translate
	   "_"
	   " "
	   (cond ((car (member d lst)))
		 (alert "OH NOES!!")
	   )
	 )
  )

Or just use a list that has spaces instead of underscores.

  (setq	lst '("ISO full bleed B5 (250.00 x 176.00 MM)"
	      "ISO full bleed B5 (176.00 x 250.00 MM)"
	      "ISO full bleed B4 (353.00 x 250.00 MM)"
	      "ISO full bleed B4 (250.00 x 353.00 MM)"
	     )
  )
  (setq d "ISO full bleed B4 (353.00 x 250.00 MM)")
  (alert (cond ((car (member d lst)))
	       (alert "OH NOES!!")
	 )
  )
0 Likes