How to create lisp for mapexport routine?

How to create lisp for mapexport routine?

Anonymous
Not applicable
1,470 Views
5 Replies
Message 1 of 6

How to create lisp for mapexport routine?

Anonymous
Not applicable

I am curious if it is possible to run a lisp that can export several entities as shapefiles.

I am very new to lisp and currently exporting layers to shapefiles individually. I have to do this for multiple drawings but these drawing all have the same layers so I'd like to create a lisp that exports these layers as shapefiles with associated blocks/properties to a folder for qgis analysis.

I was hoping this community can point me in the right direction if this can be done.

 

0 Likes
1,471 Views
5 Replies
Replies (5)
Message 2 of 6

CodeDing
Advisor
Advisor

@Anonymous ,

 

Well, here's the generic documentation for how to MAPEXPORT shp files.

But if you're trying to use it as part of a routine, then I don't know where to find the documentation for it, but here's some info..

 

When you use the MAPEXPORT command prefixed with a hyphen "-", like this:

-MAPEXPORT

then that is what you want to use in a routine.

 

You'll notice that if you input that (with the hyphen) directly into the command prompt, then you will still receive the popup dialog box. BUT , when you use it in an AutoLISP routine, then it will not appear. Try running this and it will help you determine what inputs you need to use to complete the command strictly via lisp:

(progn (command "-MAPEXPORT") (while (> (getvar 'CMDACTIVE) 0) (command pause)))

 

As far as selecting items by layers, you will probably need to use (ssget ...) to select the items you want. Lee Mac has some great explanations on how to use it here:

http://www.lee-mac.com/ssget.html

 

Hope that helps.

Best,

~DD

 

 

 

0 Likes
Message 3 of 6

Haider_of_Sweden
Collaborator
Collaborator

If I may jump into this discussion too.

I have no answers, just more questions.

 

Exporting SHP files is tedious

1. Object type: polygon

2. Select objects to export: select manually: pick

3. Options: treat closed polylines as polygons.

 

Something I would like to see in the context MAPEXPORT and LISP is that I want to be able to select one or more polylines and just get them out as SHP file instead of the multiple steps above.

 

0 Likes
Message 4 of 6

Sea-Haven
Mentor
Mentor

For polygon objects try (setq ss (ssget)) select objects now when in -mapexport answer for select manual and when asked for objects, type !ss it will accept, in lisp just ss. So need to just do correct steps may need a few "" here and there to say stop selecting or accept default. 

 

For multiple selects you would ss ss2 ss3 etc do it prior not within have all the answers before you start to do -mapexport 

0 Likes
Message 5 of 6

Haider_of_Sweden
Collaborator
Collaborator

Thanks @Sea-Haven for your input.

 

It's overkill for me to continue where you left off.

Do you have the time to write the full code for a quick mapexporter and then I can see if I can alter it further?

Would be much appreciated 🙂

0 Likes
Message 6 of 6

Sea-Haven
Mentor
Mentor

Manually do -mapexport answer all questions correct, when finished copy the command history to notepad your 1/2 way there, remove the stuff not needed. 

 

So now convert what you have to lisp. Have a go !

 

Remember in the lisp version may need the selection set already done.