コード例 #1
0
        public ObjectId DrawToLayout(string layoutName)
        {
            var id     = DbHelper.GetLayoutId(layoutName);
            var layout = id.QOpenForRead <Layout>();

            LayoutManager.Current.CurrentLayout = layoutName;
            var vps = layout.GetViewports();

            if (vps.Count > 1)
            {
                var vpId = vps[1];
                if (Template.Components.Any(x => x.ID == "vp1"))
                {
                    var    vp1        = Template.Components.First(x => x.ID == "vp1");
                    var    lookAt     = Point3d.Origin;
                    double viewHeight = 1000;
                    if (Substitutions.ContainsKey("vp1"))
                    {
                        var vp1InstParams = Substitutions["vp1"];
                        lookAt     = new Point3d((double)vp1InstParams["TargetX"], (double)vp1InstParams["TargetY"], 0);
                        viewHeight = (double)vp1InstParams["ViewHeight"];
                    }
                    Layouts.SetViewport(vpId, vp1.Width, vp1.Height, vp1.Position, lookAt, viewHeight);
                    Template.Components.Remove(vp1);
                }
            }

            foreach (var component in Template.Components)
            {
                if (Substitutions.ContainsKey(component.ID))
                {
                    GenerateComponent(component, Substitutions[component.ID]);
                }
                else
                {
                    GenerateComponent(component, null);
                }
            }

            return(id);
        }