Hello,
I migrated my application to Autocad 2018 - I am using amodeler API to create elbows. The api ExtrudeAlognPath now fails with error code 18- eApproximationMustBeAtLeastFour. I have given approximation as 32. This code was working in ACAD 2016 and earlier.
Please help below is sample code
I am creating 2 circular faces as ends and circle as path and giving 2 point on path. I tried to increase number of points on path still I get same error.
eApproximationMustBeAtLeastFour
void CElbow2::CreateElbowBody(Body& body, AcGePoint3d& orgPt)
{
try
{
double m_radius = 200;
m_angle = 1.5707 //90deg
m_EndRadius1 = m_EndRadius2 = 200;
Point3d plg[3];
Line3d rotationAxis(Line3d(Point3d(0.0, m_radius, 0.0), Vector3d::kZDir));
Body bdyStart;
if (m_angle >= 0.0)
{
plg[0] = Point3d(0.0, -m_EndRadius1, -m_EndRadius1);
plg[1] = Point3d(0.0, -m_EndRadius1, m_EndRadius1);
plg[2] = Point3d(0.0, m_EndRadius1, m_EndRadius1);
}
else
{
plg[0] = Point3d(0.0, -m_EndRadius1, -m_EndRadius1);
plg[1] = Point3d(0.0, m_EndRadius1, -m_EndRadius1);
plg[2] = Point3d(0.0, m_EndRadius1, m_EndRadius1);
}
new Face(Circle3d(plg[0], plg[1], plg[2], m_EndRadius1), 1, 32, &bdyStart);
Body bdyEnd;
if (m_angle >= 0.0)
{
plg[0] = Point3d(0.0, -m_EndRadius2, -m_EndRadius2);
plg[1] = Point3d(0.0, -m_EndRadius2, m_EndRadius2);
plg[2] = Point3d(0.0, m_EndRadius2, m_EndRadius2);
}
else
{
plg[0] = Point3d(0.0, -m_EndRadius2, -m_EndRadius2);
plg[1] = Point3d(0.0, m_EndRadius2, -m_EndRadius2);
plg[2] = Point3d(0.0, m_EndRadius2, m_EndRadius2);
}
new Face(Circle3d(plg[0], plg[1], plg[2], m_EndRadius2), 1, 32, &bdyEnd);
bdyEnd.rotate(rotationAxis, m_angle);
PolygonVertexData* pathVertexData[1];
int numberOfPathPoints = 2;
Point3d plg2[2];
plg2[0] = Point3d(0.0, 0.0, 0.0);
plg2[1] = Point3d(0.0, 0.0, 0.0);
plg2[1] *= Transf3d::rotation(rotationAxis, m_angle/4);
plg2[2] *= Transf3d::rotation(rotationAxis, m_angle);
Point3d linest(0.0, m_radius, 0.0);
Vector3d vec = m_angle >= 0.0 ? Vector3d::kZDir : -Vector3d::kZDir;
Circle3d circle(Line3d(linest, vec), m_radius);
pathVertexData[0] = new PolygonVertexData(PolygonVertexData::kArc3d, circle,32);
//pathVertexData[1] = NULL;
body = Body::Body(Body::extrusionAlongPath(bdyStart, bdyEnd,
plg2, pathVertexData, numberOfPathPoints,
false, false));
delete pathVertexData[0];
}
catch( ErrorCode error )
{
printErrorMsg( _T("CElbow2::body"), *this, error );
}
}
Solved! Go to Solution.
Thanks.
I can produce crash behavior with AsdkBody::createExtrusionAlongPath
certain exceptions are thrown.
With the example you shared I don't an error but a hard crash.
Can you please provide us a code sample project which will help us replicate the behavior,
About the crash I already requested Engineering to pursue.
Hello MADHUKAR,
Thanks for support.
Sorry, I found issue in my code, I was providing wrong data to method, the number of vertices and number of polygon vertex data should be same.
This resolves the issue 🙂
numberOfPathPoints and pathVertexData should be same..
Thanks...