Пример #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);
        }
        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);
        }
Пример #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;
      }
Пример #4
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);
            }
        }