lentityp during mapimport

lentityp during mapimport

Anonymous
Not applicable
1,368 Views
16 Replies
Message 1 of 17

lentityp during mapimport

Anonymous
Not applicable

Hi everyone,

this is my code so far.

 

 

_$
(defun c:shp_hir () 

(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"						
	 		(if (=(entnext "v_elhmod")"v_elhmod") "v_elhmod" "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"))) 

)
_$

With this line I am trying to get one of the object data's name from a layer that I want to import.

(if (=(entnext "v_elhmod")"v_elhmod") "v_elhmod" "V_ELHMOD")

Sadly i get lentityp. Once I get the correct object data's name (v_elhmod or V_ELHMOD) I am going to set the imported layer's name to the object's data. Then the "if part" takes place.

Can anyone help with this?

Thanks

David 

 

0 Likes
1,369 Views
16 Replies
Replies (16)
Message 2 of 17

dlanorh
Advisor
Advisor

lentityp error : A function requiring an entity argument has been passed an argument of incorrect data type with the value noted in the error message. Usually a result of passing the entget function a null entity argument.

 

I'm not certain, as i've never used mapimport, but i think you're trying to access an entity before it is imported.

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

0 Likes
Message 3 of 17

Moshe-A
Mentor
Mentor

Hi,

 

the (entnext) function can take 1 argument (an ename) , and you supplied there a string

so the error tells you it's a  bad argument type ("v_elhmod"  is a string)

 

i suggests that before you call (command "mapimport") evaluate all the arguments the command is need (put them in variables) or use (vl-cmdf) function which is the same as (command) but will actually evaluate all the arguments you supply before it invokes the mapimport command.

 

Moshe

 

0 Likes
Message 4 of 17

dlanorh
Advisor
Advisor

If you are trying to import multiple map shape files, and mapimport is failing because  "v_elhmod" is the wrong case; then select your files and store them in a list. Then loop through the list importing each file. If the mapiport is wrapped in a "vl-catch-all-apply" and "vl-catch-all-error-p" then you can direct it to try a second mapimport with "V_ELHMOD".

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

0 Likes
Message 5 of 17

Anonymous
Not applicable
yes. is there a way to do that?
0 Likes
Message 6 of 17

dlanorh
Advisor
Advisor
I've never tried it. i'll have a look over the weekend. Maybe something by Monday, but I can't test as I only have Vanilla Autocad.

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

0 Likes
Message 7 of 17

dlanorh
Advisor
Advisor

David,

As i said previously i have no knowledge of 3D map or the mapimport command. I have changed the mapimport command from your code, see below.

 

(setq shp_file (vl-string-trim ".shp" (strcat "Default:"(getfiled "Válaszd ki az shp fájlokat" "" "shp" 8))))
(command "._mapimport" "n" "fólia" "Adott" shp_file "fólia" "adatmezőből" "v_elhmod" "adat" "létrehoz" "tovább" "tovább")

In a new blank drawing, copy and paste the first line above and press enter. If I understand your code correctly, this is designed to get a shape file name. I've purposely moved this out of the import command. The second line is to import that file into the drawing, but I'm unsure what the minimum is to complete this task. Please remove from this second line anything that is not part of just importing the file, then copy, paste press enter again. No accessing attributes at the moment. Once that is completed, please save the drawing in autocad 2010 format and attach it.

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

0 Likes
Message 8 of 17

john.uhden
Mentor
Mentor

Your problem appears to be with

(entnext "v_elhmod")

The entnext function requires an argument that is an entity name, not a string. Or no argument to get the first entity in the drawing database.

 

John F. Uhden

0 Likes
Message 9 of 17

dlanorh
Advisor
Advisor

He's not getting any entity as the "getfiled" line is not returning a file name but text "Default:filename" with no file extension; and I think he is trying to run the dialog version of  "mapimport" without "filedia" being set to 0.

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

0 Likes
Message 10 of 17

Anonymous
Not applicable

Hi,

I have tried everything everyone said I should try. Well non of them worked. 

I am attaching the file as you described.

 

Thanks

David

0 Likes
Message 11 of 17

dlanorh
Advisor
Advisor
(setq shp_file (vl-string-trim ".shp" (strcat "Default:"(getfiled "Válaszd ki az shp fájlokat" "" "shp" 8))))

 when you run the above on the command line it returns "Default:xxxxx", a text string, where xxxxx is the name of the shape file selected. Is this what you intended? It is not a shape file name and so cannot be used in the "mapimport" command.

I do not know which version of map 3D you are using but the mapimport command for autocad 3D should take the form

(command "-MAPIMPORT" "SHP" SHP-file-name "YES" IPF-file-name "PROCEED")

I am at a loss at what you are trying to do since translating you code doesn't help and i don't have access to MAP 3D.

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

0 Likes
Message 12 of 17

Anonymous
Not applicable

For some reason the "Default:xxx" is the proper name of the shp file. I tried to run the code without the vl-string-trim part but didnt work. When the mapimport get to the point when it needs az shp file name, you can type ? then * to list the possible shp file names. The program lists them in a form like that Default:xxx. 

 

I am using AutoCad Map 3D 2012 hungarian version. Thats why I cant type english words into the mapimport line...

The code I posted in my first comment runs well, no error occurs or anything. I only need some help with the object data part where I name the shp's layer to one of it's object data name: "v_elhmod" or "V_ELHMOD".

I tried vl-cmdf (I dont know if I used it well) but the lentityp problem showed up too.

 

I guess I have to think of a new approach. 

 

0 Likes
Message 13 of 17

dlanorh
Advisor
Advisor

What happens when you type "-mapimport" on the command line, Does the command line version start?

If not then we're stuck with the dialog version. I'll dig out the "vl-catch-all-apply" code. It should work with "command-s"

 

Doesn't typing "_" infront of English words work  i.e. "_line" for the line command?

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

0 Likes
Message 14 of 17

Anonymous
Not applicable

Yes, they all work, -mapimport and _line too.

0 Likes
Message 15 of 17

Anonymous
Not applicable
_$
(defun c:shp_hirm () 
(setq shp_file (vl-string-trim ".shp" (strcat "Default:"(getfiled "Válaszd ki az shp fájlokat" "" "shp" 8)))) ;gets shp file name(=layer name) for mapimport version
(setq layer_name (vl-string-trim "Default:"(vl-string-trim ".shp" shp_file)))					;gets layer name for laymerge version
(command "._mapimport" "n"		;no profile load				
	 		"fólia"		; layer 			
	 		"adott"		;i choose the layer name with shp_file variable
	 		shp_file	;the variable					
	 		"adat"		;load the object data from:
	  		"létrehoz"	;object data table 									
	  		"tovább"	;process
	 		"tovább")	;process
  
(setq obj_kis (getpropertyvalue layer_name "v_elhmod"))		;search in a layer, named: layer_name for the "v-elhmod" object data
(setq obj_nagy (getpropertyvalue layer_name "V_ELHMOD"))	;same and puts to obj_kis and obj_nagy
  
(if (tblsearch "Layer" layer_name)				;if there is a layer_name 
  (progn
    (if (tblobjname "Layer" "v_elhmod")				;and if there is an object data named "v_elhmod"
      (progn 	
	(command "-laymrg" "N" layer_name "" "N" (itoa obj_kis) "i" ))	;do this
      (progn 
	(command "-laymrg" "N" layer_name "" "N" (itoa obj_nagy) "i" )) ;else this
      );2.if
  );1.progn
);1.if  
(print obj_kis)  
(print obj_nagy)
)
_$

I tried to import the files then change the layer name to "v-elhmod" or "V_ELHMOD" object's  data. I get the ADS request error......

0 Likes
Message 16 of 17

dlanorh
Advisor
Advisor

Do you know which bit is failing, the import or accessing the layer?

 

With your previous code, here is my attempt to catch the error. I am running 2012 and this worked for simple commands.

 

defun catchme ( / err_obj)
  
  (setq err_obj (vl-catch-all-apply 'command-s (list "._mapimport" "n" "fólia" "Adott" (vl-string-trim ".shp" (strcat "Default:"(getfiled "Válaszd ki az shp fájlokat" "" "shp" 8))) "fólia"	"adatmezobol" "v_elhmod" "adat" "létrehoz" "tovább" "tovább")))
  (if (vl-catch-all-error-p err_obj)
    (setq err_obj (vl-catch-all-apply 'command-s (list "._mapimport" "n" "fólia" "Adott" (vl-string-trim ".shp" (strcat "Default:"(getfiled "Válaszd ki az shp fájlokat" "" "shp" 8))) "fólia"	"adatmezobol" "V_ELHMOD" "adat" "létrehoz" "tovább" "tovább")))
  )
 ;rest of code here
 (princ)
)

Hopefully you can adjust to suit your needs. The code format needs to stay the same, as does the use of command-s. It doesn't work with vl-cmdf or command. It first tries "v_elhmod", and if that fails tries "V_ELHMOD".

 

If this doesn't work, i'm stumped, but you could try the AutoCAD MAP 3D Developers Forum that runs here.

 

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

Message 17 of 17

Anonymous
Not applicable

Hi,

thanks for the code but the "V_ELHMOD" part doesnt work 😕 . I dont think its an error if the code cant find an object data. I might try in the developers forum. Thanks for the help!!

 

David

0 Likes