This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

To execute "Find shortest path" query from WaterObjects.net, how to pass Start Node and Stop Node as query parameters to ExecuteDrawingQuery?

Hi,
I am trying to execute "Find shortest path" query from WaterObjects.net. So I need to pass Start Node and Stop Node as query parameters to ExecuteDrawingQuery

I am not sure about exact meaning of the arguments which need to be passed to QueryParametr. I tried doing something as follows,

Dim QueryParameters(2) As QueryParameter
QueryParameters(0) = New QueryParameter("Start Node", "1", Type.GetType("String"), Haestad.Support.Units.Unit.None, Nothing, Nothing, Nothing)

QueryParameters(0).Value = "T-1"
QueryParameters(1) = New QueryParameter("Stop Node", "2", Type.GetType("String"), Haestad.Support.Units.Unit.None, Nothing, Nothing, Nothing)
QueryParameters(1).Value = "J-690"


Though ExecuteDrawingQuery statement executes without throwing any error, it fetches 0 IDs. How do I define the QueryParameter array?

Thanks

Parents
  • Hi,

    The value of the parameter needs to be the ID of the element, not the label.  Here is an example in C#.

    PredefinedQueries queries = new PredefinedQueries();
    
    IQueryParameter[] param = new IQueryParameter[2];
    param[0] = new QueryParameter("findShortestPathStartParameter", "findShortestPathStartParameter", typeof(int), Unit.None, "", "", -1);
    param[1] = new QueryParameter("findShortestPathStopParameter", "findShortestPathStopParameter", typeof(int), Unit.None, "", "", -1);
    
    param[0].Value = 28;        //Actual ID of element.
    param[1].Value = 58;        //Actual ID of element.
    HmIDCollection ids = queries.ExecuteQuery(DrawingQueryType.FindShortestPath, CurrentProject, param, null, new NullProgressIndicator(), out string errorMessage);
    

    That should get you going.

    Kris

Reply
  • Hi,

    The value of the parameter needs to be the ID of the element, not the label.  Here is an example in C#.

    PredefinedQueries queries = new PredefinedQueries();
    
    IQueryParameter[] param = new IQueryParameter[2];
    param[0] = new QueryParameter("findShortestPathStartParameter", "findShortestPathStartParameter", typeof(int), Unit.None, "", "", -1);
    param[1] = new QueryParameter("findShortestPathStopParameter", "findShortestPathStopParameter", typeof(int), Unit.None, "", "", -1);
    
    param[0].Value = 28;        //Actual ID of element.
    param[1].Value = 58;        //Actual ID of element.
    HmIDCollection ids = queries.ExecuteQuery(DrawingQueryType.FindShortestPath, CurrentProject, param, null, new NullProgressIndicator(), out string errorMessage);
    

    That should get you going.

    Kris

Children