passing variables as object attributes

nn pruebauno at
Mon Aug 16 16:28:10 CEST 2010

On Aug 16, 10:08 am, Vikas Mahajan <vikas.mahaja... at> wrote:
> On 16 August 2010 19:23, Nitin Pawar <nitinpawar... 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.addObject("Part::Cylinder",cyname)
> 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.
> Thanks.

More information about the Python-list mailing list