Hi Jeff,
I think that I confused you. To be more clear, i have a drawing that has piping in it as well as a civil3d surface. I was able to create an alignment along a section of the piping. Along with the alignment i created a profile and placed a profile view in an arbitrary location in the drawing. Using other software that was created, the user can select the polyline that represents the start and end of a piping run and a 3d box will be created around the polyline encompassing all of the piping. From that box, I create an elevation view drawing and was going to try and match up the profile view with the piping view to show the ground surface in relationship to the piping. Instead of trying to transform the profile view to match the piping view and get it match up correctly, I instead thought I would just create a 3d polyline above the pipe that matched the contour. So in reality, i don't really need the profile view, I just need the polyline from it.
So here is what I have and it appears to be working correctly.
private void CreatePolyline3dFromProfile(Profile profile, Polyline polyline, double samplingRate)
{
double startingStation = profile.StartingStation;
double endingStation = profile.EndingStation;
double currentLocation;
Vector3d dir = (polyline.EndPoint - polyline.StartPoint).GetNormal();
Point3dCollection points
= new Point3dCollection
(); points
.Add(new Point3d
(polyline
.StartPoint.X, polyline
.StartPoint.Y, profile
.ElevationAt(startingStation
))); currentLocation = samplingRate;
while (currentLocation < endingStation)
{
points
.Add(new Point3d
((startPoint
+ (dir
* currentLocation
)).X,
(startPoint
+ (dir
* currentLocation
)).Y, profile
.ElevationAt(currentLocation
))); currentLocation += samplingRate;
}
points
.Add(new Point3d
(polyline
.EndPoint.X, polyline
.EndPoint.Y, profile
.ElevationAt(endingStation
))); Database db = HostApplicationServices.WorkingDatabase;
using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord ms = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
Polyline3d poly
= new Polyline3d
(); ms.AppendEntity(poly);
tr.AddNewlyCreatedDBObject(poly, true);
foreach (Point3d pt in points)
{
PolylineVertex3d vertex
= new PolylineVertex3d
(pt
); poly.AppendVertex(vertex);
tr.AddNewlyCreatedDBObject(vertex, true);
}
tr.Commit();
}
}
As i said i know next to nothing about Civil and hope that I havent fallen into any traps. The code above works correctly and I can view the polyline and see that it follows the contour exactly. I also believe that I am adding the start point and end point correctly to the polyline. We shall see after some testing.
Thanks for your help.