Announcements

Community notifications may experience intermittent interruptions between 10–12 November during scheduled maintenance. We appreciate your patience.

Get Invert Elevations and coordinate of all Pressure Pipe

Get Invert Elevations and coordinate of all Pressure Pipe

NoelRico
Advocate Advocate
1,451 Views
4 Replies
Message 1 of 5

Get Invert Elevations and coordinate of all Pressure Pipe

NoelRico
Advocate
Advocate

Hi Everyone,

 

I got Civil3d 2023 drawing from designer that contains pressure pipe.

I want to collect all the start/end coordinate and invert elevation of all pressure pipe so I can draw a 3d polyline on it and give to surveyor for staking in the field.

 

I'm currently creating profile by tracing the bottom of pressure pipes and fittings in the profile view then create featureline from alignment, but its taking time. Please send me any C# code to automate this process.

 

Any help will be greatly appreciated.

 

Thanks,

 

Noel

 

 

0 Likes
Accepted solutions (1)
1,452 Views
4 Replies
Replies (4)
Message 2 of 5

hosneyalaa
Advisor
Advisor

 

Hi @NoelRico 

For best answer , can you attached example drawing

 

Note , can you use this code with some changes

Looking at it 

 

 

 

https://forums.autodesk.com/t5/civil-3d-customization/read-property-data-from-an-entity/m-p/6393069

CivilDocument doc = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument;
Document acDoc = acDocMgr.MdiActiveDocument;
Database acCurDb = acDoc.Database;
using (System.IO.StreamWriter sw = new StreamWriter(@"d:\output.txt", true))
using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
{
    ObjectIdCollection pipeNetworkIds = doc.GetPipeNetworkIds();
    foreach (ObjectId pipeNetworkId in pipeNetworkIds)
    {
        Network oNetwork = ts.GetObject(pipeNetworkId, OpenMode.ForWrite) as Network;
        ObjectIdCollection pipeIds = oNetwork.GetPipeIds();
        foreach (ObjectId pipeId in pipeIds)
        {
            Pipe oPipe = ts.GetObject(pipeId, OpenMode.ForWrite) as Pipe;
            ObjectIdCollection setIds = PropertyDataServices.GetPropertySets(oPipe);
            foreach (ObjectId psId in setIds)
            {
                PropertySet pset = ts.GetObject(psId, OpenMode.ForRead, false, false) as PropertySet;
                PropertySetDefinition psd = ts.GetObject(pset.PropertySetDefinition, OpenMode.ForRead) as PropertySetDefinition;
                foreach (PropertyDefinition pd in psd.Definitions)
                {
                    int propertyId=pset.PropertyNameToId(pd.Name);
                    object value = pset.GetAt(propertyId);
                    sw.WriteLine("Handler: " + oPipe.Handle.ToString() + "; " + pd.Name + ": " + value.ToString().Trim());
                 }  
                 //PropertySetDataCollection psetDataColl = pset.PropertySetData;
                 //PropertySetData pPropData;
                //for (int c = 0; c < psetDataColl.Count; c++)
                //{
                    // pPropData = psetDataColl[c];
                    // object data = pPropData.GetData();
                    //}
                }
                sw.WriteLine(System.Environment.NewLine);

            }
        }
}

 

 

0 Likes
Message 3 of 5

NoelRico
Advocate
Advocate

Hi Alaa Hosney;

 

Thanks for the Code. I have already code for Pipe Network. I need only some properties of Pressure Network, please see below image.

 

Thanks,

0 Likes
Message 4 of 5

hosneyalaa
Advisor
Advisor
Accepted solution

 

hi @NoelRico 

try

public void InvertElevationscoordinates()
        {
            CivilDocument doc = CivilApplication.ActiveDocument;
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
            {
                ObjectIdCollection pipeNetworkIds = doc.GetPressurePipeNetworkIds();
                foreach (ObjectId pipeNetworkId in pipeNetworkIds)
                {
                    PressurePipeNetwork oNetwork = ts.GetObject(pipeNetworkId, OpenMode.ForWrite) as PressurePipeNetwork;
                    ObjectIdCollection pipeIds = oNetwork.GetPipeIds();
                    foreach (ObjectId pipeId in pipeIds)
                    {
                        PressurePipe oPipe = ts.GetObject(pipeId, OpenMode.ForWrite) as PressurePipe;

                        ed.WriteMessage(" " + System.Environment.NewLine);

                        ed.WriteMessage(oPipe.Name + System.Environment.NewLine);

                        string ContentText = string.Format("{0} StartPoint.X {1} StartPoint.Y {2} EndPoint.X {3} EndPoint.Y" +
                            " {4} Start Invert  {5} End Invert          ",
                            oPipe.StartPoint.X, oPipe.StartPoint.Y, oPipe.EndPoint.X, oPipe.EndPoint.Y, oPipe.StartElevation -( oPipe.InnerDiameter / 2 )
                            , oPipe.EndElevation - (oPipe.InnerDiameter / 2) );
                        ed.WriteMessage(ContentText);

                        ed.WriteMessage(" " + System.Environment.NewLine);
                        

                    }
                }
            }
        }

 

Captureq.JPG

Message 5 of 5

NoelRico
Advocate
Advocate
Thanks,
0 Likes