TheSwamp
Code Red => ARX Programming => Topic started by: web.pawan on December 19, 2009, 11:22:56 AM
-
For finding spline length using autolisp, i use
(command "spline" pt1 pt2 pt3 pt4 "" pt1 pt4)
(setq ent1(entlast))
(setq lengthOfSpline(vlax-curve-getDistAtParam ent1 (vlax-curve-getEndParam ent1)))
how to do the same in C++?
//this doesn't give right value
ptArray contains pt1, pt2, pt3, pt4
for( int i = 0 ; i < 4; i++ )
vertices.append(asPnt3d( ptArray[i]));
AcDbSpline* spline = new AcDbSpline(vertices, startTangent, endTangent );
double dummy1=0, dummy2=0;
int retVal;
retVal = spline->getEndParam(dummy1);
retVal = spline->getDistAtParam(dummy1,dummy2);
delete spline;
return dummy2;
//i think this is not right as the outputs are different.
//any other way to find it? is there a direct call like object.length() to find out?
Thanks,
Pawan.
-
That's right, those both give the same length;
static void ExtTools_doit(void)
{
CPromptEntityResultPtr pRes = CEditor::GetEntity(_T("\nSelect Spline: "));
if(pRes->Status != Acad::eNormal){
return;
}
AcDbEntityPointer pEnt(pRes->ObjectId,AcDb::kForRead);
if(pEnt.openStatus() != eOk){
return;
}
AcDbSpline *pSpline = AcDbSpline::cast(pEnt);
if(pSpline == NULL){
return;
}
double endParam,length;
pSpline->getEndParam(endParam);
pSpline->getDistAtParam(endParam,length);
acutPrintf(_T("\nSpline Length is %g"),length);
}
-
:-) Thank you, but i could not verify
CPromptEntityResultPtr pRes = CEditor::GetEntity(_T("\nSelect Spline: "));
if(pRes->Status != Acad::eNormal){
return;
}
what's the equivalent in autocad 2009. I couldn't locate this class in object arx 2009.
-
Sorry, that's from my own class. try this
static void ExtTools_doit(void)
{
ads_name ename = { 0L , 0L };
ads_point pnt = {0.0, 0.0, 0.0};
AcDbObjectId eId;
if(acedEntSel(_T("\nSelect Spline: "),ename,pnt) == RTNORM){
acdbGetObjectId(eId,ename);
}
AcDbEntityPointer pEnt(eId, AcDb::kForRead);
if(pEnt.openStatus() != eOk){
return;
}
AcDbSpline *pSpline = AcDbSpline::cast(pEnt);
if(pSpline == NULL){
return;
}
double endParam,length;
pSpline->getEndParam(endParam);
pSpline->getDistAtParam(endParam,length);
acutPrintf(_T("\nSpline Length is %g"),length);
}
-
:lol: Thank you!
You are very good at ARX!
-
:lol: Thank you!
It's my pleasure.
You are very good at ARX!
Thanks! I feel I'm just a newbie with ARX..... I want to be like Owen when I grow up 8-)