Subscribe to this thread
Home - General / All posts - Automatically create view(/layout) along a line with a defined scale.
Hess3 post(s)
#04-Sep-18 14:21

Hi everybody, another newbie here .

I would like to produce different layout (format A3) with a defined scale (1/750) along a line which is over 70km. Instead of create each view manually and then create a layout based on that view, do you know if there is another solution less time consuming on Manifold 8.

You can find below an overview of what I would like to do. The red rectangle are the view that I would like to generate automatically, if it's possible.

Attachments:
Overview.PNG

adamw

8,061 post(s)
#05-Sep-18 09:48

You can create the views, create a layout, set it to show the first view, then copy and paste the layout a number of times and adjust each copy to use a different view (that is, you do not have to re-create each layout from scratch, can just make a copy of an existing model layout and do a minor adjustment on the result).

You can also create a layout for each view using a script. The views of a component are accessed via Component.ViewSet, creating a new layout is done using Document.NewLayout, then you add a layout entry for the target component using, say, Layout.EntrySet.AddComponent and set the entry to show the desired view using LayoutEntry.Scope / ScopeDetail. Or you can copy and paste an existing layout using Component.Copy and Document.Paste, then adjusting the layout to show the desired view as above.

You can create views using a script as well - if you have the boxes in the screen as vector data.

Forest
574 post(s)
#06-Sep-18 02:51

Hi Hess,

At newbie level, just import the boxes into your project and select one of them, then zoom to the selected box. The layer with the boxes can be hidden (or made transparent) and you can just print the map you want. This is what I used to do with M8. I eventually wrote a script that stepped through the boxes and exported each map. Note that I did not rotate the maps, as shown in your overview.png. I did a pipeline 1800 km long so the method works. I also had to produce a set of map numbers that were on the map itself in a layer of odds and evens. That allowed me to hide odd numbers that would show up on the bottom of even maps and vice versa, by hiding the odd layer or even layer.

Work out an interactive method for doing things and then have a crack as scripting if you are keen.

Hess3 post(s)
#07-Sep-18 11:02

Hi,

Thank you very much for your reactivity and your answers that was usefull !

@Forest 1800km i guess that took you a lot of time, at least i only had 70km to do .

Sloots

429 post(s)
#07-Sep-18 19:17

I do this all the time. I have a script that uses one hidden drawing to change the view and combine this with a active thematic layer. I will post the script later

Cheers Chris


http://www.mppng.nl/manifold/pointlabeler

Hess3 post(s)
#11-Sep-18 16:31

Hi Chris,

Well, if you have that, that could be really usefull!!

Sloots

429 post(s)
#12-Sep-18 19:23

Here it is. See the attached map file for a working example.

Cheers, Chris

using System.Collections.Generic;

using Manifold.Interop.Scripts;

using M = Manifold.Interop;

using System.Threading;

/*

This script loops through a drawing that holds all views to be produced. Create a map with some baselayers, the layer with the views, 

usually hidden (drwFrames, should contain a text field for naming purposes and a field "ignore" to exclude some views when needed), and one or more thematic

layers. An image of each theme is created (for each view).

*/

class Script {

 static void Main() {

 string drwFrames = "Frames"; // Drawing that contains the different view

 string fldName = "Name"; // Field in the drwFrames drawing that hold the name of the view

 string mapName = "Map"; // Map component to work on

 string theLayout = "Layout Landscape"; // Layout that is being used

 string path = @"D:\Mppng\Temp\"; // Output folder - change this to your own situation

 int dpi = 300; // dpi of the output images

 string imgName;

 bool hideLegend = false; // Hide or show the legend

 M.Application app = Context.Application;

 M.Document doc = (M.Document)app.ActiveDocument;

 M.Drawing frames = (M.Drawing)doc.ComponentSet[drwFrames];

 M.Layout layout = (M.Layout) doc.ComponentSet[theLayout];

 M.Map map = (M.Map) doc.ComponentSet[mapName];

 M.LayerSet ls = (M.LayerSet) map.LayerSet;

 

 List<string> themes = new List<string>(); 

 // Add your list of themes here

 themes.Add("Color");

 themes.Add("Labels");

 M.Progress progress = Context.Application.NewProgress();

 progress.MaxPosition = 100;

 progress.Text = "Lengthy operation";

 progress.Start();

 // Loop through each object in the frames drawing

 M.ObjectSet os = frames.ObjectSet;

 frames.SelectNone();

 int i = 0;

 int total = os.Count * themes.Count;

 

 foreach (string theme in themes)

 {

 // Show theme

 ls[theme].Visible = true;

 foreach (M.Object obj in os) 

 {

 obj.Selected = true;

 M.Record rec = obj.Record;

 int ignore = (int)rec._GetData("ignore");

 if (ignore == 0) {

 imgName = (string)rec._GetData(fldName) + " - " + theme;

 

 layout = (M.Layout) doc.ComponentSet[theLayout];

 

 // Legend on/off

 M.LayoutEntrySet les = layout.EntrySet;

 

 foreach(M.LayoutEntry le in les)

 {

 if (le.Type == M.LayoutType.LayoutTypeBody)

 {

 if (hideLegend)

 {

 le.Legend = M.LayoutState.LayoutStateOff;

 }

 else

 {

 le.Legend = M.LayoutState.LayoutStateOn;

 }

 }

 }

 

 

 if (hideLegend)

 {

 imgName = imgName + " - without legend";

 }

 

 // Change title

 layout.Description = imgName + "  ([Scale])";

 

 i++;

 // Show progress

 app.StatusText = "Processing " + imgName + " (" + i.ToString() + " / " + total + ")...";

 // Delete image if exists

 if(-1 < doc.ComponentSet.ItemByName(imgName))

 {

 doc.ComponentSet.Remove(doc.ComponentSet.ItemByName(imgName));

 }

 

 if ((int)rec._GetData("ignore") == 0) {

 

 layout.RenderTo(imgName, dpi, 1);

 M.ExportPng exp = (M.ExportPng) app.NewExport("PNG");

 M.Image theimg = (M.Image)doc.ComponentSet[(int)doc.ComponentSet.ItemByName(imgName)];

 exp.Export((M.Component) theimg, path + imgName + ".png", M.ConvertPrompt.PromptNone);

 

 }

 

 // Remove xml

 if(System.IO.File.Exists(path + imgName + ".xml"))

 {

 System.IO.File.Delete(path + imgName + ".xml");

 }

 

 // Delete image if exists

 if(-1 < doc.ComponentSet.ItemByName(imgName))

 {

 doc.ComponentSet.Remove(doc.ComponentSet.ItemByName(imgName));

 //Context.Application.MessageBox("Bestaat al!""Script");

 }

 

 if (!progress.Update())

 {

 break;

 }

 }

 obj.Selected = false;

 }

 // Hide theme

 ls[theme].Visible = false;

 }

 progress.Stop();

 Context.Application.MessageBox("Ready!""Script");

 }

}

Attachments:
Images from multiple views.map


http://www.mppng.nl/manifold/pointlabeler

KlausDE

6,204 post(s)
#12-Sep-18 07:35

OT idea for a feature request

The Overview.png attached to the initial posting shows a different rotation for the views. That feature is an old feature request of mine.

But I'm not decides on the technical implementation - as element of the viewpoint (location in Mfd9) when applied to a layout frame or as a modification of the coordinate system.

I fear I'll never be expert enough to handle the general solution with a coordinate system.

BCowper


1,262 post(s)
#12-Sep-18 11:07

The Manifold 8 fudge of rotating a map frame, rather than having just the map view rotated, was one of the main reasons I dropped Manifold as a final map making tool. I know the workaround of a custom projection worked for some, but there should have been a way to rotate a map display without fiddling with custom projections. All major GIS competitions have this feature.

Having this built into 9 would make it easier to have a mapbook, where you have a series of map views running along a linear object, like a power line, much easier to create. Having a mapbook tool built in into 9 would also be welcome.

KlausDE

6,204 post(s)
#12-Sep-18 13:10

Agreed. My solution in Mfd8 was to rotate the frame in layout on a page enlarged to show all of the rotated map including the borders and then use those to clip the rotated cutout.

Actually I don't like the AutoCAD way dealing with plot frames, too. But it allows to align the rotation with a click on a line object and using its direction.

BCowper


1,262 post(s)
#12-Sep-18 13:18

Agreed. My solution in Mfd8 was to rotate the frame in layout on a page enlarged to show all of the rotated map including the borders and then use those to clip the rotated cutout.

Yeah that was a very poor solution (aimed at the software not you Klaus!) to the problem and wouldn't work very well where you have multiple sheets running along a line at differing angles. I have many 50+ page mapbooks for pipelines/power lines with most pages rotated at different angles from each other to maximise the length of the linear feature shown in each page. The various Manifold 8 methods to apply rotation to the map would just be too time consuming and awkward to setup for so many map views/pages.

Manifold User Community Use Agreement Copyright (C) 2007-2017 Manifold Software Limited. All rights reserved.