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?
Is this a Pro API bug? Any help will be greatly appreciated.
We don't expose this functionality in the API (converting a map between 2D and 3D), but it's a good idea, and we may be able to add it in the near future.
In the meantime, try this:
In lieu of a genuine ConvertMapToScene function, this should get you pretty close.
Cheers,
Pete Yurkosky
Programmer - ArcGIS Pro