示例#1
0
        private static Entity GetSpeckleEntity(Document doc)
        {
            FilteredElementCollector collector = new FilteredElementCollector(doc);

            var dataStorages = collector.OfClass(typeof(DataStorage));

            foreach (DataStorage dataStorage in dataStorages)
            {
                Entity settingEntity = dataStorage.GetEntity(StreamStateListSchema.GetSchema());
                if (!settingEntity.IsValid())
                {
                    continue;
                }

                return(settingEntity);
            }
            return(null);
        }
示例#2
0
        /// <summary>
        /// Writes the stream states to the current document.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="wrap"></param>
        public static void WriteStreamStateList(Document doc, List <StreamState> streamStates)
        {
            var ds = GetSettingsDataStorage(doc);

            if (ds == null)
            {
                ds = DataStorage.Create(doc);
            }

            var streamStatesEntity = new Entity(StreamStateListSchema.GetSchema());

            streamStatesEntity.Set("StreamStates", JsonConvert.SerializeObject(streamStates) as string);

            var idEntity = new Entity(DSUniqueSchemaStreamStateStorage.GetSchema());

            idEntity.Set("Id", ID);

            ds.SetEntity(idEntity);
            ds.SetEntity(streamStatesEntity);
        }