← Back to team overview

kicad-developers team mailing list archive

Re: Track copy - to be or not to be… I'm panelizing, python coder.

 

Le 01/10/2014 20:42, Daniel Dawid Majewski a écrit :
> On 01.10.2014 16:25, Wayne Stambaugh wrote:
>> They do.  It is automatically generated by the compiler just like the
>> source code comment explains.  Unless you need some special copy
>> semantics (not just a direct copy of every class member which is what
>> the compiler will generate), you do not need to write your own copy
>> constructor.
> Ok, so where are nested following python methods ?:
> Copy(MODULE self, MODULE src)
> Copy(ZONE_CONTAINER self, ZONE_CONTAINER src)
> How I could make ?:
> Copy(TRACK self, TRACK src)
> Copy(VIA self, VIA src)

Seems there is a mistake between a copy constructor and the Copy method
which exists for some BOARD_ITEMS, but not all (because currently this
method is not needed in C++ Kicad code for track/vias)

The Copy method copy only some values from an existing source to an
existing target.

The default copy constructor creates a clone (a new item) of an item.
This is very different.

I'll add a Copy method (mainly for python scripts) for tracks/vias soon.

For now, to create a clone of a track/via using the default copy
constructor, try to use something like :
newtrack=oldtrack.__class__(oldtrack)

(I am hoping it works, I am not experienced in Python language)


-- 
Jean-Pierre CHARRAS


Follow ups

References