Autocad.net: calculates the intersection of two spatial curves.

Source: Internet
Author: User
Lead: http://www.objectarx.net/bbs/archiver? Tid-410.html

Using System;
Using System. Collections. Generic;
Using System. text;
Using Autodesk. AutoCAD. applicationservices;
Using Autodesk. AutoCAD. colors;
Using Autodesk. AutoCAD. databaseservices;
Using Autodesk. AutoCAD. editorinput;
Using Autodesk. AutoCAD. geometry;
Using Autodesk. AutoCAD. runtime;
Using Asapp = Autodesk. AutoCAD. applicationservices. Application;
Using Dstm = Autodesk. AutoCAD. databaseservices. transactionmanager;
Using Autodesk. AutoCAD. graphicsinterface;
Using Autodesk. AutoCAD. InterOP;

Namespace Objectarxnet. Test
{
/**/ /// <Summary>
///Intersection of two spatial Curves
/// </Summary>
Public   Class Intersection
{
[Commandmethod ( " Intersectiontest " )]
Public   Void Intersectiontest ()
{
Editor m_ed = Application. documentmanager. mdiactivedocument. Editor;
Database m_db = Hostapplicationservices. workingdatabase;
Promptentityoptions m_peo =   New Promptentityoptions ( " \ N select the first curve: " );
Promptentityresult m_per = M_ed.getentity (m_peo );
If (M_per.status ! = Promptstatus. OK) {Return;}
Objectid m_objid1 = M_per.objectid;

M_peo =   New Promptentityoptions ( " \ N select the second curve: " );
M_per = M_ed.getentity (m_peo );
If (M_per.status ! = Promptstatus. OK) {Return;}
Objectid m_objid2 = M_per.objectid;

Using (Transaction m_tr = M_db.transactionmanager.starttransaction ())
{
Curve m_cur1 = (Curve) m_tr.getobject (m_objid1, openmode. forread );
Curve m_cur2 = (Curve) m_tr.getobject (m_objid2, openmode. forread );

Point3dcollection m_ints =   New Point3dcollection ();
M_cur1.intersectwith (m_cur2, Intersect. onbothoperands, New Plane (), m_ints, 0 , 0 ); // All the knots obtained are on the C1 curve.
Foreach (Point3d m_pt In M_ints)
{
M_ed.writemessage ("\ N intersection of the first curve and the second curve: {0}", M_pt );
}

M_ed.writemessage ( " \ N = " );
M_ints.clear ();
M_cur2.intersectwith (m_cur1, Intersect. onbothoperands, New Plane (), m_ints, 0 , 0 ); // All the knots obtained are on the C2 curve.
Foreach (Point3d m_pt In M_ints)
{
M_ed.writemessage ("\ N intersection of the second curve and the first curve: {0}", M_pt );
}
M_tr.commit ();
}
}

}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.