示例#1
0
        private void FillDyn(Property prop, object value)
        {
            var blRef   = IdBlRef.GetObjectT <BlockReference>(OpenMode.ForWrite);
            var dynProp = blRef.DynamicBlockReferencePropertyCollection.Cast <DynamicBlockReferenceProperty>()
                          .FirstOrDefault(p => p.PropertyName.Equals(prop.Name, StringComparison.OrdinalIgnoreCase));

            SetValue(dynProp, value);
        }
示例#2
0
        protected void FillProp([CanBeNull] Property prop, object value)
        {
            if (prop == null)
            {
                return;
            }
            var blRef = IdBlRef.GetObjectT <BlockReference>(OpenMode.ForWrite);

            if (prop.Type == PropertyType.Attribute && !prop.IdAtrRef.IsNull)
            {
                var atr  = prop.IdAtrRef.GetObject <AttributeReference>(OpenMode.ForWrite);
                var text = value?.ToString() ?? string.Empty;
                if (atr.IsMTextAttribute)
                {
                    var mt = atr.MTextAttribute;
                    mt.Contents        = text;
                    atr.MTextAttribute = mt;
                    atr.UpdateMTextAttribute();
                }
                else
                {
                    atr.TextString = text;
                }

                if (!atr.IsDefaultAlignment)
                {
                    atr.AdjustAlignment(Db);
                }
            }
            else if (prop.Type == PropertyType.Dynamic)
            {
                if (value == null)
                {
                    return;
                }
                var dynProp = blRef.DynamicBlockReferencePropertyCollection.Cast <DynamicBlockReferenceProperty>()
                              .FirstOrDefault(p => p.PropertyName.Equals(prop.Name, StringComparison.OrdinalIgnoreCase));
                if (dynProp != null)
                {
                    try
                    {
                        dynProp.Value = value;
                    }
                    catch
                    {
                        Inspector.AddError(
                            $"Не удалосось установить динамический параметр {prop.Name} " +
                            $"со значением {prop.Value} в блок {BlName}",
                            IdBlRef,
                            System.Drawing.SystemIcons.Error);
                    }
                }
            }
        }