Jump to content

Incorrect Data Type? Using "LM:directoryfiles" function


Ross Dunkley

Recommended Posts

Hi,

I am running into problems with my program when I try to use the output from the "LM:directoryfiles" function.

If I try to use the output from the "LM:directoryfiles" function (findjgw) I am getting the following error...

error: bad argument type: (or stringp symbolp): ("L:\\DESIGN\\2018\\2018-290 Atkinson Crescent, ALDINGA BEACH\\Work in Progress CAD\\References CAD\\2018-290 Image\\2018-290 Image.jgw")

(findjgw) returns the following "L:\\DESIGN\\2018\\2018-290 Atkinson Crescent, ALDINGA BEACH\\Work in Progress CAD\\References CAD\\2018-290 Image\\2018-290 Image.jgw" and if I enter this actual text string in my code it works, but it wont when referring to the variable (findjgw).

 

Is it because I am trying to use a list as a string? If I only use the first element of a list are they not the same thing?

 

Snippet that seems to be thew problem...

; Search Project "References CAD" Folder for ".jgw" files and Count how many...
(setq rcpath (strcat sfpath "Work in Progress CAD\\References CAD\\"))
(setq findjgw (LM:directoryfiles rcpath "*.jgw" T))
(setq countjgw (length findjgw))
(cond
	(	
		(= countjgw 1) 
		(princ "\nOnly 1 Georeferenced Aerial Image exists in 'References CAD folder'")		
		(setq jpgname (vl-string-subst "jpg" "jgw" findjgw))
		(setq intFileDia (getvar "filedia"))
		(setvar "filedia" 0)
		(command "mapiinsert" jpgname "")
		(command "zoom" "e")
		(setvar "filedia" intFileDia)	
		(princ "\nGeoreferenced Aerial Imagery Inserted...") 	
	)
	(	(> countjgw 1) 
		(alert "More than 1 Georeferenced Aerial Image exists in 'References CAD folder'...\nPlease select file to insert...")
		(command "mapiinsert")
		(princ)
	)
	(t nil)
);End Cond

I will attach the full copy also.

 

Regards, Ross.

 

ONK Mapiinsert 4.lsp

Link to comment
Share on other sites

First impression: the problem is here: findjgw is a list, (vl-string-subst  expects a string there.

 

(setq jpgname (vl-string-subst "jpg" "jgw" findjgw))

This should work:

 

(setq jpgname (vl-string-subst "jpg" "jgw" (nth 0 findjgw )))

 

  • Like 1
Link to comment
Share on other sites

One thing I see that could cause an issue is 

11 hours ago, Ross Dunkley said:

Is it because I am trying to use a list as a string? If I only use the first element of a list are they not the same thing?

Yes .. you cannot pass a list to vl-string-subst. Use (car findjgw).

 

Also your UNC path check could be simplified to this:

(if (wcmatch (getvar 'dwgprefix) "\\*")
  "UNC"
  "MAPPED"
)

Just guessing, but this looks like an incorrect path too.

(setq sfpath (strcat "\\\\" drive "\\" dir1 "\\" dir2 "\\" dir3 "\\" dir4 "\\"))

 

  • Like 1
Link to comment
Share on other sites

Thanks guys!  The following line did the trick...

(setq jpgname (vl-string-subst "jpg" "jgw" (car findjgw)))

 


 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...