示例#1
0
        public bool BakeGeometry(RhinoDoc doc, ObjectAttributes baking_attributes, out Guid obj_guid)
        {
            if (Value != null)
            {
                var att = baking_attributes.Duplicate();

                var str_id = this.Id > 0 ? Id.ToString() : "0"; // string.Empty;

                string fix_literal = this.FixLiteral
                                     .Replace("PP", "PXPYPZ")
                                     .Replace("MM", "MXMYMZ");

                if (fix_literal == "F")
                {
                    fix_literal = "PXPYPZMXMYMZ";
                }

                // set user strings
                att.SetUserString("SOF_OBJ_TYPE", "SLN");
                att.SetUserString("SOF_ID", str_id);

                if (this.GroupId > 0)
                {
                    att.SetUserString("SOF_GRP", this.GroupId.ToString());
                }
                if (this.SectionIdStart > 0)
                {
                    att.SetUserString("SOF_STYP", "B");
                    att.SetUserString("SOF_STYP2", "E");
                    att.SetUserString("SOF_SNO", SectionIdStart.ToString());

                    if (this.SectionIdEnd > 0)
                    {
                        att.SetUserString("SOF_SNOE", SectionIdEnd.ToString());
                    }
                    else
                    {
                        att.SetUserString("SOF_SNOE", "SOF_PROP_COMBO_NONE");
                    }
                }
                att.SetUserString("SOF_SDIV", "0.0");

                if (DirectionLocalZ.Length > 1.0E-6)
                {
                    att.SetUserString("SOF_DRX", DirectionLocalZ.X.ToString("F6"));
                    att.SetUserString("SOF_DRY", DirectionLocalZ.Y.ToString("F6"));
                    att.SetUserString("SOF_DRZ", DirectionLocalZ.Z.ToString("F6"));
                }

                if (string.IsNullOrEmpty(fix_literal) == false)
                {
                    att.SetUserString("SOF_FIX", fix_literal);
                }

                obj_guid = doc.Objects.AddCurve(Value, att);
            }
            else
            {
                obj_guid = new Guid();
            }
            return(true);
        }
示例#2
0
        public bool BakeGeometry(RhinoDoc doc, ObjectAttributes baking_attributes, out Guid obj_guid)
        {
            if (Value != null)
            {
                var att = baking_attributes.Duplicate();

                // set user strings
                att.SetUserString("SOF_OBJ_TYPE", "SLN");
                att.SetUserString("SOF_ID", Math.Max(0, Id).ToString());

                if (GroupId > 0)
                {
                    att.SetUserString("SOF_GRP", GroupId.ToString());
                }
                if (SectionIdStart > 0)
                {
                    att.SetUserString("SOF_STYP", ElementType);
                    att.SetUserString("SOF_STYP2", "E");
                    att.SetUserString("SOF_SNO", SectionIdStart.ToString());

                    if (SectionIdEnd > 0)
                    {
                        att.SetUserString("SOF_SNOE", SectionIdEnd.ToString());
                    }
                    else
                    {
                        att.SetUserString("SOF_SNOE", "SOF_PROP_COMBO_NONE");
                    }
                }

                if (ElementSize != 0.0)
                {
                    att.SetUserString("SOF_SDIV", ElementSize.ToString());
                }

                if (DirectionLocalZ.Length > 1.0E-6)
                {
                    var dir_z = DirectionLocalZ; dir_z.Unitize();

                    att.SetUserString("SOF_DRX", dir_z.X.ToString("F6"));
                    att.SetUserString("SOF_DRY", dir_z.Y.ToString("F6"));
                    att.SetUserString("SOF_DRZ", dir_z.Z.ToString("F6"));
                }

                if (string.IsNullOrWhiteSpace(fixLiteral) == false)
                {
                    string fix_literal = FixLiteral.Replace("PP", "PXPYPZ").Replace("MM", "MXMYMZ");

                    if (fix_literal == "F")
                    {
                        fix_literal = "PXPYPZMXMYMZ";
                    }

                    att.SetUserString("SOF_FIX", fix_literal);
                }

                if (string.IsNullOrWhiteSpace(UserText) == false)
                {
                    att.SetUserString("SOF_USERTXT", UserText);
                }

                obj_guid = doc.Objects.AddCurve(Value, att);
            }
            else
            {
                obj_guid = new Guid();
            }
            return(true);
        }