AutoCAD Map 3D Forum
Welcome to Autodesk’s AutoCAD Map 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Automate a repetitive task in MAP 3D

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
mmendezJLGA9
271 Views, 8 Replies

Automate a repetitive task in MAP 3D

I want to automate this really simple task:

1. MAPIMPORT a kmz file (with some info that goes into a block)

2. Go to paper space. 

3. Go to viewport, zoom extents, use scale down 1:X.

4. Give it an aerial image (GEOMAP, A, GEOMAPIMAGE, V)

 

When searching the web, I end up with the regular AutoCAD Visual LISP API stuff, but nothing on MAP 3D API. 

Am I looking in the wrong place for the answers?

8 REPLIES 8
Message 2 of 9

Hi @mmendezJLGA9 

This is a common task.

If you upload your KMZ/KML and your Block,  the forum can give you step-by-step instructions.

 

There are too many (way, way, waaay too many) questions that must be asked (and answered by you with solid answers) to give simple a, b, c, .........type answer.

 

Some questions (not all questions) are:

  • Are you importing a point, a line, or a polygon? Or a combination of those?
  • Does your block have an attribute? If your block doesn't have an attribute then it cannot hold any KMZ data.
  • What is the attribute's TAG in your block (or the name of the attribute that will store the KMZ data)? It's OK to answer with 'I don't know' if you don't know.
  • Additional miscellaneous questions I can't think of at the moment.

<<Note: If your block is not suitable for this operation, then a new block will have to be designed or your existing block will need to be modified.>>   

 

As you can see, it'll be faster (way, way faster) if you upload your KMZ and your block.

 

Chicagolooper
Message 3 of 9

There is nothing wrong with the manual process, it totally works, I just can't find out how to automate it.

 

The block is attributed with the "kml_name" in lower case. I wish the block was attenuated, too, but that fix is about 15 seconds, so no big deal. 

 

I guess I am asking if I use LISP for this and where is the API stuff for MAP 3D?

Also, am I looking in the correct area?

 

 

Message 4 of 9

Hi@mmendezJLGA9 

 

Of course there's a streamlined method, it's called MAPIMPORT. And the command (or procedure since it's several clicks and not just one) already exists. That procedure takes 'data' from the KMZ, assuming it's real data to begin with and not something else. 

 

If you do it right, the KMZ's data is harvested (in your case the data it's kml_name) and the data is inserted into your block. Buuut......to insert it correctly you need to disclose whether your block has an attribute.....so the attribute's TAG (or the name of the attribute) can be populated by the correct KMZ data. In other words, HOW (or what settings do you need when running MAPIMPORT) for a specific block to get populated  with THIS attribute and not THAT attribute.

 

The last thing you want is for your KMZ data to be inserted, but not inserted into the right block--blocks in NORTH locations might get populated by data that should be inserted to SOUTH blocks...and blocks in the WEST are being populated by data that belongs to blocks in the EAST.

 

The MapImport command can do all that and do it accurately with only a few clicks. Explaining HOW-TO is simply hard to explain in a Forum unless you upload a sample of the real-deal data and the actual block you plan to use.  

 

You can even enhance your MapImport by limiting the location the imported data. If you have KMZ data covering 3-square miles, you may only want to limit the import to only 1-square mile and ignore the rest. You can define your 'area' by drawing a plain-vanilla rectangle or square.

 

You may also segregate your imported blocks by allocating them across several layers, e.g. you have 100 KMZ points and your data indicates 50 are existing utility poles, 40 are proposed utility poles, and 10 are poles to be removed/demolished. Your MapImport can insert and place your blocks on 3 separate layers: existing, proposed, and demo using the existing data.

 

This single command is flexible, it can be used with other data-rich formats too, such as SDF and shapefile. It can easily be used in four different ways so you wouldn't need four separate lisp routines (SMH!). With high level creativity you could add another dozen ways and with ultra-high-mega-super-duper creatively 2 more dozen on top of that.   

 

Can you share some data? 

Chicagolooper
Message 5 of 9
jezzydoh
in reply to: mmendezJLGA9

thanks for this, i had a similar problem and my brain just wasn't braining.

Message 6 of 9
O_Eckmann
in reply to: mmendezJLGA9

Hi @mmendezJLGA9 ,

 

1.  MAPIMPORT when you've saved your Import Profil

 

(command "_-MAPIMPORT" "OGCKML" "C:/DATA/FOLDER/FILE.KML" "_Y" "C:/DATA/PROFIL.IPF" "")

 

 2. Go to paper space

 

(setvar "TILEMODE" 0)

 

3. Go to viewport, zoom extend, zoom 1:X

 

(command "_MSPACE")
(command "_ZOOM" "_E")
(command "_ZOOM" "1000/5000X")

 

4. Geocarte

 

(command "_GEOMAP" "_A")
(command "_GEOMAPIMAGE" "_V")
(command "_GEOMAP" "_O")
(command "_PSPACE")

 

 

Olivier Eckmann

EESignature

Message 7 of 9
pendean
in reply to: mmendezJLGA9


@mmendezJLGA9 wrote:

....Am I looking in the wrong place for the answers?


While you digest the other excellent feedback... you may have missed a built in tool that repeats your on screen steps for you that can be recalled and reused often on demand

https://www.autodesk.com/blogs/autocad/action-macros-in-autocad/ 

 

HTH

Message 8 of 9
mmendezJLGA9
in reply to: O_Eckmann

@ChicagoLooper I've been using the MAPIMPORT method for years and just found out about that secret Driver Options... button. Totally a time saver and error reducer.

 

@O_Eckmann If it was just me, I would totally do this. Also, what is this "OGCKML"?

 

@pendean I am probably going to try the Action Macro next week.

 

But...

 

Message 9 of 9
O_Eckmann
in reply to: mmendezJLGA9

Hi @mmendezJLGA9 

 

Here is list of possible format to export

 

Commande: (command "_-mapimport" "?" "*")
_-mapimport Entrer type de fichier à importer ou ? pour obtenir la liste <ARCINFO>:? Entrer type(s) de fichier dans liste <*>:: * Types de fichier définis.
ASCII_POINT
FDO_SDF
E00
ARCINFO
SHP
FDO_GEN
MITAB
DGN_V7_V8
OGCKML
CITYGML
GML
MIF
SDTS
FDO_SQLITE
DNF
VPF

 

Olivier Eckmann

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report