Problem using intersectWith

Problem using intersectWith

Anonymous
Not applicable
4,880 Views
5 Replies
Message 1 of 6

Problem using intersectWith

Anonymous
Not applicable

my code

 

 [CommandMethod("testLineCross")]
  public void testLineCross()
 {
             Document doc = AcadApp.DocumentManager.MdiActiveDocument;
             Editor ed = doc.Editor;
             Database db = doc.Database;
             PromptEntityResult per = ed.GetEntity("Line1");
             using (Transaction tr = doc.TransactionManager.StartOpenCloseTransaction())
             {
                 Line l1 = tr.GetObject(per.ObjectId, OpenMode.ForRead) as Line;
                 per = ed.GetEntity("Line2");
                 Line l2 = tr.GetObject(per.ObjectId, OpenMode.ForRead) as Line;
                 Point3dCollection ptcol = new Point3dCollection();
                 l1.IntersectWith(l2, Intersect.ExtendBoth,ptcol, IntPtr.Zero, IntPtr.Zero);
                 if (ptcol.Count > 0)
                     ed.WriteMessage("Intersect");
                 else
                     ed.WriteMessage("non-intersect");
                 tr.Commit();
             }	
   }

My dwg see the Attachemnts.

why get the intersectPoint?

Version:AutoCAD 2012

0 Likes
Accepted solutions (1)
4,881 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

Line1
                 from, X=11924.7823  Y=8634.7220  Z=   0.0000
                to, X=11926.0027  Y=-9044.7187  Z=   0.0000
Line2               
                from, X=5170.8647  Y=2737.5595  Z=   0.0000
                 to, X=18677.5784  Y=2737.5595  Z=   0.0000

  using the code:

 l1.IntersectWith(l2, Intersect.ExtendBoth,ptcol, IntPtr.Zero, IntPtr.Zero);

but the resulst show ptcol.Count==0.Why can not get the intersect point?
         

0 Likes
Message 3 of 6

Alexander.Rivilis
Mentor
Mentor

It easy explain:

 

2017-03-24_15-01-30.png

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 4 of 6

Anonymous
Not applicable

thank you.

how to avoid this precision error?

Convert to 2D Line?

0 Likes
Message 5 of 6

Alexander.Rivilis
Mentor
Mentor
Accepted solution

I can recommend using this method:

 

public void IntersectWith(
    Entity entityPointer, 
    Autodesk.AutoCAD.DatabaseServices.Intersect intersectType, 
    Plane projectionPlane, // !!!!!!!! 
    Point3dCollection points, 
    IntPtr thisGraphicSystemMarker, 
    IntPtr otherGraphicSystemMarker
);

 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 6 of 6

Richard_AshJNQQ8
Explorer
Explorer

Thanks for the help 🙂

0 Likes