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
Solved! Go to Solution.
Solved by hosneyalaa. Go to Solution.
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);
}
}
}
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,
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);
}
}
}
}