Ejemplo n.º 1
0
        public Entity GetUpdatedRevitEntity()
        {
            // Return the entity if up-to-date
            if (IsUpToDate)
            {
                return(RvtEntity);
            }

            // Create new entity if not yet exists
            if (RvtEntity == null)
            {
                RvtEntity = new Entity(RvtSchema);
            }

            // Fill the entity
            RvtEntity.Set <string>(NameField, Name);
            RvtEntity.Set <string>(IconField, Icon);
            RvtEntity.Set <string>(RegisterUrlField, RegisterUrl);
            RvtEntity.Set <string>(AuthorizeUrlField, AuthorizeUrl);
            RvtEntity.Set <string>(TokenUrlField, TokenUrl);
            RvtEntity.Set <string>(ClientIdField, ClientId);
            RvtEntity.Set <string>(ClientSecretField, ClientSecret);

            // Set the entity to be up-to-date and return it
            IsUpToDate = true;
            return(RvtEntity);
        }
Ejemplo n.º 2
0
        public Entity GetUpdatedRevitEntity()
        {
            // Return the entity if up-to-date
            if (IsUpToDate)
            {
                return(RvtEntity);
            }

            // Create new entity if not yet exists
            if (RvtEntity == null)
            {
                RvtEntity = new Entity(RvtSchema);
            }

            // Fill the entity
            RvtEntity.Set <string>(NameField, Name);
            RvtEntity.Set <string>(DescriptionField, Description);
            RvtEntity.Set <IList <string> >(InputsField, Inputs);
            RvtEntity.Set <IList <string> >(OutputsField, Outputs);
            RvtEntity.Set <string>(ProviderField, Provider.Name);
            RvtEntity.Set <string>(IfcConfigurationField, IfcExportConfiguration);

            // Fill the optionally encoded fields
            if (IsEncoded) // service is encoded in memory
            {
                RvtEntity.Set <string>(UrlField, Url);
                RvtEntity.Set <string>(AuthorizationField, Encrypt(AuthorizationCode, Password)); //only encrypted when Password is not null
            }
            else // service is not encoded in memory
            {
                RvtEntity.Set <string>(UrlField, Encrypt(Url, Password));                         //only encrypted when Password is not null
                RvtEntity.Set <string>(AuthorizationField, Encrypt(AuthorizationCode, Password)); //only encrypted when Password is not null
            }

            // Fill the triggers in the entity
            List <string> triggers = new List <string>();

            foreach (RevitEvntTrigger trigger in Triggers)
            {
                triggers.Add(trigger.ToString());
            }
            RvtEntity.Set <IList <String> >(TriggersField, triggers);

            // Fill the result in the entity
            if (Result != null)
            {
                RvtEntity.Set <string>(ResultTypeField, Result.isBcf ? "bcf" : "txt");
                RvtEntity.Set <string>(ResultDataField, Result.data);
                RvtEntity.Set <string>(LastRunField, Result.lastRun.ToString());
            }

            // Set the entity to be up-to-date and return it
            IsUpToDate = true;
            return(RvtEntity);
        }
Ejemplo n.º 3
0
      public Entity GetUpdatedRevitEntity()
      {
         // Return the entity if up-to-date
         if (IsUpToDate)
            return RvtEntity;

         // Create new entity if not yet exists
         if (RvtEntity == null)
            RvtEntity = new Entity(RvtSchema);

         // Fill the entity
         RvtEntity.Set<string>(UsernameField, Name);
         RvtEntity.Set<string>(CodeField, AuthorizationCode);

         // Set the entity to be up-to-daAuthorizationCodeurreturn RvtEntity;
      }
Ejemplo n.º 4
0
        public BimbotDocument(Document document)
        {
            RvtDocument = document;
            Name        = RvtDocument.PathName.Substring(RvtDocument.PathName.LastIndexOf('\\') + 1);

            RegisteredProviders = new Dictionary <string, Provider>();
            AssignedServices    = new ObservableCollection <Service>();
            ResultItems         = new ObservableCollection <ResultItem>();

            // Find or add Schema
            FindOrCreateSchema(RvtDocument);

            // Read the Bimbot data in the project
            RvtEntity = RvtDocument.ProjectInformation.GetEntity(RvtSchema);
            if (RvtEntity.IsValid())
            {
                IDictionary <string, Entity> providers = RvtEntity.Get <IDictionary <string, Entity> >(ProvidersField);
                foreach (KeyValuePair <string, Entity> pair in providers)
                {
                    Provider readProvider = new Provider(pair.Value);
                    RegisteredProviders.Add(pair.Key, readProvider);
                }
                IList <Entity> services = RvtEntity.Get <IList <Entity> >(ServicesField);
                foreach (Entity serviceEnt in services)
                {
                    Service readService = new Service(serviceEnt, RegisteredProviders);
                    readService.InitResults(ResultItems);
                    AssignedServices.Add(readService);
                }
            }
            else
            {
                RvtEntity = null;
            }

            IsUpToDate = true;
        }
Ejemplo n.º 5
0
        public void WriteToRevit()
        {
            try
            {
                // Add the provider and service to Revit document
                Transaction transaction = new Transaction(RvtDocument, "Write BimbotDocument to revit");
                transaction.Start();

                // Create the bimbot entity in the document if not exists
                if (RvtEntity == null)
                {
                    RvtEntity = new Entity(RvtSchema);
                }

                Dictionary <string, Entity> ProvidersMap = new Dictionary <string, Entity>();
                foreach (KeyValuePair <string, Provider> pair in RegisteredProviders)
                {
                    ProvidersMap.Add(pair.Key, pair.Value.GetUpdatedRevitEntity());
                }
                RvtEntity.Set <IDictionary <string, Entity> >(ProvidersField, ProvidersMap); // set the value for this entity

                List <Entity> ServicesEntity = new List <Entity>();
                foreach (Service service in AssignedServices)
                {
                    ServicesEntity.Add(service.GetUpdatedRevitEntity());
                }
                RvtEntity.Set <IList <Entity> >(ServicesField, ServicesEntity);

                RvtDocument.ProjectInformation.SetEntity(RvtEntity); // store the entity in the element
                transaction.Commit();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }