Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCB library. Rotating a component does not rotate the pin_labels #13

Open
PartyTonight opened this issue Apr 24, 2014 · 1 comment
Open

Comments

@PartyTonight
Copy link

Hi Matt,

We are trying to figure out how to rotare the pin_labels, we tryed modifying the pin_labels property but there is something we are missing.

class Component(object):
''' Generic PCB component.
'''
def init(self, x, y, rot=0, name=''):
''' Constructs a Component object
x X position
y Y position
rotation angle (degrees)
name String
'''
self.x = x
self.y = y
self.rot = rot

    self.name = name

def __getitem__(self, i):
    if isinstance(i, str):
        try:
            pin = [p for p in self.pins if p.name == i][0]
        except IndexError:
            raise IndexError("No pin with name %s" % i)
    elif isinstance(i, int):
        try:
            pin = self.pins[i-1]
        except IndexError:
            raise IndexError("Pin %i is not in array" %i)
    return BoundPin(pin, self)

@property
def pads(self):
    pads = reduce(operator.add, [p.pad for p in self.pins])
    return s2d.move(s2d.rotate(pads, self.rot), self.x, self.y)

@property
def pin_labels(self):
    L = []
    for p in self.pins:
        p = BoundPin(p, self)
        if p.pin.name:
            L.append(text(p.pin.name, p.x, p.y, 0.03))
    pin_labels=reduce(operator.add, L) if L else None
    return s2d.rotate(pin_labels,self.rot)  #this raises error 'NoneType' object has no attribute 'map'

@property
def label(self):
    return text(self.name, self.x, self.y, 0.03)
@PartyTonight
Copy link
Author

@Property
def pin_labels(self):
L = []
for p in self.pins:
p = BoundPin(p, self)
if p.pin.name:
L.append(text(p.pin.name, p.x, p.y, 0.03))
return s2d.rotate(reduce(operator.add, L),self.rot) if L else None

This rotates the labels but they are not in the correct position

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant