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

                att.SetUserString("SOF_OBJ_TYPE", "SPT");
                att.SetUserString("SOF_ID", Math.Max(0, Id).ToString());

                if (DirectionLocalX.Length > 1.0E-6)
                {
                    var dir_x = DirectionLocalX; dir_x.Unitize();

                    att.SetUserString("SOF_SX", dir_x.X.ToString("F6"));
                    att.SetUserString("SOF_SY", dir_x.Y.ToString("F6"));
                    att.SetUserString("SOF_SZ", dir_x.Z.ToString("F6"));
                }
                if (DirectionLocalZ.Length > 1.0E-6)
                {
                    var dir_z = DirectionLocalZ; dir_z.Unitize();

                    att.SetUserString("SOF_NX", DirectionLocalZ.X.ToString("F6"));
                    att.SetUserString("SOF_NY", DirectionLocalZ.Y.ToString("F6"));
                    att.SetUserString("SOF_NZ", DirectionLocalZ.Z.ToString("F6"));
                }

                if (string.IsNullOrEmpty(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.AddPoint(Value.Location, att);
            }
            else
            {
                obj_guid = new Guid();
            }
            return(true);
        }
Exemplo n.º 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);
        }