Fit the curves in geometry ........polyline to geometry line

Hi All,
This is a twister around which i am unable to find any logic.
The Task is i have a polyline and need to convert it to a geometry of small arc’s, compound curves and reverse curves (Minimum Radius 550m say) maintaining the tangency with previous curve. The only limitation is the new line should be in the range of 50mm to 100mm max from the existing polyline.

I am able to do it manually by trial and error and fixing the arc/Compund curves but was trying to find a way to automate this process.

sample line is attached in the drawing. new block.dwg (120.4 KB)

Will be really happy to get some guidance on way forward.
Thanks.

This might be a good place to start: Dynamo Dictionary

Thanks for the reply @jacob.small but its not resolving the issue…

The node is just taking up the line vertices and adding arc/curve in between i guess. so the end result is same as the first line with same vertices.

am i missing something ?

I may not be understanding the intended result here - can you sketch out what you have vs what you want?

1 Like

@jacob.small Sorry if i was not clear,

The intention is to create red line of arc/compound curve from the cyan line. The sample line is attached in above drawing.

Hope i am able to explain.

Are you trying to offset a polyline as a polyarc (a series of arcs)? See if this helps.


offsetPolylineAsArcs.dyn (8.3 KB)

def lnToAr(pl:var[]..[], of:double)
{
	pc1 = List.FirstItem(pl.Curves());
	//First Arc
	ac1 = List.FirstItem(pc1);
	ac2 = ac1.Offset(of).PointAtParameter(0.5);
	ar1 = Arc.ByThreePoints(ac1.StartPoint,ac2,ac1.EndPoint);
	ac3 = List.RestOfItems(pc1);

	ar5 = [Imperative]
	{
		cnt = 1;
		pc2 = [ar1];

		for (cr in ac3)
		{
			pc2[cnt] = Arc.ByStartPointEndPointStartTangent(cr.StartPoint,cr.EndPoint,ar1.TangentAtParameter(1));
			ar1 = pc2[cnt];
			cnt = cnt + 1;
		}
		return pc2;
	}
	return ar5;
};

def offPlyArc(pl:var[]..[], off:double, mnRd:double)
{
	pl1 = pl.Offset(off);
	of1 = 0.1;
	bl1 = true;
	ar2 = [Imperative]
	{
		ar3 = [];
		while (bl1)
		{
 			ar3 = lnToAr(pl1,of1);
 			bl1 = List.Contains(ar3.Radius >= mnRd, true) && of1<10;
 			of1 = of1 + 0.1;
		}
		return ar3;
	}
	return ar2;
};
1 Like

@Vikram_Subbaiah thanks for reply, sorry if was not clear though the process is not related to creating an offset but try to fit in the arcs, compound curves to get a proper geometry from cyan line. I have moved cyan line to just provide clarity on the entity and result i am intending to get in RED. its some what best fit geometry but removing the vertices to get to that point which is not happening as per the ApproximatewithArcandLinesegment node. that being said if i can get offset line also i can get the required line from that i guess.

the code is giving bellow error in AutoCAD might be working fine in Revit (based on Revit API).

In that case set offset to 0

The definition converts a series of lines to a series of tangential curves

Try prefixing Arc as suggested in the error
I’ve replaced Arc with Autodesk.DesignScript.Geometry.Arc below. If it doesn’t work you could try Autodesk.AutoCAD.DynamoNodes.Arc

def lnToAr(pl:var[]..[], of:double)
{
	pc1 = List.FirstItem(pl.Curves());
	//First Arc
	ac1 = List.FirstItem(pc1);
	ac2 = ac1.Offset(of).PointAtParameter(0.5);
	ar1 = Autodesk.DesignScript.Geometry.Arc.ByThreePoints(ac1.StartPoint,ac2,ac1.EndPoint);
	ac3 = List.RestOfItems(pc1);

	ar5 = [Imperative]
	{
		cnt = 1;
		pc2 = [ar1];

		for (cr in ac3)
		{
			pc2[cnt] = Autodesk.DesignScript.Geometry.Arc.ByStartPointEndPointStartTangent(cr.StartPoint,cr.EndPoint,ar1.TangentAtParameter(1));
			ar1 = pc2[cnt];
			cnt = cnt + 1;
		}
		return pc2;
	}
	return ar5;
};

def offPlyArc(pl:var[]..[], off:double, mnRd:double)
{
	pl1 = pl.Offset(off);
	of1 = 0.1;
	bl1 = true;
	ar2 = [Imperative]
	{
		ar3 = [];
		while (bl1)
		{
 			ar3 = lnToAr(pl1,of1);
 			bl1 = List.Contains(ar3.Radius >= mnRd, true) && of1<10;
 			of1 = of1 + 0.1;
		}
		return ar3;
	}
	return ar2;
};

Still not sure why its not working …

By the way

At this location i can see your offset line have 233 points compare to original 151, little confused if the geometry is improved points will be reduced right ?

1 Like

Sorry, I have no clue either :confused:

The definition creates 151 arcs corresponding to the original 151 lines (not sure what the 233 was)

While this definition might not do what you’re looking for, I suppose you’ll need to engage a similar Imperative approach as every subsequent component is dependent on the altered state of previous one.

Yes thats what is happening with that OTT Node too …i am doing it manually at the moment. In civil 3D we hv a option of best fit alignment but its not much useful because of the restrictions in shifting.