WELCOME

a:hover { cursor:url(https://files.cnblogs.com/files/laoguantongxiegogo/click_24px_1231393_easyicon.net.ico),auto; } body { cursor:url(https://files.cnblogs.com/files/laoguantongxiegogo/pointer_24px_1231389_easyicon.net.ico),auto; }

二次开发之拾取构件生成三维视图

        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
    {
        UIDocument uidoc = commandData.Application.ActiveUIDocument;
        Document doc = uidoc.Document;
        Selection sel = uidoc.Selection;
        View view = commandData.View;
        Element ele = doc.GetElement(sel.PickObject(ObjectType.Element, "选择构件"));
        BoundingBoxXYZ boundingBox = ele.get_BoundingBox(view);
        Transform transform = Transform.Identity;         

        BoundingBoxXYZ box = new BoundingBoxXYZ();
        box.Transform = transform;
        box.Min = boundingBox.Min;
        box.Max = boundingBox.Max;
        Transaction ts = new Transaction(doc, "创建围框");
        ts.Start();
        View3D view3D = View3D.CreateIsometric
            (doc, new FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType))
            .Cast<ViewFamilyType>().Where(m => m.ViewFamily == ViewFamily.ThreeDimensional)
            .First().Id);
        //设置三维剖面框      
        view3D.SetSectionBox(box);
        ts.Commit();
        if (view3D.ViewType==ViewType.ThreeD)
        {
            uidoc.ActiveView = view3D;
        }   
        //List<View3D> view3D = new FilteredElementCollector(doc).OfClass(typeof(View3D)).Cast<View3D>().Where(m => m.Name == "分析模型").ToList();
        //TaskDialog.Show("1",view3D.Count.ToString());
        //uidoc.ActiveView = view3D[0];
      return Result.Succeeded;
    }

posted @ 2021-07-16 15:44  waiting233  阅读(108)  评论(0)    收藏  举报
#Snow{ position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 99999; background: rgba(125,137,95,0.1); pointer-events: none; }