passing variables as object attributes

Vikas Mahajan vikas.mahajan12 at
Mon Aug 16 16:08:15 CEST 2010

On 16 August 2010 19:23, Nitin Pawar <nitinpawar432 at> wrote:
> you would need to define a class first with its attiributes and then you may
> want to initiate the variables by calling the class initilializer
Actually I have to dynamically add attributes to a object. I am
writing python script for  FreeCAD software. I am using loop to create
multiple cylinders and I am writing following code-:
cyname = "Cylinder"
FreeCAD.ActiveDocument.cyname.Radius= .5
FreeCAD.ActiveDocument.cyname.Height= 10

And I am getting this error-:
AttributeError: 'App.Document' object has no attribute 'cyname'

But when I use Cylinder in place of cyname, I am not getting any error.

Please help.


More information about the Python-list mailing list