def ensure_layer(self, openjson_obj, eagle_context):
        """
        Return the eaglexml layer for the given openjson object (Pin, Shape, etc.)
        given an eaglexml context string (pin, symbol, etc.). If the layer does
        not exists, create it and add it to the design.
        """

        layernum = None

        if hasattr(openjson_obj, 'attributes') \
                and 'eaglexml_layer' in openjson_obj.attributes:
            layernum = openjson_obj.attributes['eaglexml_layer']

            if layernum in self.layercache:
                return self.layercache[layernum]

        layer = default_layers[eagle_context]

        if layernum is None or layernum == layer.number:
            pass
        else:
            layer = G.layer(number=layernum, name=layernum,
                            color="1", fill="1", visible="yes", active="yes")

        if layer.number in self.layercache:
            return self.layercache[layer.number]
        else:
            self.layercache[layer.number] = layer
            self.layers.layer.append(layer)
            return layer
Example #2
0
    def ensure_layer(self, openjson_obj, eagle_context):
        """
        Return the eaglexml layer for the given openjson object (Pin, Shape, etc.)
        given an eaglexml context string (pin, symbol, etc.). If the layer does
        not exists, create it and add it to the design.
        """

        layernum = None

        if hasattr(openjson_obj, 'attributes') \
                and 'eaglexml_layer' in openjson_obj.attributes:
            layernum = openjson_obj.attributes['eaglexml_layer']

            if layernum in self.layercache:
                return self.layercache[layernum]

        layer = default_layers[eagle_context]

        if layernum is None or layernum == layer.number:
            pass
        else:
            layer = G.layer(number=layernum,
                            name=layernum,
                            color="1",
                            fill="1",
                            visible="yes",
                            active="yes")

        if layer.number in self.layercache:
            return self.layercache[layer.number]
        else:
            self.layercache[layer.number] = layer
            self.layers.layer.append(layer)
            return layer
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# TODO: handle layers

import upconvert.parser.eaglexml.generated_g as G

default_layers = {
    "net": G.layer(number="91", name="Nets", color="2", fill="1", visible="yes", active="yes"),
    "bus": G.layer(number="92", name="Busses", color="1", fill="1", visible="yes", active="yes"),
    "pin": G.layer(number="93", name="Pins", color="2", fill="1", visible="no", active="yes"),
    "symbol": G.layer(number="94", name="Symbols", color="4", fill="1", visible="yes", active="yes"),
    "name": G.layer(number="95", name="Names", color="7", fill="1", visible="yes", active="yes"),
    "value": G.layer(number="96", name="Values", color="7", fill="1", visible="yes", active="yes"),
    "info": G.layer(number="97", name="Info", color="7", fill="1", visible="yes", active="yes"),
    "guide": G.layer(number="98", name="Guide", color="6", fill="1", visible="yes", active="yes"),
    }


class EagleXML(object):
    """ The Eagle XML Format Writer """

    SCALE = 0.5
    MULT =  25.4 / 90 # 90dpi to mm
Example #4
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# TODO: handle layers

import upconvert.parser.eaglexml.generated_g as G
from math import fabs

default_layers = {
    "net":
    G.layer(number="91",
            name="Nets",
            color="2",
            fill="1",
            visible="yes",
            active="yes"),
    "bus":
    G.layer(number="92",
            name="Busses",
            color="1",
            fill="1",
            visible="yes",
            active="yes"),
    "pin":
    G.layer(number="93",
            name="Pins",
            color="2",
            fill="1",
            visible="no",