Moving a footprint using the IPC API changes the anchor point but doesn't move the footprint

This is a follow-on to my question here: KiCad IPC API script to move a footprint is not working. Is it me or is it a bug? - External Plugins - KiCad.info Forums I tried building the latest git source and now I am not getting crashes and “something is happening”. The issue is that now, when I issue the move for the fingerprint, the anchor moves, but the footprint itself does not - it’s as if you went into the footprint editor and moved the anchor point there.

Here is a screenshot showing exactly what’s happening:

Before: before

After:

As you can see, the anchor point moves, but the actual footprint does not move with it.

The entire code is in my first post, but here’s the relevant section that updates the position:

    # Find item J1 in the PCB.
    items = get_footprints(pcb) # this is a function I wrote to find the footprint by reference
    j1 = items.get('J1')
    if j1 is None:
        print('No footprint J1 found.')
        return

    # Print the position of J1
    print("J1 is at: ",end='')
    print(j1.position)

    # Position J1 
    print("Moving J1 to 0,0")
    comm = pcb.begin_commit()
    j1.position = Vector2.from_xy(0, 0)
    print("J1 is now at: ",end='')
    print(j1.position)
    
    print("Sending update to KiCad")
    try:
        pcb.update_items([j1])
        pcb.push_commit(comm)
        # Save the PCB
        pcb.save()
    except Exception as e:
        # ... handler

The code does not show any errors, and the position is shown as updated when I print it again after changing it. The issue seems to be that the anchor moves but the relationship between the anchor and the other items in the footprint changes to match the new anchor point, rather than simply moving the footprint to the new point based on the anchor.

Is this a bug or am I doing something wrong?

This is a known issue, I started working on a fix but it’s not simple, so no timeline yet.

1 Like

Hmm. I suppose I’ll just have to learn the SWIG API then, even though it’s deprecated… Oh well :slight_smile:

Fixed for 0.4.0 / KiCad 9.0.2

Thanks! I’m building the latest git source now, I’ll see if anything works better. (Saw a commit about footprint caching, so maybe this will work…we’ll see!)