+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Junior Member
    Using
    AutoCAD 2013
    Join Date
    Jul 2012
    Posts
    12

    Default find two match point in a point2dcollection

    Registered forum members do not see this ad.

    Hello,

    How we cad find two match point in a point2dcollection?
    The following code does not work correctly.

    Point2dCollection colPt = new Point2dCollection();
    string sDoubleVertex ="";

    for (int nCnt1 = 0; nCnt1 < (colPt.Count / 2); nCnt1++)
    {
    for (int nCnt2 = 0; nCnt2 < colPt.Count; nCnt2++)
    {
    // Step to the next iteration.
    if (nCnt1 == nCnt2) continue;
    if ((colPt[nCnt1].X.ToString() == colPt[nCnt2].X.ToString()) &&
    (colPt[nCnt2].Y.ToString() == colPt[nCnt2].Y.ToString()))
    {
    sDoubleVertex = nCnt2.ToString() + "," + sDoubleVertex;
    }
    }
    }

    Thank you,
    Mohsen

  2. #2
    Full Member
    Using
    AutoCAD 2010
    Join Date
    Oct 2013
    Posts
    78

    Default

    Quote Originally Posted by mohsen62sm View Post
    Hello,

    How we cad find two match point in a point2dcollection?
    The following code does not work correctly.

    Point2dCollection colPt = new Point2dCollection();
    string sDoubleVertex ="";

    for (int nCnt1 = 0; nCnt1 < (colPt.Count / 2); nCnt1++)
    {
    for (int nCnt2 = 0; nCnt2 < colPt.Count; nCnt2++)
    {
    // Step to the next iteration.
    if (nCnt1 == nCnt2) continue;
    if ((colPt[nCnt1].X.ToString() == colPt[nCnt2].X.ToString()) &&
    (colPt[nCnt2].Y.ToString() == colPt[nCnt2].Y.ToString()))
    {
    sDoubleVertex = nCnt2.ToString() + "," + sDoubleVertex;
    }
    }
    }

    Thank you,
    Mohsen
    I use VBA so that I'm only guessing what your problem could be like.
    Maybe it derives from the use of comparison between string values rather than between double ones.

    And yet in my experience even using double values comparison I always found myself forced to round numbers in order to have the match I knew there should be for my needs.
    For instance in VBA I use expressions like
    Code:
     
    if (Round(minExt(0), 5) = Round(maxExt(0), 5)) and (Round(minExt(1), 5) = Round(maxExt(1), 5)) then
    thus declaring I'm satisfied for match up to 5 digits after the comma.
    You could ask for a more precise matching, but first check the inner precision that every numeric variable type hase so as not to seek for an impossible match.

  3. #3
    Luminous Being BlackBox's Avatar
    Computer Details
    BlackBox's Computer Details
    Operating System:
    Windows 8.1 Professional, Server 2012 R2 Datacenter
    Computer:
    Dell Precision T3600
    CPU:
    Hex-Core Intel Xeon 3.2Ghz
    RAM:
    32GB
    Graphics:
    3GB NVIDIA Quadro K4000
    Primary Storage:
    2 x 240GB Samsung EVO SSD (RAID 0)
    Secondary Storage:
    1TB Western Digital VelociRaptor 10K RPM
    Monitor:
    Dual 24" Dell Ultrasharp Widescreen Monitors
    Discipline
    Civil
    BlackBox's Discipline Details
    Occupation
    Senior Civil Designer
    Discipline
    Civil
    Details
    Public/Private Land Development, Transportation, and Utilities.
    Using
    Civil 3D 2016
    Join Date
    Nov 2009
    Posts
    5,282

    Default

    Registered forum members do not see this ad.

    Linq may offer a more expedient means by which to perform the desired comparison, but thinking linearly, one could simply iterate the Collection, and compare both the Point2d, and its IndexOf to others within the Collection.

    This may also be of use:

    http://through-the-interface.typepad...using-net.html

    Cheers
    "Potential has a shelf life." - Margaret Atwood
    AutoCAD, and Civil 3D Certified Professional | Autodesk Authorized Developer
    Sincpac C3D ~ Exchange Apps ~ Autoloader ~ AutoCAD Security

Similar Threads

  1. Find Curve Point
    By gS7 in forum AutoLISP, Visual LISP & DCL
    Replies: 17
    Last Post: 13th Apr 2013, 06:09 am
  2. find intersect point
    By kalai in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 10th Jun 2011, 12:51 pm
  3. Match Z elevation of a point to another point
    By symoin in forum AutoLISP, Visual LISP & DCL
    Replies: 9
    Last Post: 6th Jan 2011, 12:36 am
  4. Move objects to match x (y,z) -coordinate of another point
    By Randolph in forum AutoLISP, Visual LISP & DCL
    Replies: 16
    Last Post: 11th Nov 2009, 06:17 pm
  5. Replies: 4
    Last Post: 27th Aug 2007, 11:35 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts