TheSwamp

Code Red => .NET => Topic started by: latour_g on August 30, 2017, 04:24:27 PM

Title: Dynamic block properties
Post by: latour_g on August 30, 2017, 04:24:27 PM
Hi,
I would like to know if it's possible to modify the dimension value in a dynamic block ? I get error "eInvalidIndut" (I make sure to try with a valid measure). 
Thank you

Code - C#: [Select]
  1.                 if (blkTab.IsDynamicBlock)
  2.                 {
  3.                     DynamicBlockReferencePropertyCollection dynBlkRefProps = blkTab.DynamicBlockReferencePropertyCollection;
  4.                     foreach (DynamicBlockReferenceProperty dynBlkRefProp in dynBlkRefProps)
  5.                     {
  6.                         if (dynBlkRefProp.PropertyName.ToUpper().StartsWith("DISTANCE1"))
  7.                         {
  8.                             // dynBlkRefProp.GetAllowedValues();  --> refer null, no specific dimension is set
  9.                             dynBlkRefProp.Value = 114;   //--> message "eInvalidInput" here
  10.                            
  11.                         }
  12.                     }
  13.                     dynBlkRefProps.Dispose();
  14.                 }
Title: Re: Dynamic block properties
Post by: jmaeding on August 30, 2017, 05:23:38 PM
not sure if your code has any actual problems, but mine to do same thing is like:
Code: [Select]
if (props[prop].UnitsType == DynamicBlockReferencePropertyUnitsType.Distance)
    props[prop].Value = (double)dynPropsDict[prop];
else if (props[prop].PropertyTypeCode == 3)
    props[prop].Value = (short)dynPropsDict[prop];
else
    props[prop].Value = (string)dynPropsDict[prop];

props[prop] is the dynBlkRefProp so all I am saying is I only assign double, short, or string props.
maybe try dynBlkRefProp.Value = 114.0? (add the .0)
Title: Re: Dynamic block properties
Post by: latour_g on August 31, 2017, 01:53:16 PM
You are right, with 114.0 it's working.  Thank you !