AnsweredAssumed Answered

How do I convert a 2D map to 3D?

Question asked by laolai on Oct 19, 2018
Latest reply on Nov 1, 2018 by pyurkosky-esristaff

I was trying to convert a 2D map to 3D using the following code:

 

public Task<bool> Create3DView()
{
return QueuedTask.Run(async () =>
{
if (MapView.Active == null) return false;

Map pMap = MapFactory.Instance.CopyMap(MapView.Active.Map);


CIMMap pMapDef = pMap.GetDefinition();
pMapDef.MapType = MapType.Scene;
pMap.SetDefinition(pMapDef);

var pLayers = pMap.GetLayersAsFlattenedList().OfType<FeatureLayer>();
foreach (var pLayer in pLayers)
{
var lyrDefn = pLayer.GetDefinition() as CIMBasicFeatureLayer;
//setting this property moves the layer to 3D group in a scene
lyrDefn.IsFlattened = false;
//Set the definition back to the layer
pLayer.SetDefinition(lyrDefn);
}

pMap.SetName("3D Map");
await ArcGIS.Desktop.Core.ProApp.Panes.CreateMapPaneAsync(pMap, MapViewingMode.SceneLocal, null);

return true;
});
}

 

But I kept getting the following error:

"A 2D map cannot be opened as a 3D map. Convert the map first and then open."

 

I have set the map type to MapType.Scene.

 

Any ideas?

Outcomes