Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am working on a custom tool in Civil 3D, and I'm encountering an issue when creating a pipe programmatically. After the pipe is created, I am trying to access the Pipe Family ID (using pipe.PartFamilyId), but it returns ObjectId.Null rather than a valid ID.
I even Used the Snoop command in the DWG file to check the pipe's properties, and the Pipe Family ID is still ObjectId.Null.
You will find the code i used below.
I checked parameters.PartFamily to make sure I got the correct ID, and it's correct. However, the Pipe Family ID is still returning ObjectId.Null after creating the pipe.
public class PipesService
{
public static ObjectId AddLinePipe(Document document, ObjectId networkId, Point3d startPoint, Point3d endPoint, PipeCreationParameters parameters)
{
var pipeId = ObjectId.Null;
var lineSegment3D = new LineSegment3d(startPoint, endPoint);
using (Transaction transaction = document.TransactionManager.StartTransaction())
{
var network = networkId.GetObject(OpenMode.ForWrite) as Network;
network.AddLinePipe(parameters.PartFamily, parameters.PartSize, lineSegment3D, ref pipeId, true);
transaction.Commit();
}
return pipeId;
}
public static ObjectId AddCurvePipe(Document document, ObjectId networkId, CircularArc3d circularArc3D, PipeCreationParameters parameters)
{
var endDirection3D = circularArc3D.GetTangent(circularArc3D.EndPoint).Direction;
var endDirection = new Vector2d(endDirection3D.X, endDirection3D.Y).Negate();
PipeCurveGeometry pipeCurveGeometry = new PipeCurveGeometry(circularArc3D.StartPoint, circularArc3D.EndPoint, endDirection);
var pipeId = ObjectId.Null;
using (Transaction transaction = document.TransactionManager.StartTransaction())
{
var network = networkId.GetObject(OpenMode.ForWrite) as Network;
pipeId = network.AddCurvePipe(parameters.PartFamily, parameters.PartSize, pipeCurveGeometry, true);
transaction.Commit();
}
return pipeId;
}
}
Solved! Go to Solution.