示例#1
0
        public static IEnumerable <object> Pull(BHoMAdapter adapter, object request = null,
                                                PullType pullType = PullType.AdapterDefault, ActionConfig actionConfig = null,
                                                bool active       = false)
        {
            if (!active)
            {
                return(new List <object>());
            }

            IRequest actualRequest = null;

            if (!adapter.SetupPullRequest(request, out actualRequest))
            {
                BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(request)}` input.");
                return(null);
            }

            ActionConfig pullConfig = null;

            if (!adapter.SetupPullConfig(actionConfig, out pullConfig))
            {
                BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(actionConfig)}` input.");
                return(null);
            }

            return(adapter.Pull(actualRequest, pullType, pullConfig));
        }
示例#2
0
文件: Pull.cs 项目: BHoM/IFC_Toolkit
        /***************************************************/
        /**** Methods                                  *****/
        /***************************************************/

        public override IEnumerable <object> Pull(IRequest request, PullType pullType = PullType.AdapterDefault, ActionConfig actionConfig = null)
        {
            if (m_LoadedModel == null)
            {
                Engine.Reflection.Compute.RecordWarning("The .ifc file has not been loaded correctly.");
                return(new List <object>());
            }

            return(Read(request, actionConfig));
        }
示例#3
0
        public override IEnumerable <object> Pull(IRequest request, PullType pullType = PullType.AdapterDefault, ActionConfig actionConfig = null)
        {
            PullConfig pullConfig = actionConfig as PullConfig ?? new PullConfig();

            RevisionRequest rr = request as RevisionRequest;

            if (rr != null)
            {
                return(GetRevisions(rr).OfType <object>());
            }

            IssueRequest ir = request as IssueRequest;

            if (ir != null)
            {
                return(GetIssues(ir, pullConfig).OfType <object>());
            }

            AuditRequest ar = request as AuditRequest;

            if (ar != null)
            {
                if (ar.Audit == null)
                {
                    BH.Engine.Reflection.Compute.RecordWarning("Please specify the Audit whose Issues you want to pull from 3DRepo in the request.");
                    return(null);
                }

                ir = new IssueRequest()
                {
                    ModelId    = ar.ModelId,
                    RevisionId = ar.RevisionId,
                    TeamSpace  = ar.TeamSpace,
                    UserAPIKey = ar.UserAPIKey
                };

                Audit audit = ar.Audit.DeepClone();

                // The conversion between 3DRepo issues and BHoM Issues
                // will need to be passed any Pulled media file Name, if they were pulled with the Issues.
                Dictionary <oM.Adapters.TDRepo.Issue, List <string> > mediaFilenames_perIssue = new Dictionary <oM.Adapters.TDRepo.Issue, List <string> >();
                List <oM.Inspection.Issue> pulledIssues = GetIssues(ir, pullConfig, true, mediaFilenames_perIssue);

                // Return the Audit with the Pulled issues from 3DRepo.
                return(new List <object>()
                {
                    audit
                });
            }

            BH.Engine.Reflection.Compute.RecordWarning($"The specified request is not compatible with {this.GetType().Name}.");
            return(new List <object>());
        }
示例#4
0
 public void Init(Transform objectTransform, PullType type, float pullPower = 1)
 {
     ObjectTransform = objectTransform;
     Debug.Log(ObjectTransform);
     Type      = type;
     PullPower = Mathf.Max(pullPower, 1);
     if (ObjectTransform)
     {
         ObjectRigidbody = ObjectTransform.GetComponent <Rigidbody>();
     }
     HadRigidbody = ObjectRigidbody != null;
 }
示例#5
0
 public override IEnumerable <object> Pull(IRequest request, PullType pullType = PullType.AdapterDefault, ActionConfig actionConfig = null)
 {
     if (IsApplicationRunning() & TryToShowApp())
     {
         return(base.Pull(request, pullType, actionConfig));
     }
     else
     {
         BH.Engine.Base.Compute.RecordError("Make sure that either the RFEM Adapter component has opened an instance of the application or you have opened one yourself."
                                            + "\nCheck if you have a frozen instance of RFEM in the background. Look in Task Manager.");
         return(null);
     }
 }
示例#6
0
    public void SetPositionOffset(Vector3 positionOffset)
    {
        PullType pullType = this.pullType;

        if (pullType != PullButton.PullType.Position)
        {
            if (pullType == PullButton.PullType.Rotation)
            {
                this.targetTf.localEulerAngles = this.originalPosition + positionOffset;
            }
        }
        else
        {
            this.targetTf.localPosition = this.originalPosition + positionOffset;
        }
    }
示例#7
0
文件: Pull.cs 项目: BHoM/XML_Toolkit
        public override IEnumerable <object> Pull(IRequest request, PullType pullType = PullType.AdapterDefault, ActionConfig actionConfig = null)
        {
            if (!System.IO.File.Exists(_fileSettings.GetFullFileName()))
            {
                BH.Engine.Reflection.Compute.RecordError("File does not exist to pull from");
                return(new List <IBHoMObject>());
            }

            if (request != null)
            {
                FilterRequest filterRequest = request as FilterRequest;

                return(Read(filterRequest.Type, actionConfig: actionConfig));
            }
            else
            {
                return(Read(null, actionConfig));
            }
        }
示例#8
0
        /***************************************************/
        /**** Adapter overload method                   ****/
        /***************************************************/

        public override IEnumerable <object> Pull(IRequest request, PullType pullType = PullType.AdapterDefault, ActionConfig actionConfig = null)

        {
            IEnumerable <object> result = null;

            if (OpenDatabase())
            {
                try
                {
                    result = base.Pull(request, pullType, actionConfig);
                }
                catch
                {
                    Engine.Base.Compute.RecordError("Could not complete Pull.");
                }
            }

            CloseDatabase();

            return(result);
        }
示例#9
0
    private IEnumerator ActivateSequence()
    {
        if (this.isLocked)
        {
            yield break;
        }
        if (this.pullStartAudio)
        {
            this.pullStartAudio.Play2dEffect();
        }
        this.isLocked     = true;
        this.isActivating = true;
        yield return(null);

        this.isDragging = true;
        float fade = 1f;

        while (fade > 0f)
        {
            fade -= Time.deltaTime * 3f;
            PullType pullType = this.pullType;
            if (pullType != PullButton.PullType.Position)
            {
                if (pullType == PullButton.PullType.Rotation)
                {
                    this.targetTf.localEulerAngles = Vector3.Slerp(this.activatePosition, this.originalPosition, fade);
                }
            }
            else
            {
                this.targetTf.localPosition = Vector3.Lerp(this.activatePosition, this.originalPosition, fade);
            }
            yield return(null);
        }
        this.isActivating = false;
        this.Activate();
        this.isLocked = false;
        yield break;
    }
示例#10
0
        public override IEnumerable <object> Pull(IRequest request, PullType pullType = PullType.AdapterDefault, ActionConfig actionConfig = null)
        {
            // If the request exists, make sure it's a SpeckleRequest
            SpeckleRequest speckleRequest = request as SpeckleRequest;

            if (request != null && request.GetType() != typeof(FilterRequest) && speckleRequest == null)
            {
                Engine.Reflection.Compute.RecordError($"SpeckleAdapter supports only {typeof(SpeckleRequest).Name}.");
                return(new List <object>());
            }

            ResponseObject response     = null;
            string         speckleQuery = "";

            if (speckleRequest != null)
            {
                speckleQuery = Speckle.Convert.ToSpeckleQuery(speckleRequest);
            }

            // Download the objects.
            response = SpeckleClient.StreamGetObjectsAsync(SpeckleClient.Stream.StreamId, speckleQuery).Result;

            // Conversion configuration.
            bool storeSpeckleId = true;

            // Extract the configuations from the ActionConfig.
            // In this case, only SpecklePullConfig contains an option.
            SpecklePullConfig config = actionConfig as SpecklePullConfig;

            if (config != null)
            {
                storeSpeckleId = config.StoreSpeckleId;
            }

            List <object> converted = Speckle.Convert.FromSpeckle(response.Resources, storeSpeckleId);

            return(converted);
        }
示例#11
0
文件: Pull.cs 项目: BHoM/TAS_Toolkit
        public override IEnumerable <object> Pull(IRequest request, PullType pullType = PullType.AdapterDefault, ActionConfig actionConfig = null)
        {
            try
            {
                GetTbdDocumentReadOnly(); //Open the TBD Document for pulling data from

                IEnumerable <object> res = base.Pull(request, pullType, actionConfig);

                CloseTbdDocument(false);

                return(res);
            }
            catch (Exception e)
            {
                BH.Engine.Base.Compute.RecordError(e.ToString());
                CloseTbdDocument(false);
                return(null);
            }
            finally
            {
                CloseTbdDocument(false);
            }
        }
示例#12
0
 private void Update()
 {
     if (!this.isDragging && !this.isLocked)
     {
         PullType pullType = this.pullType;
         if (pullType != PullButton.PullType.Position)
         {
             if (pullType == PullButton.PullType.Rotation)
             {
                 float num = this.targetTf.localEulerAngles.z;
                 if (num > 0f)
                 {
                     num -= 360f;
                 }
                 this.targetTf.localEulerAngles = Vector3.Slerp(Vector3.forward * num, this.originalPosition, Time.deltaTime * 20f);
             }
         }
         else
         {
             this.targetTf.localPosition = Vector3.Lerp(this.targetTf.localPosition, this.originalPosition, Time.deltaTime * 20f);
         }
     }
 }
示例#13
0
        /***************************************************/
        /****      Revit side of Revit_Adapter Pull     ****/
        /***************************************************/

        public override IEnumerable <object> Pull(IRequest request, PullType pullType = PullType.AdapterDefault, ActionConfig actionConfig = null)
        {
            // Check the document
            UIDocument uiDocument = this.UIDocument;
            Document   document   = this.Document;

            if (document == null)
            {
                BH.Engine.Reflection.Compute.RecordError("BHoM objects could not be removed because Revit Document is null (possibly there is no open documents in Revit).");
                return(new List <object>());
            }

            // Set config
            RevitPullConfig pullConfig = actionConfig as RevitPullConfig;

            if (pullConfig == null)
            {
                BH.Engine.Reflection.Compute.RecordNote("Revit Pull Config has not been specified. Default Revit Pull Config is used.");
                pullConfig = new RevitPullConfig();
            }

            // Read the objects based on the request
            return(Read(request, pullConfig));
        }
示例#14
0
文件: Pull.cs 项目: BHoM/SQL_Toolkit
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public override IEnumerable <object> Pull(IRequest query, PullType pullType = PullType.AdapterDefault, ActionConfig actionConfig = null)
        {
            List <object> result = new List <object>();

            if (query == null)
            {
                return(result);
            }

            using (SqlConnection connection = new SqlConnection(m_ConnectionString))
            {
                connection.Open();

                using (SqlCommand command = connection.CreateCommand())
                {
                    command.CommandText = query.IToSqlCommand();
                    Type objectType = GetDataType(query);

                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        Dictionary <string, object> dic = new Dictionary <string, object>();
                        for (int i = 0; i < reader.FieldCount; i++)
                        {
                            dic.Add(reader.GetName(i), reader.GetValue(i));
                        }
                        result.Add(Engine.SQL.Convert.FromDictionary(dic, objectType));
                    }
                    reader.Close();
                }

                connection.Close();
            }

            return(result);
        }
示例#15
0
        public static bool Move(BHoMAdapter source, BHoMAdapter target, object request = null,
                                PullType pullType = PullType.AdapterDefault, ActionConfig pullConfig = null,
                                PushType pushType = PushType.AdapterDefault, ActionConfig pushConfig = null, bool active = false)
        {
            if (!active)
            {
                return(false);
            }

            IRequest actualRequest = null;

            if (!source.SetupPullRequest(request, out actualRequest))
            {
                BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(request)}` input.");
                return(false);
            }

            ActionConfig pullCfg = null;

            if (!source.SetupPullConfig(pullConfig, out pullCfg))
            {
                BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(pullConfig)}` input.");
                return(false);
            }

            ActionConfig pushCfg = null;

            if (!source.SetupPushConfig(pushConfig, out pushCfg))
            {
                BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(pushConfig)}` input.");
                return(false);
            }


            return(source.Move(target, actualRequest, pullType, pullCfg, pushType, pushCfg));
        }
示例#16
0
 public override IEnumerable <object> Pull(IRequest request, PullType pullType = PullType.AdapterDefault, ActionConfig actionConfig = null)
 {
     return(Read(request as dynamic, actionConfig as PullConfig ?? new PullConfig()));
 }
示例#17
0
        /***************************************************/
        /****      BHoM side of Revit_Adapter Pull      ****/
        /***************************************************/

        public override IEnumerable <object> Pull(IRequest request, PullType pullType = PullType.AdapterDefault, ActionConfig actionConfig = null)
        {
            //Check if request is not null or empty
            if (request == null)
            {
                BH.Engine.Reflection.Compute.RecordError("BHoM objects could not be read because provided IRequest is null or empty.");
                return(new List <object>());
            }
            else if (request is FilterRequest)
            {
                FilterRequest filterRequest = (FilterRequest)request;
                if (filterRequest.Type == null && String.IsNullOrWhiteSpace(filterRequest.Tag) && (filterRequest.Equalities == null || filterRequest.Equalities.Count == 0))
                {
                    BH.Engine.Reflection.Compute.RecordError("BHoM objects could not be read because provided IRequest is null or empty.");
                    return(new List <object>());
                }
            }

            //Initialize Revit config
            RevitPullConfig pullConfig = actionConfig as RevitPullConfig;

            //If internal adapter is loaded call it directly
            if (InternalAdapter != null)
            {
                InternalAdapter.RevitSettings = RevitSettings;
                return(InternalAdapter.Pull(request, pullType, pullConfig));
            }

            if (!this.IsValid())
            {
                BH.Engine.Reflection.Compute.RecordError("Revit Adapter is not valid. Please check if it has been set up correctly and activated.");
                return(new List <object>());
            }

            //Reset the wait event
            m_WaitEvent.Reset();

            if (!CheckConnection())
            {
                return(new List <object>());
            }

            //Send data through the socket link
            m_LinkIn.SendData(new List <object>()
            {
                PackageType.Pull, request, pullType, pullConfig, RevitSettings
            });

            //Wait until the return message has been recieved
            if (!m_WaitEvent.WaitOne(TimeSpan.FromMinutes(m_WaitTime)))
            {
                Engine.Reflection.Compute.RecordError("The connection with Revit timed out. If working on a big model, try to increase the max wait time");
            }

            //Grab the return objects from the latest package
            List <object> returnObjs = new List <object>(m_ReturnPackage);

            //Clear the return list
            m_ReturnPackage.Clear();

            //Raise returned events
            RaiseEvents();

            //Check if the return package contains error message
            if (returnObjs.Count == 1 && returnObjs[0] is string)
            {
                Engine.Reflection.Compute.RecordError(returnObjs[0] as string);
                return(new List <object>());
            }

            //Return the package
            return(returnObjs);
        }
示例#18
0
 protected override void OnInput(InputEvent input)
 {
     base.OnInput(input);
     if (this.isLocked)
     {
         return;
     }
     if (input.type == InputEvent.EventType.Press)
     {
         this.touchStartTime = Time.realtimeSinceStartup;
         this.lastPosition   = this.hudCamera.ScreenToWorldPoint(input.position);
         this.isDragging     = true;
     }
     else if (input.type == InputEvent.EventType.Release)
     {
         if (Time.realtimeSinceStartup - this.touchStartTime < this.tapTresholdTime)
         {
             base.StartCoroutine(this.ActivateSequence());
         }
         this.isDragging = false;
     }
     else if (input.type == InputEvent.EventType.Drag && this.isDragging)
     {
         Vector3 vector = this.hudCamera.ScreenToWorldPoint(input.position);
         float   num    = (vector.y - this.lastPosition.y) * this.dragScale;
         this.lastPosition = vector;
         PullType pullType = this.pullType;
         if (pullType != PullButton.PullType.Position)
         {
             if (pullType == PullButton.PullType.Rotation)
             {
                 float num2 = this.targetTf.localEulerAngles.z;
                 if (num2 > 0f)
                 {
                     num2 -= 360f;
                 }
                 float num3 = num2 + num;
                 if (num3 < this.activatePosition.z)
                 {
                     this.targetTf.localEulerAngles = this.activatePosition;
                     this.Activate();
                 }
                 else if (num3 > this.originalPosition.z)
                 {
                     this.targetTf.localEulerAngles = this.originalPosition;
                 }
                 else
                 {
                     this.targetTf.localEulerAngles = Vector3.forward * num3;
                 }
             }
         }
         else
         {
             this.targetTf.Translate(Vector3.up * num);
             if (this.targetTf.localPosition.y < this.activatePosition.y)
             {
                 this.targetTf.localPosition = this.activatePosition;
                 this.Activate();
             }
             else if (this.targetTf.localPosition.y > this.originalPosition.y)
             {
                 this.targetTf.localPosition = this.originalPosition;
             }
         }
     }
     else if (input.type == InputEvent.EventType.MouseLeave && this.isDragging)
     {
         this.isDragging = false;
     }
 }
 public new ClinicReportBuilder Pull(PullType type) => base.Pull(type);
 internal ClinicReportBuilder(PullType pullType) => PullType = pullType;