pRegion->getAreaProp()

pRegion->getAreaProp()

EMD1954
Advocate Advocate
1,215 Views
6 Replies
Message 1 of 7

pRegion->getAreaProp()

EMD1954
Advocate
Advocate

I want to let the user draw a complicated, 2D polyline, select it, and have it convert to a region so I can use the mass properties for a handful of tasks.  I've gotten to the point (following the samples) where I am able to create the region using

 

es = AcDbRegion::createFromCurves(curveSegs, regions);

 

AcDbRegion *pRegion;

pRegion =static_cast<AcDbRegion*>(regions[0]);  // I only have one element to pick

 

pRegion->getPlane(plane);

plane.getCoordSystem(origin, xAxis, yAxis);

es = pRegion->getAreaProp(origin, xAxis, yAxis, perimeter, area, centroid, momInertia,

prodInertia, prinMoments, prinAxes, radiiGyration, extentsLow, extentsHigh);

 

Then I save it to the database.  It works fine up to this point, but I get the wrong centroid (and different than the command line "MASSPROP")

 

Anything obvious?  Any help would be appreciated.

Thanks,

Ed

0 Likes
Accepted solutions (1)
1,216 Views
6 Replies
Replies (6)
Message 2 of 7

owenwengerd
Advisor
Advisor

What are the actual values that you're passing for the origin, xAxis, and yAxis arguments to getAreaProp()? Perhaps the MASSPROP command uses the UCS instead of the World coordinate system.

--
Owen Wengerd
ManuSoft
0 Likes
Message 3 of 7

EMD1954
Advocate
Advocate

Origin is -50.1250, 76.0000, 0.0000 (it's the first point of the 3Dpoly that i created before it's turned into a region)
xAxis  is 1.0000, 0.0000, 0.0000
yAxis  is 0.0000, 1.0000, 0.0000

 

Function is attached as .txt file

 

Thanks,

Ed

 

 

0 Likes
Message 4 of 7

owenwengerd
Advisor
Advisor

Try the WCS or UCS, then compare the results to MASSPROP.

--
Owen Wengerd
ManuSoft
0 Likes
Message 5 of 7

EMD1954
Advocate
Advocate

Sorry for the trouble, but I don't understand.  I tried it in the "world" UCS, changed the view and set the UCS to "View" and even tried to set the UCS to "element".  What do you mean?  Sorry.

0 Likes
Message 6 of 7

owenwengerd
Advisor
Advisor

I am referring to the first three arguments to getAreaProp(). For example, the WCS would be:

pRegion->getAreaProp(AcGePoint3d(0,0,0), AcGeVector3d(1,0,0), AcGeVector3d(0,1,0), ...);
--
Owen Wengerd
ManuSoft
0 Likes
Message 7 of 7

EMD1954
Advocate
Advocate
Accepted solution

Yes.  The problem was that "origin" was returning the first point of the original polyline, so I just zeroed the X and Y coordinates (I need Z for the proper elevation).  The xAxis and yAxis were correct:

 

pRegion->getPlane(plane);

plane.getCoordSystem(origin, xAxis, yAxis); 

 

origin.x = 0.0;

origin.y = 0,0;

 

Works great - thank you,

Ed

0 Likes