Author Topic: Dynamic block properties  (Read 137 times)

0 Members and 1 Guest are viewing this topic.

latour_g

  • Newt
  • Posts: 118
Dynamic block properties
« 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.                }

jmaeding

  • Bull Frog
  • Posts: 279
  • How many of you have never raised your hand?
Re: Dynamic block properties
« Reply #1 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)
James Maeding

latour_g

  • Newt
  • Posts: 118
Re: Dynamic block properties
« Reply #2 on: August 31, 2017, 01:53:16 pm »
You are right, with 114.0 it's working.  Thank you !