Automated way to create a customized reference grid

Automated way to create a customized reference grid

Albuquerque6PUK4
Contributor Contributor
3,723 Views
18 Replies
Message 1 of 19

Automated way to create a customized reference grid

Albuquerque6PUK4
Contributor
Contributor

Hi,

 

My company works with a lot of georeferenced data and we have to produce drawings, some with dozens of layouts, with reference grids. 
I need help with 2 problems:

  1. I (with some AI help, and some tinkering) created a cumbersome Lisp routine that can execute some commands in all layouts. The problem is that "MAPLAYOUTREFERENCESYSTEM" has a popup window and I can't figure out a way to simulate an "enter" and just accept the default values. The "enter" would have to be entered as a parameter, as the routine asks for the command and then the number of parameters, that are stored in a list. Is this even possible with Lisp?
  2. In addition to the grid coordinates, we need to place labels on the left side and top of the viewport. This is to create specific zones to identify parts of the drawing. For example, we need to know that feature X  is found in section C,3. Is there an automated way to place this letters and numbers (like in the attached clip)? I tried to edit the xml file in here, but got nowhere. 

Can someone help me out with these?

 

Thank you

0 Likes
3,724 Views
18 Replies
Replies (18)
Message 2 of 19

ChicagoLooper
Mentor
Mentor

Hi @Albuquerque6PUK4 

You didn't mention the coordinate system you've assigned to modelspace and without assigning that CS, you can't create a grid, such as the one you create using MAPLAYOUTREFERENCESYSTEM.

 

Assigning a proper CS is critical to using that command. It also helps to have an understanding of SCALE beyond the typical ivebeenusingautocadforyearsandiknowhowthechangeviewportscale.

 

Run the MAPLAYOUTREFERENCESYSTEM command then select (click) the VP you want to place a grid. Here’s an example using State Plane Coord Sys assigned to modelspace. The resultant grid is 1” X 1”. 

 

1. MapLayoutReferenceSystem (The CS you choose may vary.)1. MapLayoutReferenceSystem (The CS you choose may vary.)2. VP Grid: State Plane Coordinate System (SPCS)2. VP Grid: State Plane Coordinate System (SPCS)

 

FYI, the coordinates (black numbers) along the perimeter of the VP in image 2 are 'live' meaning they're dynamic. That means if you pan east, west, north or south, the coordinates will change too. Same goes if you zoom-in or -out, the numbers will adjust automatically.

 

Chicagolooper

EESignature

0 Likes
Message 3 of 19

Albuquerque6PUK4
Contributor
Contributor

[deleted; format error]

0 Likes
Message 4 of 19

Albuquerque6PUK4
Contributor
Contributor

Hi @ChicagoLooper 

Thank you for your reply. You are completely right about the scale. "ivebeenusingautocadforyearsandiknowhowthechangeviewportscale" and sometimes have to pause for a few seconds, especially when we receive drawings in imperial units.

 

We work with WGS84 and have, at least, 2 different scales in the layouts. There is a layout with an overview, with a much smaller scale (1:4000, 1:5000), and the rest of the layouts with a bigger scale (1:500 most of the times).

Usually, we have drawings with 40 or 50 layouts (sometimes a lot more), and it's very time consuming to go through all of them to apply a CS grid.

I have a Lisp routine (a very crude one because I only started messing with Lisp recently) to apply some commands to all layouts without having to go through each one individually. My routine is this:

 

 

(defun c:execall ()     

         (setq com (getstring "\Enter a command: "))                                                                                                                         

         (setq nargs (getint "How many arguments: "))                                                                                                               

         (setq COMMLIST (list com))                                                                                                                                                      

         (repeat nargs (setq COMMLIST (append COMMLIST (list (getstring "Enter an argument: ")))))                      

         (foreach Layout (layoutlist)

                 (command "LAYOUT" "S" Layout)                                                                                                                                     

                 (command "PSPACE")                                                                                                                                                        

                 (apply 'command COMMLIST)

                 (command "ZOOM" "E")

                 (command "REGENALL")

    )      

         (princ)                                                                                                                                                                                           

)

 

 

My problem is when I try this with the command MAPLAYOUTREFERENCESYSTEM. I can give the coordinates of some random point in the viewport border as the first argument, so the command is applied to the viewport and I don't have to keep choosing the viewport in every layout. However, after choosing the viewport, the command shows the popup window and I don't know which argument to use to just accept the default values and keep applying the command to the other layouts without having to press "OK" in fifty (or more) popup windows. It should work something like this:

  • Enter a command: MAPLAYOUTREFERENCESYSTEM
  • How many arguments: 2
  • Enter an argument: coordinates x and y of a point in the viewport border
  • Enter an argument: argument that would just "click" Ok on the popup window (is this even possible to execute as an argument?)

This is my first issue.

 

My second issue is that after applying a grid with the correct coordinates in all layouts (and having it display like in your reply), we need to place an "extra" grid. On the left, we need to place letters, and on the top we need to place numbers. Is there any automated way to place these letters and numbers, using the CS grid as a reference (the letters and numbers should be placed between the "intervals" created by the CS grid - red in the drawing I attached)?

 

Albuquerque6PUK4_0-1705927034395.jpeg

 

 

Thank you.

0 Likes
Message 5 of 19

ChicagoLooper
Mentor
Mentor

@Albuquerque6PUK4 wrote

 

<...My problem is when I try this with the command MAPLAYOUTREFERENCESYSTEM. I can give the coordinates of some random point...>> 

 

It's not requiring you to select a random POINT, it's really asking you which viewport to place a 'reference grid.' If you are relying on lisp to automatically select a VP for you, then don't bother using MapLayoutReferenceSystem. Instead, you should rely on your lisp to pick it for you.

 

It sounds like you're trying to 'combine' the AutoCAD ref grid command with your own workflow and it won't work because your own input is interfering with the Cad command.

 

When using MapLayoutReferenceSystem, you don't need to provide any arguments, what you need to provide are the parameters of scale, such as (a) the specific viewport scale used on a specific layout, (b) the scale of the grid or the size of the grid cells (c) the coordinate system which your grid is referencing, such as UTM, State Plane, OSGB, CSRS,  etc., etc. b/c every coordinate system has units (meters/feet) and those units will have an affect whether you like it or not.

 

You also need to be cognizant that the reference grid placed your VP does NOT have to be the same as the coordinate system you assign to modelspace.  What does that mean? It means its entirely customizable. You may assign State Plane US Feet to modelspace then create a reference grid that displays UTM meters, or vice versa.

 

Because modelspace can use one geospatial reference system and the viewport map reference grid can use another means the those two reference systems are independent, i.e. they don't have to be the same nor have relate to each other. 

 

Chicagolooper

EESignature

0 Likes
Message 6 of 19

Albuquerque6PUK4
Contributor
Contributor

Hi @ChicagoLooper ,

 

Thank you for your reply.

I hope to improve my Lisp skills, but, at the moment, trying to figure out if I could do it with the MAPLAYOUTREFERENCESYSTEM command seemed the best route for me.

When using the command, the first parameter must be a "Point", or "Last". So, passing the coordinates as the first argument for the command works. Since all the viewports are scaled correctly and the CS is also correctly applied, I just needed a 2nd argument for the command, to automatically click "Ok" on the popup window (accepting the default values: I want to use the "Current map coordinate system", default "Scale" and default "Precision").

From your answer, it seems this is not possible and there is no apparent way to implement a "click" as an argument. 

 

About my 2nd issue, do you think this Grid/Labelling could be automated?

 

Thank you.

0 Likes
Message 7 of 19

ChicagoLooper
Mentor
Mentor

HI @Albuquerque6PUK4 

You can defiinitely do it with MapReferenceLayoutSystem.

 

You don't need that argument. i.e. first point, last point. Really, you don't need it. If it's asking for that then you're not doing it correctly.

 

  1. Assign a CS to modelspace. This step is mandatory.
  2. On layout tab, establish your VP scale. If more than one VP on your layout tab, establish scale for each individual VP.
  3. Execute MAPREFERENCELAYOUTSYSTEM=>Select a viewport using your cursor.
  4. In the dialog window, establish the grid parameters, this is where it might get confusing, very confusing......for example, (a) which coordinate system will the ref grid use, the same one as modelspace or do you want to use a different one, (b) what scale for the VP, do you want to continue using your VP scale or do you want to change it, (c) what size of grid cells do you prefer, QQmm X RRmm.  

Can you upload a sample drawing for better explanation?

Chicagolooper

EESignature

0 Likes
Message 8 of 19

Albuquerque6PUK4
Contributor
Contributor

Hi @ChicagoLooper 

Thank you for your patience with this.
I feel we are talking about two slightly different things. Maybe the way I formulated my problem wasn't very clear.

 

The issue is that I need an "automated" way to apply a CS grid in several layouts without having to interact with each one individually. I know that MAPLAYOUTREFERENCESYSTEM doesn't need a point coordinate, and a simple click in the viewport is enough. However, the Lisp routine is not interactive, it needs a value for the viewport parameter, so I have to give an x and y coordinate as an argument.


I am attaching two drawings (example.dwg and example-no_grid.dwg) and the Lisp file.

The example.dwg file is the "final" product.

Please, on the example-no_grid.dwg run the Lisp routine. When asked the number of arguments just answer 1. That argument needs to be a point on the border of the viewport [(44,534) works]. This will apply the CS grid in every layout. The problem is that you'll have to click "Ok" in every popup window (and that is what I wanted to avoid, passing a "mouse click" as an argument).

If I follow your suggestion, I have to answer 0 for the number of arguments and then click on the viewport, but this just stops the Lisp routine and I just get the CS grid on the current layout. This is the same as applying the command in every layout individually (something I would like to avoid).

 

The example.dwg isn't "final" because the numbers and letters that I mentioned in previous posts need to be moved around. That is also a very time consuming issue. I use some older project as a template and, obviously, the coordinates are always changing, so the CS grids are always changing, but the letters and numbers on the border remain stationary. I usually copy the letters across rows and the numbers across column, but, even so, when dealing with more than 50 layouts, this takes a lot of time.

 

P.S. - these drawings are just a simplistic version of what we usually deal with. 

 

0 Likes
Message 9 of 19

Albuquerque6PUK4
Contributor
Contributor

Hi @ChicagoLooper,

 

Since there haven't been any more answers, is this an easy "fix" and I am missing something, or simply can't be done?

Thank you

0 Likes
Message 10 of 19

Pointdump
Consultant
Consultant

Hi @AlbuquerquePUK4,
You'll probably get more traction on your question in the >>>Customization Forum<<<.
Dave

Dave Stoll
Las Vegas, Nevada

EESignature

64GB DDR4 2400MHz ECC SoDIMM / 1TB SSD
NVIDIA Quadro P5000 16GB
Windows 10 Pro 64 / Civil 3D 2025
0 Likes
Message 11 of 19

ChicagoLooper
Mentor
Mentor

Hi @Albuquerque6PUK4 

I would use the built in reference grid. Why? Because it's dynamic and that means if you move the target area of your viewport east/west/north/south then the reference grid will A-U-T-O-M-A-T-I-C-A-L-L-Y adjust and reference NEW  values for the ref grid running across the viewport.

 

For example, here's a view of Albuquerque NM by I-25. You can see Arroyo del Oso Golf Course east of the interstate. Notice the numbers of the reference grid around the perimeter of the viewport. Those values reference New Mexico State Plane coordinate system, central zone, US feet. (See image-1) Image-1Image-1

 

Continuing with the same example, here's Albuquerque International Airport which is approximately 4 miles southwest of the golf course. (See image-2)  Compare these numbers around the VP (they're still referenced to State Plane, Central zone) with the values shown on the previous image. Image-2Image-2

 

Why to the number change? Because the VP is reflecting the values of the assigned coordinate system, which in this case is NM83-CF (New Mexico, NAD83, Central Zone, US feet). As the TARGET AREA of the viewport changes, so does the grid. The numbers are dynamic and that means they'll change on-the-fly when you pan in the viewport.

 

Notes:

  1. The numbers around the VP will also dynamically change if you zoom-in or -out. 
  2. In the above example, the viewport scale is 1"=2000' (your actual VP scale may vary).
  3. In the above example, the reference grid has a 1"x1" cell size, hence the values increase/decrease by 2,000 (your actual grid cell may vary). 
  4. If you have a thorough understanding of Viewport Scale vs Map Scale, then establishing notes 2 and 3 will be easy.  

 

  

Chicagolooper

EESignature

0 Likes
Message 12 of 19

Albuquerque6PUK4
Contributor
Contributor

Hi @Pointdump

Thank you for your suggestion.

 

Hi @ChicagoLooper,

Thank you for the replies. However, we are definitely talking about two different things. I don't know if you had the chance to open the drawings/run the script, but I am using the built in reference grid. The issue is that we need to use an ADDITIONAL set of letters and numbers (and these are not dynamic). Maybe this step can't be automated.

0 Likes
Message 13 of 19

O_Eckmann
Mentor
Mentor

Hi @Albuquerque6PUK4 ,

 

I think that letters and numbers can't be added by native command, but if you play with lisp, and make (entget (car (entsel))) and select the PLGRIDSYSTEM object, you find all small tick, and at the end after code 340, you find all horizontal and vertical lines.

 

That's the end of the PLGRIDSYSTEM object info returned in lisp in your sheet 01.

(340 . <Nom d'entité: 1d28c0d4960>) (70 . 9) (62 . 18) (420 . 0) (90 . 10) (90 . 2) (40 . 43.4564) (40 . 67.2882) (40 . 625.456) (40 . 67.2882) (90 . 2) (40 . 43.4564) (40 . 167.288) (40 . 625.456) (40 . 167.288) (90 . 2) (40 . 43.4564) (40 . 267.288) (40 . 625.456) (40 . 267.288) (90 . 2) (40 . 43.4564) (40 . 367.288) (40 . 625.456) (40 . 367.288) (90 . 2) (40 . 43.4564) (40 . 467.288) (40 . 625.456) (40 . 467.288) (90 . 2) (40 . 142.005) (40 . 24.8323) (40 . 142.005) (40 . 533.832) (90 . 2) (40 . 242.005) (40 . 24.8323) (40 . 242.005) (40 . 533.832) (90 . 2) (40 . 342.005) (40 . 24.8323) (40 . 342.005) (40 . 533.832) (90 . 2) (40 . 442.005) (40 . 24.8323) (40 . 442.005) (40 . 533.832) (90 . 2) (40 . 542.005) (40 . 24.8323) (40 . 542.005) (40 . 533.832))

1st code 90, says number of line : 10 = 5 vertical + 5 horizontal

And each code 90 says 2 points :

     1st point : X = 1st code 40, Y = 2nd code 40

     2nd point : X = 3rd code 40, Y = 4th code 40

With these info, you can automate placement of your letters and numbers.

 

For dialog box which appears when you attach or add antoher grid, I haven't found any solution to bypass it.

I haven't found any API in lisp too. Perhaps in .Net

You can ask your question in customization forum

Olivier Eckmann

EESignature

0 Likes
Message 14 of 19

ChicagoLooper
Mentor
Mentor

@Albuquerque6PUK4 

You are confusing Map3D's Map Book with the MapSystemReferenceSystem.

 

They are two different Map3D features that serve two separate functions. Terms are not interchangeable so if you use one term in place of the other you'll not only confuse the forum but you'll confuse yourself too.

 

Here's a, 8-1/2 minute >>VIDEO<< on how to create a Map Book by Jerry Bartels.

 

Using MapBooks in Civil 3D to automate (Tiled) Plan ProductionUsing MapBooks in Civil 3D to automate (Tiled) Plan Production

 

 

I don't like reinventing the wheel. If an existing command will serve your purpose then invest some of your time and master it. The Map Book will create the columns and rows you desperately want.

 

Give a man a fish and you feed him for a day. Teach him how to fish and you feed him for a lifetime.

 

Chicagolooper

EESignature

0 Likes
Message 15 of 19

Albuquerque6PUK4
Contributor
Contributor

Hi @O_Eckmann,

Thank you for your input. That seems to be what I am after. I'll have to take a better look at it.

 

Hi @ChicagoLooper,

Thank you for your tips. I'll also check the Map Book, but that still doesn't exactly solve the question, because we just use letters on the left and numbers on the top of the viewport. 
Using your quote, it's more like I am looking for eggs and you want to teach me how to fish. 🙂
It's still useful, and appreciated, but wasn't what I was looking for at the moment.

0 Likes
Message 16 of 19

O_Eckmann
Mentor
Mentor

Hi @Albuquerque6PUK4 ,

 

You could try this code.

It should be executed in each layout.

Work only when grid is East/north (not rotated)

I try to use international command and options (developped on my french version), so I hope I've forgotten any command.

Olivier Eckmann

EESignature

0 Likes
Message 17 of 19

Albuquerque6PUK4
Contributor
Contributor

Hi @O_Eckmann ,

 

Merci beaucoup!

Your code will be a great help.

It's generating the right letters and numbers. I'll have to try to adjust the positioning a little.

Thank you for your help.

0 Likes
Message 18 of 19

OTMortimer
Participant
Participant

Hi - this is slightly off topic so forgive me, but I thought this may be a good place to ask.

In my work we create a lot of custom grids for example A-Z on the x axis and 1-25 on the y axis with 50m x 50m spacing. I was wondering if it would be possible to create a LISP routine that would before the same functionality as MAPLAYOUTREFERENCESYSTEM but for a custom grid. The reason being is that we have an overall grid for the site and multiple zoomed in viewports that need to show the relevant grid references and as you can imagine it takes time to create these manually.

Any help would be well received 

0 Likes
Message 19 of 19

ChicagoLooper
Mentor
Mentor

Hi @OTMortimer

Unfortunately user @Albuquerque6PUK4 didn’t use the correct terminology when explaining what he needed. He didn’t need MAPLAYOUTREFERENCESYSTEM, he actually needed a Map Book. 

 

Here’s a video by Jerry Bartels explaining how to use the Map Book feature. To watch the video click >>HERE<<.

 

The Map Book is the tool used to create letters and numbers for a ‘Tiled Map.’

 

The feature known as MAPLAYOUTREFERENCESYSTEM is a powerful tool used for a different purpose—it’s

not appropriate for the result you want. 


Use the Map Book function to establish your GRID (your tiles/columns & rows). Don’t confuse MAPLAYOUTREFERENCESYSTEM with the Map Book function, they’re two different things. Don’t refer to MAPLAYOUTREFERENCESYSTEM when you really mean you want Map Book. 
IMG_2153.jpeg

When using Map Book, you can choose columns & rows to make you map ‘Tiles.’
IMG_2152.jpeg

Chicagolooper

EESignature

0 Likes