Hello
i have trouble with the AcDb3dSolid revolve function.
The following code works fine in Autocad2012,2013,2014.
Now in 2015 i get an Acad::eOk, but the Solid has no volume.
if i use the createRevolvedSolid function
AcDbRevolveOptions arevopt;
es=m_solid->createRevolvedSolid((AcDbRegion*)l_region[0],axisPoint,axisDir,angleOfRevolution,0,arevopt);
i get the correct solid.
Is there a know error in the revolve funtion?
void testsolid_rotate()
{
bool bret=false;
AcGePoint3d axisPoint(0.0,0.0,0.0);
AcGeVector3d axisDir(0.0,1.0,0.0);
AcDbVoidPtrArray l_ar,l_region;
AcDbLine *aline=new AcDbLine();
aline->setStartPoint(AcGePoint3d(5.0,0.0,0.0));
aline->setEndPoint(AcGePoint3d(10.0,0.0,0.0));
l_ar.append(aline);
aline=new AcDbLine();
aline->setStartPoint(AcGePoint3d(10.0,00.0,0.0));
aline->setEndPoint(AcGePoint3d(10.0,20.0,0.0));
l_ar.append(aline);
aline=new AcDbLine();
aline->setStartPoint(AcGePoint3d(10.0,20.0,0.0));
aline->setEndPoint(AcGePoint3d(8.0,20.0,0.0));
l_ar.append(aline);
aline=new AcDbLine();
aline->setStartPoint(AcGePoint3d(8.0,20.0,0.0));
aline->setEndPoint(AcGePoint3d(8.0,40.0,0.0));
l_ar.append(aline);
aline=new AcDbLine();
aline->setStartPoint(AcGePoint3d(8.0,40.0,0.0));
aline->setEndPoint(AcGePoint3d(5.0,40.0,0.0));
l_ar.append(aline);
aline=new AcDbLine();
aline->setStartPoint(AcGePoint3d(5.0,40.0,0.0));
aline->setEndPoint(AcGePoint3d(5.0,0.0,0.0));
l_ar.append(aline);
AcDbRegion::createFromCurves(l_ar,l_region);
AcDb3dSolid *m_solid;
m_solid=new AcDb3dSolid();
if (m_solid)
{
m_solid->setRecordHistory(false);
m_solid->setDatabaseDefaults(acdbHostApplicationServices()->workingDatabase());
double angleOfRevolution = 2.0*M_PI;
if (m_solid->revolve((AcDbRegion*)l_region[0],axisPoint,axisDir,angleOfRevolution)==Acad::eOk)
{
Acad::ErrorStatus es;
double volume;
AcGePoint3d centroid;
double momInertia[3];
double prodInertia[3];
double prinMoments[3];
AcGeVector3d prinAxes[3];
double radiiGyration[3];
AcDbExtents extents;
m_solid->getMassProp(volume,centroid,momInertia,prodInertia,prinMoments,prinAxes,radiiGyration,extents);
ads_printf(_T("\n Volume1:%g"),volume);
}
}
}
Is workingDatabase() returning a non-NULL value? What is the return value of the call to getMassProp()?
Hello,
workingDatabase() returning a value.
getMassProp() returns a Acad::eOk.
m_solid->revolve((AcDbRegion*)l_region[0],axisPoint,axisDir,angleOfRevolution)
returns Acad::eOk no Solid.
Volume=0;
m_solid->createRevolvedSolid((AcDbRegion*)l_region[0],axisPoint,axisDir,angleOfRevolution,0,arevopt)
i get the solid.
Volume is okay.
Sorry, I'm out of ideas. I recommend to attach a complete self-contained buildable function for reproducing the problem so that someone from Autodesk can try to reproduce it.
Hi Owen,
thanks.
In the first post is the fully code.
Copy it and you can try it.
Maybe somebody at autodesk can debug the revolve function and find the error.
I am able to reproduce the problem. I've cleaned up your code and made a more readable test case:
//region boundary curves AcDbLine Line1(AcGePoint3d(5.0,0.0,0.0), AcGePoint3d(10.0,0.0,0.0)); AcDbLine Line2(AcGePoint3d(10.0,0.0,0.0), AcGePoint3d(10.0,20.0,0.0)); AcDbLine Line3(AcGePoint3d(10.0,20.0,0.0), AcGePoint3d(8.0,20.0,0.0)); AcDbLine Line4(AcGePoint3d(8.0,20.0,0.0), AcGePoint3d(8.0,40.0,0.0)); AcDbLine Line5(AcGePoint3d(8.0,40.0,0.0), AcGePoint3d(5.0,40.0,0.0)); AcDbLine Line6(AcGePoint3d(5.0,40.0,0.0), AcGePoint3d(5.0,0.0,0.0)); AcDbVoidPtrArray rCurves; rCurves.append(&Line1); rCurves.append(&Line2); rCurves.append(&Line3); rCurves.append(&Line4); rCurves.append(&Line5); rCurves.append(&Line6); AcDbVoidPtrArray rRegions; Acad::ErrorStatus es = AcDbRegion::createFromCurves(rCurves, rRegions); if (es == Acad::eOk && !rRegions.isEmpty()) { AcDb3dSolid Solid; Solid.setRecordHistory(false); Solid.setDatabaseDefaults(acdbHostApplicationServices()->workingDatabase()); double angleOfRevolution = 2.0 * 3.141592653589793238462643383279502884197; es = Solid.revolve((AcDbRegion*)rRegions[0], AcGePoint3d::kOrigin, AcGeVector3d::kYAxis, angleOfRevolution); if (es == Acad::eOk) { double volume = 0; AcGePoint3d centroid; double momInertia[3]; double prodInertia[3]; double prinMoments[3]; AcGeVector3d prinAxes[3]; double radiiGyration[3]; AcDbExtents extents; es = Solid.getMassProp(volume, centroid, momInertia, prodInertia, prinMoments, prinAxes, radiiGyration, extents); if (es == Acad::eOk) ads_printf(_T("\n Volume1:%g"),volume); } }