Predefined drawing query parameters in WaterObjects.NET

Product(s): WaterGEMS, WaterCAD
Version(s): CONNECT Edition as of 10.02.02.06
Area: Other
Original Author Kris Culin, Senior Software Engineer, Bentley Systems

Problem

When using the WaterObjects.NET API to execute a "Find ____" or "PathToNearest ___" predefined drawing query (such as DrawingQuery.FindAdjacentStartNodes), how do you specify the selected element(s)? What are the parameters needed?

NOTE: this article is for advanced users using the WaterObjects.NET API to create custom tools to interact with hydraulic model data. Advanced Programming background required.

Solution

To select elements in WaterObjects.Net, use the IFeatureManager. This can be retrieved by casting the ApplicationModel to IMappingApplicationModel.

FeatureManager.SelectElements(IDominProject, SelectionSetItemCollection)

A SelectionSetItemCollection is a list of SelectionSetItem objects. Each SelectionSetItem contains the ElementTypeID and list of IDs of that type. When SelectElements is called, it will mark these elements as “selected” internally so that calls to ExecuteDrawingQuery will correctly see one or more elements selected.

This will require you to open the project (wtg) file, not the sqlite file directly as you will need an instance of the IProject (cast to IDomainProject in most cases).

The related predefined drawing queries are listed below with their respective query parameters:

Find Connected

  • Use PredefinedQueries.ExecuteQuery using DrawingQueryType.FindConnected
  • Define a QueryParameter as described below

Query Parameters:

Name

Value

Type

queryParameters

{Haestad.Framework.Support.IQueryParameter[1]}

Haestad.Framework.Support.IQueryParameter[]

◢ [0]

{Haestad.Framework.Support.QueryParameter}

Haestad.Framework.Support.IQueryParameter {Haestad.Framework.Support.QueryParameter}

 

Arrow forward [Haestad.Framework.Support.QueryParameter]

{Haestad.Framework.Support.QueryParameter}

Haestad.Framework.Support.QueryParameter

DefaultValue

-1

object {int}

DescriptionKey

"findConnectedParameterDescription"

string

Label

"Find Elements Connected To"

string

LabelKey

"findConnectedParameter"

string

Name

"findConnectedParameter"

string

TypeCategory

""

string

Arrow forward Unit

{None}

Haestad.Support.Units.Unit

Value

1058

object {int}

Arrow forward ValueType

{Name = "Int32" FullName = "System.Int32"}

System.Type {System.RuntimeType}


Supported ElementTypes

These are the ElementTypeIDs supported by the above query – equivalent to using (int)DomainElementType.[member]

Name

Value

Type

availableElementTypeIds

{int[24]}

int[]

[0]

54

int

[1]

55

int

[2]

52

int

[3]

308

int

[4]

302

int

[5]

56

int

[6]

301

int

[7]

303

int

[8]

305

int

[9]

306

int

[10]

321

int

[11]

60

int

[12]

61

int

[13]

62

int

[14]

64

int

[15]

65

int

[16]

66

int

[17]

310

int

[18]

68

int

[19]

72

int

[20]

300

int

[21]

307

int

[22]

309

int

[23]

24

int


Find Disconnected

  • Use PredefinedQueries.ExecuteQuery using DrawingQueryType.FindDisconnected
  • Configure a single parameter as defined below.

Query Parameters

Name

Value

Type

queryParameters

{Haestad.Framework.Support.IQueryParameter[1]}

Haestad.Framework.Support.IQueryParameter[]

◢ [0]

{Haestad.Framework.Support.QueryParameter}

Haestad.Framework.Support.IQueryParameter {Haestad.Framework.Support.QueryParameter}

Arrow forward [Haestad.Framework.Support.QueryParameter]

{Haestad.Framework.Support.QueryParameter}

Haestad.Framework.Support.QueryParameter

DefaultValue

-1

object {int}

DescriptionKey

"findDisconnectedParameterDescription"

string

Label

"Find Elements Disconnected From"

string

LabelKey

"findDisconnectedParameter"

string

Name

"findDisconnectedParameter"

string

TypeCategory

""

string

Arrow forward Unit

{None}

Haestad.Support.Units.Unit

Value

153

object {int}

Arrow forward ValueType

{Name = "Int32" FullName = "System.Int32"}

System.Type {System.RuntimeType}


Supported ElementTypeIDs

Name

Value

Type

availableElementTypeIds

{int[24]}

int[]

[0]

54

int

[1]

55

int

[2]

52

int

[3]

308

int

[4]

302

int

[5]

56

int

[6]

301

int

[7]

303

int

[8]

305

int

[9]

306

int

[10]

321

int

[11]

60

int

[12]

61

int

[13]

62

int

[14]

64

int

[15]

65

int

[16]

66

int

[17]

310

int

[18]

68

int

[19]

72

int

[20]

300

int

[21]

307

int

[22]

309

int

[23]

24

int


Path to Nearest Element of Type

  • Create two parameters as described below.
  • Use PredefinedQueries.ExecuteQuery using DrawingQueryType.PathToNearestElementOfType

Name

Value

Type

queryParameters

{Haestad.Framework.Support.IQueryParameter[2]}

Haestad.Framework.Support.IQueryParameter[]

◢ [0]

{Haestad.Framework.Support.QueryParameter}

Haestad.Framework.Support.IQueryParameter {Haestad.Framework.Support.QueryParameter}

Arrow forward [Haestad.Framework.Support.QueryParameter]

{Haestad.Framework.Support.QueryParameter}

Haestad.Framework.Support.QueryParameter

DefaultValue

-1

object {int}

DescriptionKey

"pathToNearestElementStartParameterDescription"

string

Label

"Start Element"

string

LabelKey

"pathToNearestElementStartParameter"

string

Name

"pathToNearestElementStartParameter"

string

TypeCategory

""

string

Arrow forward Unit

{None}

Haestad.Support.Units.Unit

Value

127

object {int}

Arrow forward ValueType

{Name = "Int32" FullName = "System.Int32"}

System.Type {System.RuntimeType}

◢ [1]

{Haestad.Framework.Support.QueryParameter}

Haestad.Framework.Support.IQueryParameter {Haestad.Framework.Support.QueryParameter}

Arrow forward [Haestad.Framework.Support.QueryParameter]

{Haestad.Framework.Support.QueryParameter}

Haestad.Framework.Support.QueryParameter

DefaultValue

2

object {int}

DescriptionKey

"pathToNearestElementTypeParameterDescription"

string

Label

"Element Type"

string

LabelKey

"pathToNearestElementTypeParameter"

string

Name

"pathToNearestElementTypeParameter"

string

TypeCategory

""

string

Arrow forward Unit

{None}

Haestad.Support.Units.Unit

Value

2

object {int}

Arrow forward ValueType

{Name = "Int32" FullName = "System.Int32"}

System.Type {System.RuntimeType}

The second parameter defined above can have the following values:

  • 1 (Junction)
  • 2 (Reservoir), Default
  • 3 (Tank)
  • 4 (StandardPump)
  • 5 (PumpStation)
  • 6 (PBV)
  • 7 (PRV)
  • 8 (PSV)
  • 9 (TCV)
  • 10 (FCV)
  • 11 (GPV)
  • Hydrant (12
  • Hammer nodal-elements
    • 13 (SurgeTank)
    • 14 (AirValve)
    • 15 (HydropneumaticTank)
    • 16 (SagSrv)
    • 17 (DischargeToAtmosphere)
  • Hammer directed-node elements
    • 19 (ValveWithLinearAreaChange)
    • 20 (Turbine)
    • 21 (OrificeBetweenTwoPipes)
    • 22 (CheckValve)
  • 23 (PeriodicHeadFlow)
  • 24 (DirectedNode)

Path to Nearest Upstream Element of Specified Type

  • Create two parameters as defined below.
  • For the second parameter, see the valid values from the “Path to Nearest Element of Type” query
  • Use PredefinedQueries.ExecuteQuery with DrawingQueryType.PathToNearestUpstreamElementOfType

Name

Value

Type

queryParameters

{Haestad.Framework.Support.IQueryParameter[2]}

Haestad.Framework.Support.IQueryParameter[]

◢ [0]

{Haestad.Framework.Support.QueryParameter}

Haestad.Framework.Support.IQueryParameter {Haestad.Framework.Support.QueryParameter}

Arrow forward [Haestad.Framework.Support.QueryParameter]

{Haestad.Framework.Support.QueryParameter}

Haestad.Framework.Support.QueryParameter

DefaultValue

-1

object {int}

DescriptionKey

"pathToNearestUpstreamElementStartParameterDescription"

string

Label

"Start Element"

string

LabelKey

"pathToNearestUpstreamElementStartParameter"

string

Name

"pathToNearestUpstreamElementStartParameter"

string

TypeCategory

""

string

Arrow forward Unit

{None}

Haestad.Support.Units.Unit

Value

127

object {int}

Arrow forward ValueType

{Name = "Int32" FullName = "System.Int32"}

System.Type {System.RuntimeType}

◢ [1]

{Haestad.Framework.Support.QueryParameter}

Haestad.Framework.Support.IQueryParameter {Haestad.Framework.Support.QueryParameter}

Arrow forward [Haestad.Framework.Support.QueryParameter]

{Haestad.Framework.Support.QueryParameter}

Haestad.Framework.Support.QueryParameter

DefaultValue

2

object {int}

DescriptionKey

"pathToNearestUpstreamElementTypeParameterDescription"

string

Label

"Element Type"

string

LabelKey

"pathToNearestUpstreamElementTypeParameter"

string

Name

"pathToNearestUpstreamElementTypeParameter"

string

TypeCategory

""

string

Arrow forward Unit

{None}

Haestad.Support.Units.Unit

Value

2

object {int}

Arrow forward ValueType

{Name = "Int32" FullName = "System.Int32"}

System.Type {System.RuntimeType}

Path to Nearest Downstream Element of Specified Type

  • Create two parameters as described below.
  • For the second parameter, see the valid values from the “Path to Nearest Element of Type” query.
  • Use PredefinedQueries.ExecuteQuery with DrawingQueryType.PathToNearestDownstreamElementOfType

Name

Value

Type

queryParameters

{Haestad.Framework.Support.IQueryParameter[2]}

Haestad.Framework.Support.IQueryParameter[]

◢ [0]

{Haestad.Framework.Support.QueryParameter}

Haestad.Framework.Support.IQueryParameter {Haestad.Framework.Support.QueryParameter}

Arrow forward [Haestad.Framework.Support.QueryParameter]

{Haestad.Framework.Support.QueryParameter}

Haestad.Framework.Support.QueryParameter

DefaultValue

-1

object {int}

DescriptionKey

"pathToNearestDownstreamElementStartParameterDescription"

string

Label

"Start Element"

string

LabelKey

"pathToNearestDownstreamElementStartParameter"

string

Name

"pathToNearestDownstreamElementStartParameter"

string

TypeCategory

""

string

Arrow forward Unit

{None}

Haestad.Support.Units.Unit

Value

128

object {int}

Arrow forward ValueType

{Name = "Int32" FullName = "System.Int32"}

System.Type {System.RuntimeType}

◢ [1]

{Haestad.Framework.Support.QueryParameter}

Haestad.Framework.Support.IQueryParameter {Haestad.Framework.Support.QueryParameter}

Arrow forward [Haestad.Framework.Support.QueryParameter]

{Haestad.Framework.Support.QueryParameter}

Haestad.Framework.Support.QueryParameter

DefaultValue

2

object {int}

DescriptionKey

"pathToNearestDownstreamElementTypeParameterDescription"

string

Label

"Element Type"

string

LabelKey

"pathToNearestDownstreamElementTypeParameter"

string

Name

"pathToNearestDownstreamElementTypeParameter"

string

TypeCategory

""

string

Arrow forward Unit

{None}

Haestad.Support.Units.Unit

Value

3

object {int}

Arrow forward ValueType

{Name = "Int32" FullName = "System.Int32"}

System.Type {System.RuntimeType}

Find Adjacent Nodes

  • To execute this query, use the IFeatureManager. Use the ExecuteDrawingQuery method with the type DrawingQueryType.FindConnectedNodes
  • This requires the element to be “selected” in the drawing before executing the query or no results are returned.
  • Use the FeatureManager.SelectElements call to select the element first before calling the ExecuteDrawingQuery. See the beginning of this document for details on this process.
  • No parameters (use empty QueryParameter array)

Find Adjacent Pipes

  • Select the element(s) first with FeatureManager.SelectElements
  • Execute the query using FeatureManager.ExecuteDrawingQuery using DrawingQueryType.FindConnectedLinks
  • No parameters 9use empty QueryParameter array)

Find Adjacent Start Nodes

  • Select the link(s) in the model first using FeatureManager.SelectElements
  • Execute using FeatureManager.ExecuteDrawingQuery using DrawingQueryType.FindAdjacentStartNodes.
  • No parameters (use empty QueryParameter array)

Find Adjacent Stop Nodes

  • Select the link(s) in the model first using FeatureManager.SelectElements
  • Execute using FeatureManager.ExecuteDrawingQuery using DrawingQueryType.FindAdjacentStopNodes
  • No parameters (use empty QueryParameter array)

Find Associated Customer Meters

  • Select node(s) or link(s) in the model first.
  • Execute using FeatureManager.ExecuteDrawing Query using DrawingQueryType.FindAssociatedCustomers
  • No parameters

Find Elements Associated with Customer Meters

  • Select customer meter(s) in the model.
  • Execute FeatureManager.ExecuteDrawingQuery using DrawingQueryType.FindElementsAssociatedWithSelectedCustomerMeters
  • No parameters

Find Associated SCADA Elements

  • Select element(s) in the model.
  • Execute FeatureManager.ExecuteDrawingQuery using DrawingQueryType.FindAssociatedScadaElements
  • No parameters

Find Reversed Laterals

  • This is a WaterGEMS specific query and requires an instance of IdahoPredefinedQueries.
  • Use ExectueQuery with DrawingQueryType.FindReversedLaterals.
  • No parameters required.


See Also

Waterobjects.NET - Extending the capabilities of your OpenFlows product

Related Forum Discussion

Recommended
Related