程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> Revit API選擇三維視圖上一點

Revit API選擇三維視圖上一點

編輯:C#入門知識

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)
    {
         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

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved