Author Topic: length of spline!  (Read 2150 times)

0 Members and 1 Guest are viewing this topic.

web.pawan

  • Guest
length of spline!
« on: December 19, 2009, 11:22:56 AM »
For finding spline length using autolisp, i use
Code: [Select]
(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++?
Code: [Select]
//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.
« Last Edit: December 19, 2009, 07:56:43 PM by Daniel »

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6963
  • AKA Daniel
Re: length of spline!
« Reply #1 on: December 19, 2009, 08:13:38 PM »
That's right, those both give the same length;

Code: [Select]
  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);
  }


web.pawan

  • Guest
Re: length of spline!
« Reply #2 on: December 20, 2009, 03:05:51 AM »
 :-) Thank you, but i could not verify
Code: [Select]
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.


It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6963
  • AKA Daniel
Re: length of spline!
« Reply #3 on: December 20, 2009, 03:23:59 AM »
Sorry, that's from my own class. try this

Code: [Select]
  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);
  }

web.pawan

  • Guest
Re: length of spline!
« Reply #4 on: December 20, 2009, 06:04:38 AM »
 :lol: Thank you!
You are very good at ARX!

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6963
  • AKA Daniel
Re: length of spline!
« Reply #5 on: December 20, 2009, 06:10:13 AM »
: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-)