.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Created Polyline3d from corridor's applied subassembly is not planar

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
michal_hcz
188 Views, 2 Replies

Created Polyline3d from corridor's applied subassembly is not planar

Hi,

I wanted to create a lofted solid3d from polyline3ds which I got from shape points in an applied subassembly in a corridor. But some of them are not planar. So I ortho-projected shape points onto a plane created from corridor frequency but this didn't work either even though point coordinates were slightly modified.
Tested on Civil 24 and 25.

But when I use autocad command LOFT solid is created.
Any idea how to deal with that non-planar 3d polylines?


Thanks for any recommendations.

 

michal_hcz_1-1715958612542.png

 

Corridor created along Y axis but some of polylines are still not planar.

michal_hcz_0-1715959702856.png

 

 

 

Corridor Corridor = corrId.GetObject(OpenMode.ForRead) as Corridor;

	foreach (Baseline bl in Corridor.Baselines)
	{
		foreach (BaselineRegion reg in bl.BaselineRegions)
		{
			foreach (double station in reg.SortedStations())
			{
				AppliedAssembly appliedAssembly = reg.AppliedAssemblies.GetItemAt(station);

				foreach (var subass in appliedAssembly.GetAppliedSubassemblies())
				{
					foreach (CalculatedShape cShape in subass.Shapes)
					{
						foreach (string shapeCode in cShape.CorridorCodes)
						{
							foreach (CalculatedLink cLink in cShape.CalculatedLinks)
							{
								foreach (CalculatedPoint cPoint in cLink.CalculatedPoints)
								{
									// cPoint.XYZ <-- points for polylines
								}
							}
						}
					}
				}
			}
		}
	}


internal void CreatePolyline3d(List<Point3d> points, Transaction tr)
{
	if (points.Count < 3) return;

	Polyline3d Polyline3d = new Polyline3d();
	Polyline3d.ColorIndex = 3;

	var bt = (BlockTable)tr.GetObject(HostApplicationServices.WorkingDatabase.BlockTableId, OpenMode.ForRead, false);
	var btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false);

	btr.AppendEntity(Polyline3d);
	tr.AddNewlyCreatedDBObject(Polyline3d, true);

	foreach (Point3d p in points)
	{
		PolylineVertex3d vertex = new PolylineVertex3d(p);
		Polyline3d.AppendVertex(vertex);

		tr.AddNewlyCreatedDBObject(vertex, true);
	}

	Polyline3d.Closed = true;
}

internal void CreateSolid3d(Polyline3d poly1, Polyline3d poly2, Transaction tr)
{
	if (poly1.IsPlanar && poly2.IsPlanar) // <-- some of them are not planar
	{
		Solid3d s = new Solid3d();

		s.CreateLoftedSolid(new Entity[2] { poly1, poly2 }, new Entity[0], null, new LoftOptions());

		var bt = (BlockTable)tr.GetObject(HostApplicationServices.WorkingDatabase.BlockTableId, OpenMode.ForRead, false);
		var btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false);

		btr.AppendEntity(s);
		tr.AddNewlyCreatedDBObject(s, true);
	}
}

 

 

 

2 REPLIES 2
Message 2 of 3
hosneyalaa
in reply to: michal_hcz
Message 3 of 3
michal_hcz
in reply to: michal_hcz

Thank you, using Polyline instead of Polyline3d helped.

Michal

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report