예제 #1
0
            bool Bake(IGH_Param param, BakeOptions options, out List <NXOpen.Tag> ids)
            {
                var geometryToBake = param.VolatileData.AllData(true).Select(x => x.ScriptVariable()).
                                     Select(x =>
                {
                    switch (x)
                    {
                    case Rhino.Geometry.Point3d point: return(new Rhino.Geometry.Point(point));

                    case Rhino.Geometry.GeometryBase geometry: return(geometry);
                    }

                    return(null);
                });

                if (geometryToBake.Any())
                {
                    ids = new List <NXOpen.Tag>();
                    foreach (var geometry in geometryToBake)
                    {
                        var shape = geometry.ToShape().ToList();
                        ids.AddRange(shape.Select(obj => obj.Tag));
                    }

                    return(true);
                }

                ids = default;
                return(false);
            }
예제 #2
0
            bool IGH_ElementIdBakeAwareObject.Bake(BakeOptions options, out List <NXOpen.Tag> ids)
            {
                bool result = false;

                if (activeObject is IGH_Param param)
                {
                    result = Bake(param, options, out ids);
                }

                else if (activeObject is IGH_Component component)
                {
                    var list = new List <NXOpen.Tag>();
                    foreach (var outParam in component.Params.Output)
                    {
                        if (Bake(outParam, options, out var partial))
                        {
                            result = true;
                            list.AddRange(partial);
                        }
                    }

                    ids = result ? list : default;
                }
                else
                {
                    ids = default;
                }

                return(result);
            }
예제 #3
0
 bool IGH_ElementIdBakeAwareObject.CanBake(BakeOptions options) => activeObject.IsBakeCapable;
예제 #4
0
 public static IEnumerable <IGH_ElementIdBakeAwareObject> GetObjectsToBake(GH_Document definition, BakeOptions options) => ElementIdBakeAwareObject.OfType(definition.SelectedObjects().OfType <IGH_ActiveObject>().Where(x => !x.Locked)).Where(x => x.CanBake(options));