AcGeCircArc3d start angle and end angle

Anonymous

AcGeCircArc3d start angle and end angle

Anonymous
Not applicable
I have created a AcGeCircArc3d and I wish to use the data from this to
create an actual arc in AutoCAD. When you get the startAng and endAng
properties of the arc they are set to the refVec() of the arc. How can I
convert this to the actual start and end angles that will generate a arc in
AutoCAD that matches the AcGeCircArc3d? I hope this makes sense to someone.
0 Likes
Reply
785 Views
5 Replies
Replies (5)

Anonymous
Not applicable
Hi Tim,

I'm not sure but i think you must set the current UCS in the plane where
your AcDbCircArc entity should be. The x-Axis of this UCS should have the
direction of the RefVec. Now you can set start- and endangle as they are in
the AcGeCircArc3d object.
Hope this helps.

Regards Steffen Lips


"Tim Nary" schrieb im Newsbeitrag
news:A25C481E1C73DB6A6EF61D622CC6F561@in.WebX.maYIadrTaRb...
> I have created a AcGeCircArc3d and I wish to use the data from this to
> create an actual arc in AutoCAD. When you get the startAng and endAng
> properties of the arc they are set to the refVec() of the arc. How can I
> convert this to the actual start and end angles that will generate a arc
in
> AutoCAD that matches the AcGeCircArc3d? I hope this makes sense to
someone.
>
>
0 Likes

Anonymous
Not applicable
I'm afraid that doesn't help me much.
0 Likes

Anonymous
Not applicable
Hopefully this will work for you...


/***************************************************************************
*
**
** geCurveToDbCurve
** allocates a new curve!
**
** **jma
**
*************************************/

AcDbCurve*
geCurveToDbCurve(const AcGeCurve3d* pcurve)
{
if (pcurve->isKindOf(AcGe::kLineSeg3d)) {
const AcGeLineSeg3d *geLine = static_cast
AcGeLineSeg3d*>(pcurve);
AcDbLine* dbLine = new AcDbLine(geLine->startPoint(),
geLine->endPoint());
return dbLine;
}
else if (pcurve->isKindOf(AcGe::kCircArc3d)) {
const AcGeCircArc3d* geCircArc = static_cast
AcGeCircArc3d*>(pcurve);
if (geCircArc->isClosed()) {
AcDbCircle* dbCircle = new AcDbCircle(geCircArc->center(),
geCircArc->normal(),
geCircArc->radius());
return dbCircle;
}
else {
AcGePlane ecsPlane;
Aec::getEcsPlane(geCircArc->normal(), ecsPlane);
double refAng = geCircArc->refVec().angleOnPlane(ecsPlane);
AcDbArc* dbArc = new AcDbArc(geCircArc->center(),
geCircArc->radius(),
(refAng + geCircArc->startAng()),
(refAng + geCircArc->endAng()));
dbArc->setNormal(geCircArc->normal());
return dbArc;
}
}
else if (pcurve->isKindOf(AcGe::kEllipArc3d)) {
const AcGeEllipArc3d* geEllipArc = static_cast
AcGeEllipArc3d*>(pcurve);

AcDbEllipse* dbEllipse = new AcDbEllipse;
double ratio = geEllipArc->minorRadius() /
geEllipArc->majorRadius();
AcGeVector3d majorAxis = geEllipArc->majorAxis() *
geEllipArc->majorRadius();

if (geEllipArc->isClosed()) {
dbEllipse->set(geEllipArc->center(), geEllipArc->normal(),
majorAxis, ratio);
}
else {
dbEllipse->set(geEllipArc->center(), geEllipArc->normal(),
majorAxis, ratio, geEllipArc->startAng(),
geEllipArc->endAng());
}

if (dbEllipse->isNull()) {
delete dbEllipse;
ASSERT(0);
return NULL;
}
else
return dbEllipse;
}
return static_cast(NULL);
}


Jim Awe
Autodesk, Inc.


"Tim Nary" wrote in message
news:A25C481E1C73DB6A6EF61D622CC6F561@in.WebX.maYIadrTaRb...
> I have created a AcGeCircArc3d and I wish to use the data from this to
> create an actual arc in AutoCAD. When you get the startAng and endAng
> properties of the arc they are set to the refVec() of the arc. How can I
> convert this to the actual start and end angles that will generate a arc
in
> AutoCAD that matches the AcGeCircArc3d? I hope this makes sense to
someone.
>
>
0 Likes

Anonymous
Not applicable
It almost works, what is the definition of
Aec::getEcsPlane(geCircArc->normal(), ecsPlane); ?
0 Likes

Anonymous
Not applicable
Oops... sorry I didn't see that reference. Here are two more functions.
You have to figure out what the angles of the arc are relative to its ECS,
so you need to get the Plane of the Arc's ECS first.


/***************************************************************************
*
**
** getEcsToWcsMatrix
** run AutoCAD's arbitrary matrix algorithm for ECS entities
**
** **jma
**
*************************************/

void
getEcsToWcsMatrix(const AcGePoint3d& origin,
const AcGeVector3d& zAxis, AcGeMatrix3d& mat)
{
const double kArbBound = 0.015625; // 1/64th

// short circuit if in WCS already
if (zAxis == AcGeVector3d::kZAxis) {
mat.setToIdentity();
return;
}

AcGeVector3d xAxis, yAxis;

ASSERT(zAxis.isUnitLength());

if ((fabs(zAxis.x) < kArbBound) && (fabs(zAxis.y) < kArbBound))
xAxis = AcGeVector3d::kYAxis.crossProduct(zAxis);
else
xAxis = AcGeVector3d::kZAxis.crossProduct(zAxis);

xAxis.normalize();
yAxis = zAxis.crossProduct(xAxis);
yAxis.normalize();

mat.setCoordSystem(origin, xAxis, yAxis, zAxis);
}


/***************************************************************************
*
**
** getEcsPlane
** This is the ECS plane for an AutoCAD entity. It can then be used to
** calculate angles relative to the ECS plane, for instance, angles of
** AcDbArc, AcDbBlockReference
**
** **jma
**
*************************************/

void
getEcsPlane(const AcGeVector3d& entNormal, AcGePlane& ecsPlane)
{
AcGeMatrix3d ecsMat;
getEcsToWcsMatrix(AcGePoint3d::kOrigin, entNormal, ecsMat);

AcGePoint3d origin;
AcGeVector3d xAxis, yAxis, zAxis;
ecsMat.getCoordSystem(origin, xAxis, yAxis, zAxis);
ecsPlane.set(origin, xAxis, yAxis);
}


"Tim Nary" wrote in message
news:0EEB0A1C1275C7F8D3A454898D1742F2@in.WebX.maYIadrTaRb...
> It almost works, what is the definition of
> Aec::getEcsPlane(geCircArc->normal(), ecsPlane); ?
>
>
>
0 Likes