Malformed list on input

Malformed list on input

Anonymous
Not applicable
2,226 Views
8 Replies
Message 1 of 9

Malformed list on input

Anonymous
Not applicable

I used TD.lsp to insert multiple typical details without having to go through the insert screen everytime. I tried to update it so I could specify what details I wanted instead of having to go through the library. Now that I've added a conditional, I get an error message. Please help.

0 Likes
Accepted solutions (3)
2,227 Views
8 Replies
Replies (8)
Message 2 of 9

hak_vz
Advisor
Advisor
Accepted solution

Try this

 

(defun C:TEST ( / k) ;TYPICAL DETAILS
	(initget 1 "CF GB CS CB CM BW W PR SB ND CD MS TC PS")
	(set k (getkword "\nWhich table are you using? [CF/GB/CS/CB/CM/BW/W/PR/SB/ND/CD/MS/TC/PS] :"))
	(cond
	  	((= k "CF")
			(Foreach itm 
				'( "N:\\CAD\\AutoCad Blocks\\Details\\Block\\"
					"N:\\CAD\\AutoCad Blocks\\Details\\Concrete\\"
					"N:\\CAD\\AutoCad Blocks\\Details\\Foundation\\"
					"N:\\CAD\\AutoCad Blocks\\Details\\Misc\\"
					"N:\\CAD\\AutoCad Blocks\\Details\\Foundation\\"
				)
				(foreach dwg (LM:listbox "Select drawing Files" (vl-directory-files itm "*.dwg" 1) 1)
      					(command "_insert" (strcat itm dwg) pause "1" "1" "0")
    			)
			)
		)	
	  	((= k "W")
			(Foreach itm 
				'( "N:\\CAD\\AutoCad Blocks\\Details\\Block\\"
		 			"N:\\CAD\\AutoCad Blocks\\Details\\Misc\\"
		 			"N:\\CAD\\AutoCad Blocks\\Details\\Truss\\"
		 			"N:\\CAD\\AutoCad Blocks\\Details\\Wood\\"
				)
				(foreach dwg (LM:listbox "Select drawing Files" (vl-directory-files itm "*.dwg" 1) 1)
      					(command "_insert" (strcat itm dwg) pause "1" "1" "0")
    			)
			)
		)	
  	)
)

 

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 9

Anonymous
Not applicable

Awesome! It lets me load it, but now my condition doesn't work. Another nut to crack.

0 Likes
Message 4 of 9

pbejse
Mentor
Mentor
Accepted solution

@Anonymous wrote:

I used TD.lsp to insert multiple typical details without having to go through the insert screen everytime. I tried to update it so I could specify what details I wanted instead of having to go through the library. Now that I've added a conditional, I get an error message. Please help.


The error comes from this line

(set k (getkword "\nWhich table are you using? [CF/GB/CS/CB/CM/BW/W/PR/SB/ND/CD/MS/TC/PS] :"))

Change it to

(setq k (getkword "\nWhich table are you using? [CF/GB/CS/CB/CM/BW/W/PR/SB/ND/CD/MS/TC/PS] :"))

And you are missing a  number of  parenthesis on your cond statement

(Cond
 	( (= k "CF")(foreach ...
			...
		      (foreach ...)
		      )
	 )
	 ( (= k "W") (foreach ...
			...
		       (foreach ... )
		      )
	   )
	 );cond 

 

Here is another way to add more options

 

(defun C:TEST ( / k) ;TYPICAL DETAILS
  (setq details "N:\\CAD\\AutoCad Blocks\\Details\\"
	library '(( "CF" . ("Block" "Concrete" "Foundation" "Misc" "Foundation"))			
		  ( "W"  . ("Block" "Misc" "Truss" "Wood"))
		  )
      )
	(initget 1 "CF GB CS CB CM BW W PR SB ND CD MS TC PS")
	(setq k (getkword "\nWhich table are you using? [CF/GB/CS/CB/CM/BW/W/PR/SB/ND/CD/MS/TC/PS] :"))
  	(if
	  (setq f (Assoc k library))
	     (foreach itm (cdr f)
	       (if (findfile (strcat details itm))
	  	(foreach dwg (LM:listbox "Select drawing Files" (vl-directory-files (setq path (strcat details itm "\\")) "*.dwg" 1) 1)
      					(command "_insert" (strcat path dwg) pause "1" "1" "0")
    			)
		  )
	       )
	  )
  (princ)
  )

 

HTH

0 Likes
Message 5 of 9

hak_vz
Advisor
Advisor

 

 

(defun C:TEST ( / k) ;TYPICAL DETAILS
	(initget 1 "CF GB CS CB CM BW W PR SB ND CD MS TC PS")
	(setq k (getkword "\nWhich table are you using? [CF/GB/CS/CB/CM/BW/W/PR/SB/ND/CD/MS/TC/PS] :"))
	(cond
	  	((= k "CF")
			(Foreach itm 
				'( "N:\\CAD\\AutoCad Blocks\\Details\\Block\\"
					"N:\\CAD\\AutoCad Blocks\\Details\\Concrete\\"
					"N:\\CAD\\AutoCad Blocks\\Details\\Foundation\\"
					"N:\\CAD\\AutoCad Blocks\\Details\\Misc\\"
					"N:\\CAD\\AutoCad Blocks\\Details\\Foundation\\"
				)
				(foreach dwg (LM:listbox "Select drawing Files" (vl-directory-files itm "*.dwg" 1) 1)
      					(command "_insert" (strcat itm dwg) pause "1" "1" "0")
    			)
			)
		)	
	  	((= k "W")
			(Foreach itm 
				'( "N:\\CAD\\AutoCad Blocks\\Details\\Block\\"
		 			"N:\\CAD\\AutoCad Blocks\\Details\\Misc\\"
		 			"N:\\CAD\\AutoCad Blocks\\Details\\Truss\\"
		 			"N:\\CAD\\AutoCad Blocks\\Details\\Wood\\"
				)
				(foreach dwg (LM:listbox "Select drawing Files" (vl-directory-files itm "*.dwg" 1) 1)
      					(command "_insert" (strcat itm dwg) pause "1" "1" "0")
    			)
			)
		)	
  	)
)

 

 

I've had some troubles with reaching forum, so my intervention to change set to setq didn't pass through. This will probably work and here you have solution from @pbejse 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 6 of 9

Anonymous
Not applicable

Last question. I run this, the condition works, but for some reason in my dwg's don't show up in the list box. It used to work on my 2016 autocad, but now I'm on a computer that uses 2014. just checking if this works for other users.

0 Likes
Message 7 of 9

hak_vz
Advisor
Advisor

@Anonymous 

It should work just fine with any version of a Acad including ver 2014 or similar programs that use visual lisp. If you answer on type of structure with correct key value it shows DCL dialog (keywords "CF" "W").

 

Execution is a bit awkward since if you lookup more than directory since code jumps from folder to folder and DCL title is always equal to "Select dwg". What if each folder has files with same name? 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 8 of 9

pbejse
Mentor
Mentor
Accepted solution

@Anonymous wrote:

Last question. I run this, the condition works, but for some reason in my dwg's don't show up in the list box. It used to work on my 2016 autocad, but now I'm on a computer that uses 2014. just checking if this works for other users.


Only time LM:listbox is empty is if there are no drawing files found on specified folder.

You should modfiy TD UPDATE.LSP to check for valid files and show the current keyword selection and folder on the list box title.

(if (setq DwgFiles (vl-directory-files itm "*.dwg" 1))
	(foreach dwg (LM:listbox (strcat "Select Drawing(s) | " k " | "
					 (vl-filename-base (vl-filename-directory itm)))
		       		DwgFiles 1)
		(command "_insert" (strcat itm dwg) pause "1" "1" "0")
	)
    )

HTH

 

0 Likes
Message 9 of 9

Anonymous
Not applicable

thanks for all the help. Turns out the file path on this new computer is different from my last one. Just used findfile to get the path and works like a dream now.

0 Likes