Revit API select a point on the 3D view

Source: Internet
Author: User

Start
[TransactionAttribute (Autodesk. Revit. Attributes. TransactionMode. Manual)]
CmdPickPointIn3d: IExternalCommand
{
Result Execute (ExternalCommandData commandData, messages, ElementSet elements)
{
UIApplication app = commandData. Application;
Document doc = app. ActiveUIDocument. Document;

XYZ point_in_3d;

(PickFaceSetWorkPlaneAndPickPoint (app. ActiveUIDocument, point_in_3d ))
{
TaskDialog. Show (,

+
+ PointString (point_in_3d ));

Result. Succeeded;
}

{
Messages =;
Result. Failed;
}

Result. Succeeded;
}
PointString (XYZ p)
{
. Format (,
RealString (p. X ),
RealString (p. Y ),
RealString (p. Z ));
}
PointString (UV p)
{
. Format (,
RealString (p. U ),
RealString (p. V ));
}
RealString ()
{
A. ToString ();
}
PickFaceSetWorkPlaneAndPickPoint (UIDocument uidoc, XYZ point_in_3d)
{
Point_in_3d =;

Document doc = uidoc. Document;

Reference r = uidoc. Selection. PickObject (
ObjectType. Face,
);

Element e = doc. get_Element (r. ElementId );

(! = E)
{
PlanarFace face
= E. GetGeometryObjectFromReference (r)
PlanarFace;

(Face! =)
{
Plane plane = Plane (
Face. Normal, face. Origin );

Transaction t = Transaction (doc );

T. Start (
+ );

SketchPlane sp = doc. Create. NewSketchPlane (
Plane );

Uidoc. ActiveView. SketchPlane = sp;
Uidoc. ActiveView. ShowActiveWorkPlane ();


{
Point_in_3d = uidoc. Selection. PickPoint (

+ );
}
(OperationCanceledException)
{
}

T. RollBack ();
}
}
! = Point_in_3d;
}
} Url: http://greatverve.cnblogs.com/p/pick-a-point-in-3d.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.