Get and set dynamicpropertyByname in python

hi everyone,
i want to know how can i a get and set dynamicpropertybynam in python , i dont want by node but in python if it possible ?

see this

/// https://forums.autodesk.com/t5/net/dynamic-block-properties-not-being-updated-using-c-net/m-p/10559162
private static void DisplayDynBlockProperties( Editor ed, BlockReference br, string name )
        {
            // Only continue is we have a valid dynamic block
            if (br != null && br.IsDynamicBlock)
            {
                ed.WriteMessage( "\nDynamic properties for \"{0}\"\n", name );

                // Get the dynamic block's property collection
                DynamicBlockReferencePropertyCollection pc = br.DynamicBlockReferencePropertyCollection;

                // Loop through, getting the info for each property 
                foreach (DynamicBlockReferenceProperty prop in pc)
                {
                    // Start with the property name, type and description
                    ed.WriteMessage( "\nProperty: \"{0}\" : {1}", prop.PropertyName, prop.UnitsType );

                    if (prop.Description != "")
                    {
                        ed.WriteMessage( "\n  Description: {0}", prop.Description );
                    }

                    // Is it read-only?
                    if (prop.ReadOnly)
                    {
                        ed.WriteMessage(" (Read Only)");
                    }
                    else if (!prop.ReadOnly)
                    {
                        ed.WriteMessage(" (READ WRITE Only)");
                    }

                    //Switch Property
                    if (prop.PropertyName == "STEM_LENGTH" )  
                    {

                        object[] values = prop.GetAllowedValues();
                        prop.Value = 48;
                        // GETTING THE EXCEPTION HERE.
                       
                    }
            .........
            ..........
       }
    }
}
1 Like

thk