Ejemplo n.º 1
0
        public static List <GeometryBase> AllVisableGeometryInGHDocmument()
        {
            var canvas = Instances.ActiveCanvas;

            if (canvas == null)
            {
                throw new Exception("No Document Server exist!");
            }

            if (!canvas.IsDocument)
            {
                throw new Exception("No Document Server exist!");
            }

            GH_Document doc = canvas.Document;

            if (doc == null)
            {
                throw new Exception("Tasker 未找到GH_Document");
            }

            var list = new List <GeometryBase>();

            foreach (IGH_DocumentObject obj in doc.Objects)
            {
                if (!(obj is IGH_PreviewObject prev) ||
                    prev.Hidden ||
                    !(obj is IGH_Component comp))
                {
                    continue;
                }

                comp.Params.Output.ForEach((IGH_Param output) =>
                {
                    IGH_Structure data = output.VolatileData;
                    if (!data.IsEmpty)
                    {
                        foreach (var dat in data.AllData(true))
                        {
                            GeometryBase geometry = GH_Convert.ToGeometryBase(dat);
                            if (geometry == null)
                            {
                                continue;
                            }
                            list.Add(geometry);
                        }
                    }
                });
            }

            return(list);
        }
Ejemplo n.º 2
0
        protected override void BeforeSolveInstance()
        {
            ClearOutput();
            curve    = false;
            line     = false;
            polyline = false;
            arc      = false;
            circle   = false;
            ellipse  = false;
            IGH_Structure dd        = Params.Input[0].VolatileData;
            double        tolerance = 0;

            foreach (IGH_Goo number in Params.Input[1].VolatileData.AllData(true))
            {
                GH_Number num = (GH_Number)number;
                tolerance = num.Value;
            }
            foreach (IGH_Goo geo in dd.AllData(true))
            {
                GH_Curve crv = (GH_Curve)geo;
                if (crv.Value.IsLinear(tolerance))
                {
                    line = true;
                }
                else if (crv.Value.IsPolyline())
                {
                    polyline = true;
                }
                else if (crv.Value.IsCircle(tolerance))
                {
                    circle = true;
                }
                else if (crv.Value.IsArc(tolerance))
                {
                    arc = true;
                }
                else if (crv.Value.IsEllipse(tolerance))
                {
                    ellipse = true;
                }
                else
                {
                    curve = true;
                }
            }
            AddOutput();
        }
Ejemplo n.º 3
0
        protected override void BeforeSolveInstance()
        {
            ClearOutput();
            point   = false;
            curve   = false;
            surface = false;
            brep    = false;
            mesh    = false;
            IGH_Structure dd = Params.Input[0].VolatileData;

            foreach (IGH_Goo geo in dd.AllData(true))
            {
                if (geo is GH_Point)
                {
                    point = true;
                }
                else if (geo is GH_Curve)////curve
                {
                    curve = true;
                }
                else if (geo is GH_Brep)
                {
                    GH_Brep bp = (GH_Brep)geo;
                    if (bp.Value.IsSurface)///surface
                    {
                        surface = true;
                    }
                    else//////brep
                    {
                        brep = true;
                    }
                }
                else if (geo is GH_Mesh)
                {
                    mesh = true;
                    GH_Mesh me = (GH_Mesh)geo;
                }
            }
            AddOutput();
        }
Ejemplo n.º 4
0
 internal static IEnumerable <Types.IGH_ElementId> ToElementIds(IGH_Structure data) =>
 data.AllData(true).
 OfType <Types.IGH_ElementId>().
 Where(x => x.IsValid);
Ejemplo n.º 5
0
 internal static IEnumerable <ElementId> ToElementIds(IGH_Structure data) =>
 data.AllData(true).
 OfType <Types.IGH_ElementId>().
 Where(x => x is object).
 Select(x => x.Id);