.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem using intersectWith

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
4140 Views, 5 Replies

Problem using intersectWith

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

5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

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?
         

Message 3 of 6
Alexander.Rivilis
in reply to: Anonymous

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

Message 4 of 6
Anonymous
in reply to: Alexander.Rivilis

thank you.

how to avoid this precision error?

Convert to 2D Line?

Message 5 of 6

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
in reply to: Anonymous

Thanks for the help 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report