search in attributes during mapimport

search in attributes during mapimport

Anonymous
Not applicable
1,167 Views
7 Replies
Message 1 of 8

search in attributes during mapimport

Anonymous
Not applicable

Hi everyone,

it seems I might need a little help...

I need to import shape files into my drawing. These shape files always have a different name and I cant tell what the name is gonna be (random generated). During the import I change the shp files layer name into one of it's attribute's number. The next part in the importing procedure is when the imported newly named layer is merged to an existing one. The code works just fine.

_$
(defun c:shp () 

(command "._mapimport" "n"			
	 		"fólia"			
	 		"Adott"			
	  		(vl-string-trim ".shp" (strcat "Default:"(getfiled "Válaszd ki az shp fájlokat" "" "shp" 8)))	
	  		"fólia"			
	 		"adatmezőből"		
	 		"v_elhmod"		
	 		"adat"			
	 		"létrehoz"		
	 		"tovább"
	  		"tovább")
(if (tblsearch "Layer" "2") 
(progn
(setq OLDLAY "2")
(setq NEWLAY "Opa")
(command "-laymrg" "N" OLDLAY "" "N" NEWLAY "i")))

(if (tblsearch "Layer" "3")
(progn  
(setq OLDLAY "3")
(setq NEWLAY "Opa")
(command "-laymrg" "N" OLDLAY "" "N" NEWLAY "i")))
  
(if (tblsearch "Layer" "1")
(progn
(setq OLDLAY "1")
(setq NEWLAY "Opl")
(command "-laymrg" "N" OLDLAY "" "N" NEWLAY "i"))) 
)
_$

 The problem is that some shp file's attribute data sometimes named V_ELHMOD instead of v_elhmod. So the code works with lowercases. Is there a way to solve this problem? Maybe with a searching code that runs through the attribute table and if it is written with capital letter then return with V_ELHMOD?

 

Thanks for the answers!

David

0 Likes
1,168 Views
7 Replies
Replies (7)
Message 2 of 8

Moshe-A
Mentor
Mentor

David,

 

check (strcase) function (it will do just what you want)

 

Moshe

 

0 Likes
Message 3 of 8

Anonymous
Not applicable

Moshe,

 

the imported shp file's attribute is named (one of it)  v_elhmod or V_ELHMOD. I dont know which one is going to be in the shp file. How can I use strcase in this situation? Mapimport needs a string, the same string that the shp got in the attribute table. Sorry, maybe I was not too clear in my previous letter.

 

David

0 Likes
Message 4 of 8

dlanorh
Advisor
Advisor
Where you are checking the attribute "tag" name use (strcase "tag name"), to always make it uppercase, or conversely use (strcase "tag name" T) to make it always lowercase in the comparison.

I am not one of the robots you're looking for

0 Likes
Message 5 of 8

Anonymous
Not applicable

I did google strcase function, the usage of it is clear :D. If the tag name is always uppercase or lower, it doesnt matter. The problem is that I dont know which one should I use. Because if in the attribute table its lowercase and in my code is always upper, then the code wont work the way I want.

0 Likes
Message 6 of 8

Moshe-A
Mentor
Mentor

if you need to know if the string all lowercase or uppercase then write a simple function

to find it.

 

 

 

0 Likes
Message 7 of 8

dlanorh
Advisor
Advisor

Post removed

I am not one of the robots you're looking for

0 Likes
Message 8 of 8

dlanorh
Advisor
Advisor

Perhaps your question could be answered better here ->https://forums.autodesk.com/t5/autocad-map-3d-forum/bd-p/85

You can't search the data until it is imported.

I am not one of the robots you're looking for

0 Likes