Map 3D Query Macro and Script

Here is a macro combined with a couple of scripts that I wrote this week. What it does is import data from another drawing (containing street names in this case) with a Map 3D query based on a rectangular area.

The Macro:

^C^Cscript;P:/GIS/XREF-CITY-MAP.scr;(alert "Pick two diagonal points to define the import area.");(setq firstp (getpoint "Pick first point: "));\(setq secondp (getpoint "Pick second point: "));\script;P:/GIS/IMPORT-STREETNAMES.scr;

I’ll break it down for you.

The first part of the macro…

script;P:/GIS/XREF-CITY-MAP.scr;

…XREFs a map into the drawing so you can visually pan and zoom to your location. Here is the contents of “XREF-CITY-MAP.scr”:

-layer
n
X-BASE
s
X-BASE

-xref
a
P:\GIS\City-Map.dwg
0,0,0
1
1
0

The middle part of the macro…

(alert "Pick two diagonal points to define the import area.");(setq firstp (getpoint "Pick first point: "));\(setq secondp (getpoint "Pick second point: "));\

…creates an alert box telling the user to pick two diagonal points to define a rectangular area which will be used in the query. Notice that I am defining the coordinates for “firstp” and “secondp” and using back slashes (\) to pause for user input.

The last part of the macro…

script;P:/GIS/IMPORT-STREETNAMES.scr;

…defines and executes the Map 3D query. Here is the contents of “IMPORT-STREETNAMES.scr”:

-xref
d
*
ADEDRAWINGS
al
d
P
a
P
P:
x
at
P:\GIS\Street_Names.dwg
x
adequery
c
p
c
x
d
l
w
c
!firstp
!secondp
p
and
la
*
x
e
d
ADEDRAWINGS
de
Street_Names.dwg
x

Notice that I used “!firstp” and “!secondp” in the script to input the coordinates defined earlier in the macro.

I hope this helps you see the power of macros and scripts. If this is foreign to you, take some time to learn the basics of creating macros.

No Comment

No comments yet

Leave a reply