Exemple #1
0
        /// <summary>
        /// Adds a point cloud instance programmatically.
        /// </summary>
        /// <param name="doc">The document.</param>
        /// <param name="engineType">The engine identifier string.</param>
        /// <param name="identifier">The identifier for the particular point cloud.</param>
        /// <param name="trf">The transform to apply to the new point cloud instance.</param>
        public void AddInstance(Document doc, String engineType, String identifier, Transform trf)
        {
            Transaction t = new Transaction(doc, "Create PC instance");

            t.Start();
            PointCloudType type = PointCloudType.Create(doc, engineType, identifier);

            PointCloudInstance.Create(doc, type.Id, trf);
            t.Commit();
        }
Exemple #2
0
        /// <summary>
        /// Creates a point cloud.
        /// </summary>
        /// <param name="document">The active document</param>
        /// <param name="identifier">The name of the point cloud</param>
        /// <param name="points">The points</param>
        /// <param name="transform">The transform</param>
        protected void CreatePointCloud(Document document, string identifier, CloudPoint[] points, Transform transform)
        {
            t_pending_points = points;

            using (Transaction t = new Transaction(document, identifier))
            {
                t.Start();
                PointCloudType     type     = PointCloudType.Create(document, m_identifier, identifier);
                PointCloudInstance instance = PointCloudInstance.Create(document, type.Id, transform);
                PointCloudBase     new_pc   = m_pointclouds.Last();
                new_pc.ElementId = instance.Id;
                new_pc.Document  = document;
                new_pc.Engine    = this;
                t.Commit();
            }
        }
        /// <summary>
        /// Returns the PointCloudInstance instance of the point cloud.
        /// </summary>
        /// <returns>The instance of PointCloudInstance</returns>
        private PointCloudInstance GetInstance()
        {
            FilteredElementCollector  coll      = new FilteredElementCollector(Document);
            List <PointCloudInstance> instances = coll.OfClass(typeof(PointCloudInstance))
                                                  .ToElements().Cast <PointCloudInstance>().ToList();

            foreach (PointCloudInstance instance in instances)
            {
                PointCloudType type = Document.GetElement(instance.GetTypeId()) as PointCloudType;
                if (type.EngineIdentifier == m_engine.Identifier &&
                    type.Name == m_identifier)
                {
                    return(instance);
                }
            }

            return(null);
        }