Ask A Cartographer

Locking elements in templates

November 07 2007 | 2 comments
Categories: Map Elements

I am creating a map document that members of our GIS team can use as a master document for many
of the maps we make so they have the same look and feel and would like to lock some elements in the layout so they cannot be accidentally moved (e.g. locking the title, scale bar, north arrow, etc.). Other elements we would like to remain unlocked such as the Data Sources text and a box surrounding that text which will need to be resized each time a map is made since the Data Sources will likely change and the box will likely need to be resized and possibly moved to a different location on the map. If I understand Templates correctly, some of these criteria can be met, but not all and a few of our team members have complained that they could not then edit the template to modify elements that needed modifying. Hence we are using a read-only .mxd file which each map maker copies to make a new map. Is there a way to lock the elements in the layout view that we don’t what to ever move?

If I understand the sticky move tolerance option, that only applies when editing items and does not effectively “lock” graphic elements in layout view (I tried a sticky move tolerance of 500 px on an image that is only 640 px wide, but was still able to move things with only a slight movement of the mouse).

If there is a way to accomplish the goal of having some elements movable and others locked in place using Templates, I would love to learn about it.

Thank you for any assistance you can provide.

Mapping Center Answer:

There’s no way, in terms of a property for layout elements to do what you want.

Here’s an idea, though having never “walked a mile in your shoes”, take it for what you think it’s worth. You could replace those elements that you know will always be exactly as they are with a single graphic. Then you could draw the other elements in the MXD that will change on top of that graphic. The idea would be to remove everything that will change (from a copy of your MXD; just so you don’t accidentally save over the original), and then export it to .EMF format. Next, in another copy of your MXD, from the Insert menu choose Picture and browse to your EMF file and insert that into your layout; then delete all the items that the EMF file handles.

There are some risks in doing this. First is that somebody could accidentally select and move that picture; by keeping it at the back of the drawing order, that should be minimal. You could also keep the coordinates for the size and position of that picture handy and just verify them before saving or printing the map.

Lock is property of an element posted by Mark Chilcott on Jul 30 2009 6:21PM
Hi Mappers,

It is about 10 lines of code to change the property of an element to locked.

Private Sub GraphicLock_Click()
Dim pMxDoc As IMxDocument
Dim pActiveView As IActiveView
Dim pGraphicsContainerSel As IGraphicsContainerSelect
Dim pEnumElement As IEnumElement
Dim pElement As IElement


Set pMxDoc = Application.Document
Set pActiveView = pMxDoc.ActivatedView
Set pGraphicsContainerSel = pActiveView
Set pEnumElement = pGraphicsContainerSel.SelectedElements

'Enumerate through all the elements
pEnumElement.Reset
Set pElement = pEnumElement.Next ' Get first value from container
Do Until pElement Is Nothing
If pElement.Locked = False Then ' UnLocked element - lock it
pElement.Locked = True
End If
Set pElement = pEnumElement.Next ' Get next value from container
Loop
End Sub

Similar code to unlock.

To my mind, this property should be exposed in the property box for an element. Would be easy to do.

Our organization does a lot of series mapping. Due to issues we have had in the past with things moving, or corrupt templates, we prototyped the template by placing all the elements normally, then wrote code to replace all of them. Therefore, our code creates every element in the layout with the push of a button, thereby guaranteeing everything is there, and in the correct place. Works very well.

[Little bit more complex than that : we store a table that contains all the information to create the elements for each map sheet in the series.]



Cheers,

Mark


Cheers,

Mark
MPS-Atlas Provides Element Locking posted by David Watkins on Jul 31 2009 10:11AM
The 9.3 release of the MPS-Atlas extension, a component of PLTS, provides an user-interface for locking and unlocking elements in the page layout. It is a right-click option on the elements in the Elements tab.

If you would like to post a comment, please login.

Contact Us | Legal | Privacy |