Revit API determines the intersection of straight lines

Source: Internet
Author: User

Start
[TransactionAttribute (Autodesk. Revit. Attributes. TransactionMode. Manual)]
CmdDuctAlign: IExternalCommand
{
XYZ GetIntersection (Line line1, Line line2)
{
IntersectionResultArray results;

SetComparisonResult result
= Line1.Intersect (line2, results );
(SetComparisonResult. Overlap = result) InvalidOperationException (
);
(SetComparisonResult. Disjoint = result) InvalidOperationException (
);
(SetComparisonResult. Superset = result) InvalidOperationException (
);
(SetComparisonResult. Subset = result) InvalidOperationException (
);
(Results = | results. Size! =)
InvalidOperationException (
);

IntersectionResult iResult
= Results. get_Item ();

IResult. XYZPoint;
}
Result Execute (ExternalCommandData commandData, messages, ElementSet elements)
{
UIApplication app = commandData. Application;
Document doc = app. ActiveUIDocument. Document;
Selection sel = app. ActiveUIDocument. Selection;

SplitButtonData splitButtonData = SplitButtonData (,);
PushButton pbtn = PushButton ();
RibbonPanel rpanel = RibbonPanel ();


Transaction ts = Transaction (doc ,);
Ts. Start ();

IList <Reference> refDucts = sel. PickObjects (ObjectType. Element ,);
Duct duct1 = doc. GetElement (refDucts. ElementAt () Duct;
Duct duct2 = doc. GetElement (refDucts. ElementAt () Duct;
LocationCurve lCurve1 = duct1.Location LocationCurve;
LocationCurve lCurve2 = duct1.Location LocationCurve;
XYZ xyz11 = lCurve1.Curve. get_EndPoint ();
XYZ xyz12 = lCurve1.Curve. get_EndPoint ();
XYZ xyz21 = lCurve2.Curve. get_EndPoint ();
XYZ xyz22 = lCurve2.Curve. get_EndPoint ();
Line line1 = Line. get_Bound (xyz11, xyz12 );
Line line2 = Line. get_Bound (xyz21, xyz22 );
GetIntersection (line1, line2 );

Air Duct Movement

XYZ xyz1 = XYZ (xyz11.X, xyz11.Y ,);
XYZ xyz2 = XYZ (xyz12.X, xyz12.Y ,);
XYZ xyz3 = XYZ (xyz21.X, xyz21.Y ,);
XYZ xyz4 = XYZ (xyz22.X, xyz22.Y ,);
XYZ vec1 = xyz2-xyz1;
XYZ zVec = XYZ (,,);
XYZ nVec = vec1.CrossProduct (zVec). Normalize (); TaskDialog. Show (, nVec. CrossProduct (zVec). Normalize (). ToString ());
LCurve2.Move (nVec );



Ts. Commit ();

Result. Succeeded;
}
} Url: http://greatverve.cnblogs.com/p/revit-api-line-SetComparisonResult.html
Reference: http://revit.haotui.com/thread-171-1-32.htmlhttp://revit.haotui.com/thread-489-1-23.html

Related Article

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.