cdelker / schemdraw

MIT License
103 stars 20 forks source link

Properties of CurrentLabel() not working since 0.18 #35

Closed csiegl182 closed 4 months ago

csiegl182 commented 4 months ago

CurrentLabels() are not working since 0.18 as expected. The reason is obvious since all properties are ignored within init(). Is there a refactoring going on regarding this element?

cdelker commented 4 months ago

CurrentLabel had some problems in 0.18 that were fixed in 9e85a82359abdb7f825668f087f7fb8a6c0a642b (See https://github.com/cdelker/schemdraw/issues/23). Do issues persist in the latest (unreleased) commit?

Element keyword arguments are picked up and put in Element.params by Element.__new__, so they may be there and used even if not captured in __init__.

csiegl182 commented 4 months ago

Thanks for you help. I overlooked the implementation of the new method.

However, I still face some issues. I dont know if I use the syntax appropriately, but if I have the following code I observe a KeyError due to missing lblloc parameter.

import schemdraw
import schemdraw.elements as elm

with schemdraw.Drawing() as d:
    d += (R:=elm.Resistor().down())
    d += elm.CurrentLabel(reverse=True).theta(180).at(R.center).label('foo', rotate=180, loc='bottom', ofst=(1, 1))

I am not quite sure if this is an unintended parameter combination or if there is a missing default value for lblloc.

cdelker commented 4 months ago

Confirmed. It was a combination of using .at with an absolute position (R.center instead of just R) and providing a rotation to the label at the same time. a30d98af9521467c8e97d958395f3b00f3cc2eff should fix it.

csiegl182 commented 4 months ago

Looks good right now. Thanks a lot for your immediate help!