Exemplo n.º 1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        ///
        /// 以下代码还需要优化
        ///
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Hu_Layer ParentLayer = new Hu_Layer();
            Hu_Layer ChildLayer  = new Hu_Layer();
            Hu_Layer OutputLayer = new Hu_Layer();

            LayerTable LTable = Rhino.RhinoDoc.ActiveDoc.Layers;

            if (!DA.GetData(0, ref ParentLayer))
            {
                return;
            }
            if (!DA.GetData(1, ref ChildLayer))
            {
                return;
            }

            Layer _ParentLayer = ParentLayer.Value;
            Layer _ChildLayer  = ChildLayer.Value;

            if (!this.LayerExist(_ParentLayer))
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, string.Format("父图层: {0}不存在", _ParentLayer.Name));
                _ParentLayer = LTable.CurrentLayer;
            }
            _ChildLayer.ParentLayerId = _ParentLayer.Id;
            int LayerIndex = this.AddLayerToDocument(_ChildLayer);

            OutputLayer = new Hu_Layer(LTable.FindIndex(LayerIndex));
            DA.SetData(0, OutputLayer);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Hu_Layer Layer       = default(Hu_Layer);
            Color    ObjectColor = new Color();

            if (!DA.GetData(0, ref Layer))
            {
                return;
            }
            if (!this.ColorFromLayer)
            {
                if (!DA.GetData(1, ref ObjectColor))
                {
                    return;
                }
            }
            ObjectAttributes Attr = new ObjectAttributes();

            Attr.LayerIndex = Layer.Value.Index;
            if (this.ColorFromLayer)
            {
                Attr.ColorSource = ObjectColorSource.ColorFromLayer;
            }
            else
            {
                Attr.ColorSource = ObjectColorSource.ColorFromObject;
                Attr.ObjectColor = ObjectColor;
            }
            DA.SetData(0, Attr);
        }