コード例 #1
0
        /// <summary>
        /// The implementation of IExternalApplication.OnStartup()
        /// </summary>
        /// <param name="application">The Revit application.</param>
        /// <returns>Result.Succeeded</returns>
        public Result OnStartup(UIControlledApplication application)
        {
            try
            {
                // Register point cloud engines for the sample.

                // Predefined engine (non-randomized)
                IPointCloudEngine engine = new BasicPointCloudEngine(PointCloudEngineType.Predefined);
                PointCloudEngineRegistry.RegisterPointCloudEngine("apipc", engine, false);

                // Predefined engine with randomized points at the cell borders
                engine = new BasicPointCloudEngine(PointCloudEngineType.RandomizedPoints);
                PointCloudEngineRegistry.RegisterPointCloudEngine("apipcr", engine, false);

                // XML-based point cloud definition
                engine = new BasicPointCloudEngine(PointCloudEngineType.FileBased);
                PointCloudEngineRegistry.RegisterPointCloudEngine("xml", engine, true);

                // Create user interface for accessing predefined point clouds
                RibbonPanel panel = application.CreateRibbonPanel("Point cloud testing");

                System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();

                panel.AddItem(new PushButtonData("AddPredefinedInstance",
                                                 "Add predefined instance",
                                                 assembly.Location,
                                                 "Revit.SDK.Samples.CS.PointCloudEngine.AddPredefinedInstanceCommand"));
                panel.AddSeparator();

                panel.AddItem(new PushButtonData("AddRandomizedInstance",
                                                 "Add randomized instance",
                                                 assembly.Location,
                                                 "Revit.SDK.Samples.CS.PointCloudEngine.AddRandomizedInstanceCommand"));
                panel.AddSeparator();

                panel.AddItem(new PushButtonData("AddTransformedInstance",
                                                 "Add randomized instance\nat transform",
                                                 assembly.Location,
                                                 "Revit.SDK.Samples.CS.PointCloudEngine.AddTransformedInstanceCommand"));
                panel.AddSeparator();

                panel.AddItem(new PushButtonData("SerializePointCloud",
                                                 "Serialize point cloud (utility)",
                                                 assembly.Location,
                                                 "Revit.SDK.Samples.CS.PointCloudEngine.SerializePredefinedPointCloud"));
            }
            catch (Exception e)
            {
                TaskDialog.Show("Exception from OnStartup", e.ToString());
            }

            return(Result.Succeeded);
        }
コード例 #2
0
        /// <summary>
        /// Cleans up FindSurface, custom point cloud engines, DirectShapeManager instances before Revit is terminated.
        /// </summary>
        public static void OnPluginShutdown()
        {
            // clean up FindSurface
            FindSurface.CleanUp();

            // clean up XYZPointCloudEngine
            List <string> engine_names = PointCloudEngineRegistry.GetSupportedEngines() as List <string>;

            foreach (string engine_name in engine_names)
            {
                if (engine_name == S_OUTLIER_PC_ENGINE_IDENTIFIER || engine_name == S_INLIER_PC_ENGINE_IDENTIFIER)
                {
                    PointCloudEngineRegistry.UnregisterPointCloudEngine(engine_name);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Initializes FindSurface, custom point cloud engines, DirectShapeManager instances when Revit loaded this plugin.
        /// </summary>
        public static bool OnPluginStartUp()
        {
            FS_CONTEXT_CREATION_ERROR error = FS_CONTEXT_CREATION_ERROR.FS_NO_ERROR;

            // initialize FindSurface
            s_find_surface = FindSurface.GetInstance(ref error);

            switch (error)
            {
            case FS_CONTEXT_CREATION_ERROR.FS_OUT_OF_MEMORY:
                TaskDialog.Show("FindSurface", "Context creation failed: FS_OUT_OF_MEMORY");
                return(false);

            case FS_CONTEXT_CREATION_ERROR.FS_LICENSE_EXPIRED:
                TaskDialog.Show("FindSurface", "Context creation failed: FS_LICENSE_EXPIRED");
                return(false);

            case FS_CONTEXT_CREATION_ERROR.FS_LICENSE_UNKNOWN:
                TaskDialog.Show("FindSurface", "Context creation failed: FS_LICENSE_UNKNOWN");
                return(false);
            }

            // initialize parameters temporarily
            FindSurface.Accuracy     = 0.003f;           // Set Sensor Measurement Accuracy
            FindSurface.MeanDistance = 0.01f;            // Set Mean Distance of Neighboring Points
            FindSurface.TouchRadius  = 0.025f;           // Touch Size of the Seed Region

            // initialize Custom Point Cloud Engines
            s_outlier_point_cloud_engine = new UniformGridPointCloudEngine(S_OUTLIER_PC_ENGINE_IDENTIFIER);
            PointCloudEngineRegistry.RegisterPointCloudEngine(S_OUTLIER_PC_ENGINE_IDENTIFIER, s_outlier_point_cloud_engine, false);
            s_inlier_point_cloud_engine = new OctreePointCloudEngine(S_INLIER_PC_ENGINE_IDENTIFIER);
            PointCloudEngineRegistry.RegisterPointCloudEngine(S_INLIER_PC_ENGINE_IDENTIFIER, s_inlier_point_cloud_engine, false);

            // initialize DirectShape Engines
            s_direct_shape_manager = new DirectShapeEngine();

            return(true);
        }