Results 1 to 8 of 8

Thread: How to determine the lowest elevation of several pipes?

  1. #1
    Login to Give a bone
    0

    Default How to determine the lowest elevation of several pipes?

    Hi,

    I'm trying to extend the pipe class with the extension method, by creating a function. This function is to:


    1. Determine which pipes in the network have the same EndStructureId as the startStructureId of the pipe in question
    2. For those pipes, calculate the minimum value of the endPoint.Z property.


    Since there's no collection of the 'pipe' object per se, I have to work with the ObjectIdCollection available through GetPipeIds(), right? This means I have to make a new transaction for every pipe in the network? I can't get my mind around this.

    Code:
    Imports System.Runtime.CompilerServices  
    Imports Autodesk.Civil.DatabaseServices   
    Imports Autodesk.AutoCAD.DatabaseServices 
    Imports Autodesk.AutoCAD.ApplicationServices
    
    
    Public Function LowestElev(ByVal oPipe As Pipe) As Double        
            Dim trans As Transaction = m_tm.StartTransaction()
            Dim oNetworkId As ObjectId = oPipe.NetworkId()
            Dim oNetwork As Network = trans.GetObject(oNetworkId, OpenMode.ForRead)
    
    
            Dim oPipeIds As ObjectIdCollection = oNetwork.GetPipeIds()
    
    
            For Each oPipeId As ObjectId In oPipeIds
                Dim iPipe As Pipe = trans.GetObject(oPipeId, OpenMode.ForRead)
    
    
                If iPipe.EndStructureId = oPipe.StartStructureId Then
                   ???? 
                End If
                
            Next
            trans.commit()
    End Function
    I appreciate any help!

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: How to determine the lowest elevation of several pipes?

    Having just started a new job which has not yet even fully implemented Civil 3D for daily production (still uses Land Desktop), I don't have a data set to query... However, thinking out-loud, you might be able to extract the parent Pipe Network, and iterate the pipes within. You may even be able to employ LINQ's OrderBy() Method to sort the Pipe Objects themselves, by Endpoint.Z Property.

    This old post has an example of using OrderBy(), sorting a list of Objects by one of their Properties.

    HTH
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    Login to Give a bone
    0

    Default Re: How to determine the lowest elevation of several pipes?

    Thanks for the quick response!

    Should I make a list of the pipes and then use the orderby method, or should I create an array to store the elevation values and then get the minimum value in that array? Which option is the best one?

    I'm concerned with performance issues...

  4. #4
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: How to determine the lowest elevation of several pipes?

    Quote Originally Posted by ruipfbarreiros370525 View Post
    Should I make a list of the pipes and then use the orderby method, or should I create an array to store the elevation values and then get the minimum value in that array? Which option is the best one?

    I'm concerned with performance issues...
    [Edit] Disregard this line: That depends on what the Pipe Network Object allows for as accessible Property Objects. Ideally (and I do not have the documentation in front of me at the moment, so forgive what follows if inaccurate), you'd be able to access the Pipes as an enumerable collection/array from the Pipe Network, which makes things simple. LINQ is not necessary, and should only be used if the accessible collection is in the required Type for the OrderBy() Method, otherwise it doesn't make sense.

    The goal here being to iterate the pipes as few times as possible... If possible, OrderBy() might, or might not be more efficient than (as you state above) creating the array of Pipe Objects, store each target elevation (or are you also going to compare both ends to get the lowest of the two?), and then Sort() the resultant List<double>, etc.

    Concerning performance, the first thing to observe to my mind, is how small most pipe networks are... A large pipe network might have tens of pipes? Regardless of which methodology you feel works best, so long as you don't make any blatant errors in code logic, methinks you'll see very little performance difference in the end.

    HTH
    Last edited by BlackBox; 2014-02-04 at 11:38 PM.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  5. #5
    Login to Give a bone
    0

    Default Re: How to determine the lowest elevation of several pipes?

    According to the .NET API (http://docs.autodesk.com/CIV3D/2014/...ide/index.html) there seems to be no enumeration that can control the pipes in a network. I believe dealing with ObjectId and ObjectIdCollection is the only way to go..

    Iterate through the pipes as few times as possible, as you say, is very important to me. I agree that a pipe network will never be that big, but I do want to add significant functionality to my code, hopefully to be able to calculate an entire network through .NET. Because I need to add several "properties" to the pipes and structures (not properties actually, but extension methods as you pointed out in another thread), I want to keep things as simple and effective as possible. In fact, performance will, at the end of day, dictate whether my "plugin" will be successful or not (if it takes 2h to calculate the network, it's not a very good plugin!)

    So, I'm learning as I go, hopefully making the right decisions to have an efficient code.

    Thanks for your inputs! They have been essential!

  6. #6
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: How to determine the lowest elevation of several pipes?

    Disregard some of my comments above, as I didn't pay close enough attention.

    Yes, iterating ObjectIdCollection if perfectly fine. There's no real need to compare EndStructureId with StartStructureId, since you're not doing anything with those Objects AFAIK. To do so logically, foreach Pipe's ObjectId's (start and end), you'd have to compare that to each-and-every-single other Pipe's start and end ObjectId, which at most exponentially increases the iteration, and at minimum forces you to iterate once, storing to a Dictionary, and then iterating that several times. No good. Instead, you've already obtained the ObjectIdCollection for the Network's Pipes - iterate that.

    You're already using a Transaction (to be more precise your code above is not, but should be using the Transaction; see the help documentation for AutoCAD .NET API code examples), so within that using statement, and after the call to GetPipeIds(), iterate the ObjectIdCollection, opening each (ForRead) as Pipe, and extract the 'low' elevation (storing if not already stored, comparing to stored, and storing the lowest if previously stored, etc.). One Transaction for the entire evaluation.

    HTH
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  7. #7
    Login to Give a bone
    0

    Default Re: How to determine the lowest elevation of several pipes?

    it's great to finally understand stuff! thanks a lot!

  8. #8
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: How to determine the lowest elevation of several pipes?

    Quote Originally Posted by ruipfbarreiros370525 View Post
    it's great to finally understand stuff! thanks a lot!
    We all start somewhere; I'm happy to help.

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Similar Threads

  1. Pipes Invert Elevation issues
    By Max-G in forum Revit MEP - General
    Replies: 3
    Last Post: 2015-09-02, 04:16 PM
  2. 2015: Lowest Elevation of a surface
    By mattab222 in forum AutoCAD Civil 3D - General
    Replies: 3
    Last Post: 2015-07-25, 02:37 AM
  3. 2014: Aligning two pipes elevation without a section.
    By Armando Martinez in forum Revit MEP - General
    Replies: 8
    Last Post: 2014-03-19, 11:15 PM
  4. 2011: Pipes Inserting at an Elevation of Zero
    By DBill2508 in forum AutoCAD Civil 3D - Pipes
    Replies: 0
    Last Post: 2012-09-06, 11:13 AM
  5. Combine Surfaces-Use lowest elevation
    By epipkin in forum AutoCAD Civil 3D - Surfaces
    Replies: 2
    Last Post: 2010-08-05, 04:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •