Exemple #1
0
 /// <summary>
 /// Check if a Dag input is a DAGFileOutput, DAGFolderOutput, or DAGPathOutput
 /// </summary>
 /// <param name="inputDag"></param>
 /// <returns></returns>
 public static bool IsPathType(this Interface.Io.Outputs.IDag inputDag)
 {
     if (inputDag is DAGFileOutput)
     {
         return(true);
     }
     if (inputDag is DAGFolderOutput)
     {
         return(true);
     }
     if (inputDag is DAGPathOutput)
     {
         return(true);
     }
     return(false);
 }
Exemple #2
0
        /// <summary>
        /// Get asset path of ProjectFolder type to be downloaded
        /// </summary>
        /// <param name="outputDag"></param>
        /// <returns>return empty if it is not a path type input</returns>
        public static string GetOutputPath(this Interface.Io.Outputs.IDag outputDag)
        {
            var value = string.Empty;

            if (outputDag.IsPathType())
            {
                var pathSource = outputDag.GetPathSource();
                if (!string.IsNullOrEmpty(pathSource))
                {
                    value = pathSource;
                }
                else
                {
                    throw new System.ArgumentException($"The source of {outputDag.Name} is not supported FileRenference or FolderReference type");
                }
            }
            return(value);
        }
Exemple #3
0
        /// <summary>
        /// Get the source of a path type Step input. Returns null if inputStep is not path type
        /// </summary>
        /// <param name="outputDag"></param>
        /// <returns></returns>
        public static string GetPathSource(this Interface.Io.Outputs.IDag outputDag)
        {
            if (outputDag.IsPathType())
            {
                if (outputDag is DAGFileOutput f)
                {
                    return(GetPath(f.From.Obj));
                }
                else if (outputDag is DAGFolderOutput folder)
                {
                    return(GetPath(folder.From.Obj));
                }
                else if (outputDag is DAGPathOutput p)
                {
                    return(GetPath(p.From.Obj));
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }

            string GetPath(object obj)
            {
                if (obj is FileReference f)
                {
                    return(f.Path);
                }
                else if (obj is FolderReference folder)
                {
                    return(folder?.Path);
                }
                else
                {
                    return(null);
                }
            }
        }
        public RunOutputAsset(Interface.Io.Outputs.IDag dagOutput, string platform, string runSource = default)
        {
            if (dagOutput == null)
            {
                return;
            }

            this.Name = dagOutput.Name;

            //var platform = "grasshopper";
            var dagOutputAlias = dagOutput.GetAlias(platform);

            this.IsLinkedAsset = dagOutputAlias is DAGLinkedOutputAlias;
            // override the name and description
            this.AliasName   = dagOutputAlias?.Name ?? this.Name;
            this.Handlers    = dagOutputAlias?.Handler;
            this.Description = dagOutputAlias?.Description ?? dagOutput.Description;

            // cloud source: CLOUD:mingbo/demo/1D725BD1-44E1-4C3C-85D6-4D98F558DE7C
            // local source: LOCAL:C\Users\mingo\simulaiton\1D725BD1
            this.RunSource    = runSource;
            this.RelativePath = dagOutput.GetOutputPath();
        }
Exemple #5
0
 /// <summary>
 /// Get an alias for a platform (rhino, grasshopper, revit, etc)
 /// </summary>
 /// <param name="outputDag"></param>
 /// <param name="platform">platform name (rhino, grasshopper, revit, etc)</param>
 /// <returns></returns>
 public static Interface.Io.Outputs.IAlias GetAlias(this Interface.Io.Outputs.IDag outputDag, string platform)
 {
     return(outputDag.Alias?.OfType <Interface.Io.Outputs.IAlias>()?.FirstOrDefault(_ => _.Platform.Contains(platform)));
 }