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
Hi Kevin
There is a sample in ArcObjects Help for .NET that should help you: http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#//000100000p85000000
Hopping this help
Anne-Yvonne
Yes Anne-Yvonne, thanks for your reply.
Actually, I was inspired by this .NET sample to write my Java code.
I used the same method: after creating the ISchematicElementClass, the UID corresponding to the SchematicAttributeAssociatedField class is created, then I invoke the function createSchematicAttribute with the field name and this UID.
So, maybe it's not the right time to invoke this function. I don't see how/when to do it.
Several questions to make sure I understand:
''' Create a field SchematicAttribute on a given SchematicElementClass
''' </summary>
''' <param name="schElementClass">The SchematicElementClass where the field attribute is created</param>
''' <param name="AttributeName">The ISchematicAttributeField name</param>
''' <param name="EvalMode">The EvaluationMode for the created schematic attribute</param>
''' <param name="StorageMode">The StorageMode for the created schematic attribute</param>
''' <param name="value">The FieldNames for the created schematic attribute</param>
''' <returns>The created ESRI.ArcGIS.Schematic.ISchematicAttributeField</returns>
''' <remarks>The UID.Value is a contant GUID value for the ISchematicAttributeField type of schematic attribute</remarks>
Public Function CreateAttributeFieldForElementClass(ByVal schElementClass As ESRI.ArcGIS.Schematic.ISchematicElementClass, ByVal AttributeName As String, ByVal EvalMode As ESRI.ArcGIS.Schematic.esriSchematicAttributeEvaluationMode, ByVal StorageMode As ESRI.ArcGIS.Schematic.esriSchematicAttributeStorageMode, ByVal value() As String) As ESRI.ArcGIS.Schematic.ISchematicAttributeField
Dim schAttribute As ESRI.ArcGIS.Schematic.ISchematicAttribute = Nothing
Try
' create an ISchematicAttribute
Dim pUid As ESRI.ArcGIS.esriSystem.UID = New ESRI.ArcGIS.esriSystem.UID()
pUid.Value = "{E1902BB0-6070-4EE2-995A-DB86FAC5EEB0}"
schAttribute = schElementClass.CreateSchematicAttribute(AttributeName, pUid)
Catch
Return Nothing
End Try
Dim schAttributeMngt As ESRI.ArcGIS.Schematic.ISchematicAttributeManagement = TryCast(schAttribute, ESRI.ArcGIS.Schematic.ISchematicAttributeManagement)
Try
' the StorageMode must be set before the EvaluationMode
' consistenty is checked when the EvaluationMode is set
schAttributeMngt.StorageMode = StorageMode
schAttributeMngt.EvaluationMode = EvalMode
Catch
' an error is returned if the StorageMode and EvaluationMode are not consistent
End Try
' cast SchematicAttribute into ISchematicAttributeField and set its properties
Dim schAttField As ESRI.ArcGIS.Schematic.ISchematicAttributeField = TryCast(schAttribute, ESRI.ArcGIS.Schematic.ISchematicAttributeField)
If (schAttField IsNot Nothing) Then
schAttField.FieldNames = value
End If
Return schAttField
End Function
- Start ArcCatalog and expand the schematic dataset in Catalog tree.
- Right-click the schematic dataset in Catalog tree.
- Click Show/Hide Schematic Classes.
Yes, by using an SQL query when creating the node schematic element class, I expect to generate a diagram containing every node of my feature class. When you say that the standard builder will no longer manage them, that's to say node features selection has no effect on the diagram generation? Actually, in addition to this attribute issue, I don't manage to create a schematic diagram because I don't see how to instantiate (in java) a ISchematicStandardBuilder in order to use the generateDiagram function.
You are right, selecting features prior to generate the diagram have no impact when configuring queries on your schematic feature classes. If you want to generate diagram from a selection set of features in your map, you should let the standard builder running in its full "standard" mode.
And OK, I will try to create a SchematicAttributeField instead of a SchematicAttributeAssociatedField.
Now, in ArcCatalog, I see my schematic dataset containing a schematic template, containing the schematic NODE and EDGE feature classes I created, so that's a good start.
Except if you want to work from a selection set of features... In this case, you need to associate your schematic feature class to the desired GIS feature class (NODE in your case, I guess), remove the SQL query you specified for your schematic class and create a SchematicAttributeAssociatedField instead.
How do you want to work exactly (from a features selection set or from queries?)? Why are you coding your dataset configuration; that is, the creation of your diagram template, schematic feature classes from scratch? Why are you not working within Dataset Editor?
Did you read and try the Schematics tutorials http://resources.arcgis.com/en/help/main/10.2/index.html#//004z00000066000000
and the Schematics videos Getting started with Schematics in videos | ArcGIS Resource Center
I prefer the SQL query method, but actually it doesn't matter as I want to associate all GIS features to schematic features.
I'm trying to automate the schematic dataset, template and diagram creation by code because I have to create a lot of geodatabases containing each one a geometric network and a schematic diagram based on it.
It's up to you to do so... but it looks to be quite complex. In your case, I would have coded the diagram template creation and configure it to simply work with the Standard builder with the AutoCreateElementClasses option turned on.
Then I would have called GenerateDiagram on ISchematicBuilder while the InitialObjects for the input ISchematicBuilderContext parameter is initialized with the whole set of geometric network edges. Indeed, working with the only edges in input is often sufficient for the Standard builder to generate diagrams corresponding to the entire GN.