Hi,
I'm trying to automate the complete creation of a schematic template with ArcObjects SDK for Java (10.2).
I've managed to create the GDB, the schematic dataset and the schematic diagram class (template).
Then, I created a schematic element class associated with a feature class taken from the same GDB, which works.
I would like to share a field "NAME" between the feature class and the schematic element class, in order to label the nodes of a schematic diagram.
So, I tried that:
...
ISchematicElementClass nodeSchematicElementClass = schematicDataset.createSchematicElementClass("NODE", esriSchematicElementType.esriSchematicNodeType);
nodeSchematicElementClass.setSchematicDataSourceByRef(schematicDataSource);
nodeSchematicElementClass.alterAssociatedObjectClass(schematicDataSource, nodeFeatureClass.getObjectClassID());
nodeSchematicElementClass.setGeometryType(esriGeometryType.esriGeometryPoint);
nodeSchematicElementClass.setExternalQueryEvaluationMode(esriSchematicExternalQueryEvaluationMode.esriSchematicQueryBuildEvaluation);
nodeSchematicElementClass.setQueryString("SELECT * FROM NODE");
schematicDiagramClass.associateSchematicElementClass(nodeSchematicElementClass);
UID associatedFieldUID = new UID();
associatedFieldUID.setValue("{7DE3A19D-32D0-41CD-B896-37CA3AFBD88A}"); // taken from the file ...\Desktop10.2\bin\configuration\CLSID\esri.clsid.ecfg
ISchematicAttribute schematicAttribute = nodeSchematicElementClass.createSchematicAttribute("NAME", associatedFieldUID);
then I get the following ArcObjects error in the last line:
AutomationException: 0x80040a28 - Additional field can't be added : NAME in 'Esri Schematics'
I get the same error with any other field name.
Does anybody have a solution? Am I doing something wrong with my attribute field association?
I would appreciate any help! Thanks,
Kevin
Please be aware that specifying SQL queries on each of your schematic feature classes is ok but it's a real hard work. SQL Queries will be not enough, you will have also to specify unique identifiers for each of the schematic features belonging to those feature classes, specify the from and to node identifiers for the link schematic features your expect in your diagram, and so on...
If your GIS data is organized into a Geometric Network, the Standard builder doesn't need all those stuffs, it is designed to directly deal with any set of GN features, decode the network topology, and create the expected schematic nodes and links with generic identifiers.
OK, thanks for your explanations. So in my simple case, it seems clear it's better to use the standard builder.
However, I don't know how to create a ISchematicStandardBuilder, as there is no SchematicStandardBuilder object class in Java, and the function schematicDataset.getSchematicBuilder() returns an ISchematicBuilder which is not castable to ISchematicStandardBuilder. So, for example, I can't turn on the option "AutoCreateElementClasses".
I also tried instantiating with ISchematicStandardBuilderProxy:
ISchematicStandardBuilder schematicStandardBuilder = new ISchematicStandardBuilderProxy();
but I have a NullPointerException when calling:
schematicStandardBuilder.setAutoCreateElementClasses(true);
Do you know how to create a standard builder using Java?
Please have a look to the snippets we recently shared on arcgis.com here.
The Generate A Diagram From A Map Selection.snippet file should help you.
Thanks for this helpful set of samples.
According to the "Create A Standard Builder Schematic Diagram Class From Scratch" snippet, we must instanciate a SchematicStandardBuilder object like that:
objectType = Type.GetTypeFromProgID("esriSchematic.SchematicStandardBuilder");
ESRI.ArcGIS.Schematic.ISchematicStandardBuilder pSchStandardBuilder;
if (objectType == null) return null;
pSchStandardBuilder = Activator.CreateInstance(objectType) as ESRI.ArcGIS.Schematic.ISchematicStandardBuilder;
So, I found an equivalent way in Java to calling Activator.CreateInstance:
ISchematicStandardBuilder schematicStandardBuilder = (ISchematicStandardBuilder)Class.forName("esriSchematic.SchematicStandardBuilder").newInstance();
At this line, I get a "java.lang.ClassNotFoundException: esriSchematic.SchematicStandardBuilder" exception.
Does it means that it's not possible to create a Java instance of the SchematicStandardBuilder class?
I just tried to create a SchematiAttributeField instead of a attribute associated field and the createSchematicAttribute function works.
So I have the following code:
UID attributeFieldUID = new UID();
attributeFieldUID.setValue(SCHEMATIC_ATTRIBUTE_FIELD_UID);
ISchematicAttribute schematicAttribute = schematicElementClass.createSchematicAttribute(fieldName, attributeFieldUID);
ISchematicAttributeManagement schematicAttributeManagement = (ISchematicAttributeManagement)schematicAttribute;
schematicAttributeManagement.setEvaluationMode(esriSchematicAttributeEvaluationMode.esriSchematicAttributeBuildEvaluation);
schematicAttributeManagement.setStorageMode(esriSchematicAttributeStorageMode.esriSchematicAttributeFieldStorage);
But now I have the following error when casting the ISchematicAttribute to ISchematicAttributeManagement:
java.lang.ClassCastException: com.esri.arcgis.schematic.SchematicAttributeField cannot be cast to com.esri.arcgis.schematic.ISchematicAttributeManagement
However, when I look in the Schematic Dataset Editor, I get the attribute field well created. The Storage mode is set to Field and the Evaluation mode to "on genete/update", so that's what I expected.