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

                var id_str  = this.Id > 0 ? Id.ToString() : "0";
                var grp_str = this.GroupId.ToString();
                var mno_str = this.MaterialId.ToString();
                var mrf_str = this.ReinforcementId.ToString();
                var t_str   = this.Thickness.ToString();

                att.SetUserString("SOF_OBJ_TYPE", "SAR");
                att.SetUserString("SOF_ID", id_str);
                att.SetUserString("SOF_T", Thickness.ToString());
                if (GroupId > 0)
                {
                    att.SetUserString("SOF_GRP", GroupId.ToString());
                }
                if (MaterialId > 0)
                {
                    att.SetUserString("SOF_MNO", MaterialId.ToString());
                }
                if (ReinforcementId > 0)
                {
                    att.SetUserString("SOF_MRF", ReinforcementId.ToString());
                }

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

                obj_guid = doc.Objects.AddBrep(Value, att);
            }
            else
            {
                obj_guid = new Guid();
            }
            return(true);
        }
Exemple #2
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", "SAR");
                att.SetUserString("SOF_ID", Math.Max(0, Id).ToString());

                if (GroupId > 0)
                {
                    att.SetUserString("SOF_GRP", GroupId.ToString());
                }
                if (MaterialId > 0)
                {
                    att.SetUserString("SOF_MNO", MaterialId.ToString());
                }
                if (ReinforcementId > 0)
                {
                    att.SetUserString("SOF_MRF", ReinforcementId.ToString());
                }

                att.SetUserString("SOF_T", Thickness.ToString());
                att.SetUserString("SOF_QREF", Alignment);

                if (MeshOptions == "AUTO")
                {
                    att.SetUserString("SOF_MCTL", "0");
                }
                else if (MeshOptions == "REGM")
                {
                    att.SetUserString("SOF_MCTL", "1");
                }
                else if (MeshOptions == "SNGQ")
                {
                    att.SetUserString("SOF_MCTL", "2");
                }
                else if (MeshOptions == "OFF")
                {
                    att.SetUserString("SOF_MCTL", "-1");
                }

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

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

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

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

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