### Poll

#### ?

s
0 (0%)
s
1 (100%)

Total Members Voted: 1

### Author Topic: how to get the intersectpoint  (Read 2200 times)

0 Members and 1 Guest are viewing this topic.

#### frtfff

• Bull Frog
• Posts: 226
##### how to get the intersectpoint
« on: January 09, 2010, 10:05:31 AM »
I hope tp get a intersect point of a line and a pline .
but I don't have any idea.
Do you have any good idea?
Thank you
« Last Edit: January 11, 2010, 12:57:54 AM by Daniel »

#### XXL66

• Guest
##### Re: how to get the intersectpoint
« Reply #1 on: January 09, 2010, 12:00:47 PM »
based on begin, endpoint and bulge of pline compute circle. Compute intersection circle and infinite line. Result is 0 points, 1 (tangent) point or 2 points. In case of 2 points compute which is on the bulged segment.

#### frtfff

• Bull Frog
• Posts: 226
##### Re: how to get the intersectpoint
« Reply #2 on: January 10, 2010, 02:35:10 AM »

#### It's Alive!

• Needs a day job
• Posts: 7012
• AKA Daniel
##### Re: how to get the intersectpoint
« Reply #3 on: January 10, 2010, 09:16:02 AM »
Code: [Select]
`  static void doit(void)  {    CPromptEntityResult per1;    CEditor::GetEntity(per1,_T("Select Line"));    if(per1.Status != Acad::eNormal)    {      acutPrintf(_T("\nCEditor::GetEntity Line %ld: "),__LINE__ );      return;    }    CPromptEntityResult per2;    CEditor::GetEntity(per2,_T("Select PLine"));    if(per2.Status != Acad::eNormal)    {      acutPrintf(_T("\nCEditor::GetEntity Line %ld: "),__LINE__ );      return;    }    AcDbEntityPointer pEnt1(per1.ObjectId, AcDb::kForRead);    if(pEnt1.openStatus() != Acad::eOk)    {      acutPrintf(_T("\npEnt1.openStatus() Line %ld: "),__LINE__ );      return;    }    AcDbEntityPointer pEnt2(per2.ObjectId, AcDb::kForRead);    if(pEnt2.openStatus() != Acad::eOk)    {      acutPrintf(_T("\npEnt2.openStatus() Line %ld: "),__LINE__ );      return;    }    AcDbCurve *pLine = AcDbCurve::cast(pEnt1);    if(!pLine)    {      acutPrintf(_T("\npLine is Null Line %ld: "),__LINE__ );      return;    }    AcDbCurve *pPline = AcDbCurve::cast(pEnt2);    if(!pPline)    {      acutPrintf(_T("\npPline is Null Line %ld: "),__LINE__ );      return;    }    AcGePoint3dArray pts;    if(pLine->intersectWith(pPline,AcDb::kExtendThis,pts) != eOk)    {      acutPrintf(_T("\npLine->intersectWith Line %ld: "),__LINE__ );      return;    }    for(size_t i=0;i<pts.length();i++)    {      acutPrintf(_T("\n@ %g,%g,%g"),pts[i].x,pts[i].y,pts[i].z);    }  }`

#### frtfff

• Bull Frog
• Posts: 226
##### Re: how to get the intersectpoint
« Reply #4 on: January 10, 2010, 10:43:00 PM »
Code: [Select]
`// This is the revised code from Mr.Daneal //CPromptEntityResult per1; //CEditor::GetEntity(per1,_T("Select Line")); ads_name line_sel; ads_point pt_line; //acedEntSel(_T("\nSelect First line:"),line_sel,pt_line); if(acedEntSel(_T("\nSelect line:"),line_sel,pt_line) != Acad::eNormal) { acutPrintf(_T("\nCEditor::GetEntity Line %ld: "),__LINE__ ); return; } //CPromptEntityResult per2; //CEditor::GetEntity(per2,_T("Select PLine")); ads_name pilne_sel; ads_point Pt_pline; if(acedEntSel(_T("\nSelect Pline:"),pilne_sel,Pt_pline) != Acad::eNormal) { acutPrintf(_T("\nCEditor::GetEntity Line %ld: "),__LINE__ ); return; } AcDbObjectId lineId,plineId; acdbGetObjectId(lineId,line_sel); acdbGetObjectId(plineId,pilne_sel); //AcDbEntityPointer pEnt1(lineId, AcDb::kForRead); //AcDbEntityPointer pEnt2(plineId, AcDb::kForRead); AcDbEntity *pEnt1,*pEnt2; acdbOpenObject(pEnt1,lineId,AcDb::kForRead); acdbOpenObject(pEnt2,plineId,AcDb::kForRead); AcDbCurve *pLine = AcDbCurve::cast(pEnt1); if(!pLine) { acutPrintf(_T("\npLine is Null Line %ld: "),__LINE__ ); return; } AcDbCurve *pPline = AcDbCurve::cast(pEnt2); if(!pPline) { acutPrintf(_T("\npPline is Null Line %ld: "),__LINE__ ); return; } AcGePoint3dArray pts; if(pLine->intersectWith(pPline,AcDb::kExtendThis,pts) != eOk) { acutPrintf(_T("\npLine->intersectWith Line %ld: "),__LINE__ ); return; } for(size_t i=0;i<pts.length();i++) { acutPrintf(_T("\n@ %g,%g,%g"),pts[i].x,pts[i].y,pts[i].z); } pEnt1->close(); pEnt2->close();//The question is the first point and the final point doesn't work here.What happened?`
« Last Edit: January 10, 2010, 11:08:22 PM by Daniel »

#### frtfff

• Bull Frog
• Posts: 226
##### Re: how to get the intersectpoint
« Reply #5 on: January 10, 2010, 10:47:42 PM »
:kewl:

#### frtfff

• Bull Frog
• Posts: 226
##### Re: how to get the intersectpoint
« Reply #6 on: January 10, 2010, 10:50:35 PM »
We should get four datas for every condition.But it doesn't work.

#### It's Alive!

• Needs a day job
• Posts: 7012
• AKA Daniel
##### Re: how to get the intersectpoint
« Reply #7 on: January 11, 2010, 12:57:02 AM »
I guess it does not like Collinear segments