I used ArcObjects for .NET to create a schematic dataset, then a schematic diagram class (aka "schematic template" in the UI) wherein I load feature classes.
To do that, I followed the sample: "Create A Standard Builder Schematic Diagram Class From Scratch".
But when I generate diagrams, I get from ArcMap a "missing spatial reference" warning.
So how to set the spatial reference?
In ArcMap, it's possible in the properties of the schematic template. But using ArcObjects, I can't find an interface of the class SchematicDiagramClass to set the ISpatialReference.
I would appreciate any help on that.
Thanks!
Solved! Go to Solution.
see IGeoDatasetSchemaEdit ArcObjects Help for .NET developers
SchematicDiagramClass implements IGeoDataset ArcObjects Help for .NET developers that has SpatialReference ArcObjects Help for .NET developers
Yes, but the spatial reference property of IGeoDataset is read-only: http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//0025000003n0000000
There is only a "get" to the spatial reference object.
see IGeoDatasetSchemaEdit ArcObjects Help for .NET developers
It works casting the ISchematicDiagramClass object to this IGeoDatasetSchemaEdit, then using AlterSpatialReference, thanks.
Now I still have a 'missing spatial reference' error adding a diagram to a map, because the schematic element classes still don't have spatial reference. I create these object as ISchematicElementClass. What interface could I use to set their spatial reference?
You can get SchematicDataset and then alter spatial reference
OK, I got the ISchematicDataset object and am looking for an interface like IGeoDatasetSchemaEdit to change the spatial reference. The available interfaces are in this list: ArcObjects 10 .NET SDK Help
IGeoDatasetSchemaEdit isn't available for this object because I get a cast error.
Which interface could I use ?
Can you post part of source code ?
I can't cast the SchematicDataset to IGeoDatasetSchemaEdit because I get an InvalidCastException. Here is my code:
I create a schematicWorkspace from a IWorkspace like this:
[...]
ISchematicWorkspaceFactory schematicWorkspaceFactory = new SchematicWorkspaceFactoryClass(); ISchematicWorkspace schematicWorkspace = schematicWorkspaceFactory.Open(workspace);
Then, I create the schematic dataset:
schematicDataset = schematicWorkspace.CreateSchematicDataset(SCHEMATIC_DATASET_NAME); schematicDataset.DesignMode = true; Type objectType = Type.GetTypeFromProgID("esriSchematic.SchematicStandardBuilder"); ISchematicStandardBuilder schematicStandardBuilder = Activator.CreateInstance(objectType) as ISchematicStandardBuilder; schematicStandardBuilder.AddConnectedNodes = true; schematicStandardBuilder.InitializeLinksVertices = true; schematicStandardBuilder.AutoCreateElementClasses = true; schematicDiagramClass = schematicDataset.CreateSchematicDiagramClass(SCHEMATIC_DIAGRAM_CLASS_NAME); schematicDiagramClass.SchematicBuilder = schematicStandardBuilder as ISchematicBuilder; schematicDiagramClass.SchematicDataSource = schematicDataset.DefaultSchematicDataSource; schematicDiagramClass.ExternalQueryEvaluationMode = esriSchematicExternalQueryEvaluationMode.esriSchematicNoQuery; schematicDiagramClass.AlwaysLoadDiagrams = true;
Then, I define the spatial reference:
ISpatialReference spatialReference = gdbDataset.getSpatialReference(); IGeoDatasetSchemaEdit geoDataset = (IGeoDatasetSchemaEdit)schematicDataset; // here I get an InvalidCastException geoDataset.AlterSpatialReference(spatialReference); IGeoDatasetSchemaEdit geoDiagramClass = (IGeoDatasetSchemaEdit)schematicDiagramClass; geoDiagramClass.AlterSpatialReference(spatialReference);
Excuse me but before I have seen old help because now schematic has changed ( ArcObjects Help for .NET developers ). See these snippets: http://www.arcgis.com/home/item.html?id=a8be26357b944dfdbbd69a55818dcc88