blob: 50df73872b6019db3a73d2c76569762102baac05 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# copyright 2015 Hamilton Kibbe <ham@hamiltonkib.be>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# 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.
"""
CAM File Operations
===================
**Transformations and other operations performed on Gerber and Excellon files**
"""
import copy
def to_inch(cam_file):
""" Convert Gerber or Excellon file units to imperial
Parameters
----------
cam_file : `gerber.cam.CamFile` subclass
Gerber or Excellon file to convert
Returns
-------
gerber_file : `gerber.cam.CamFile` subclass
A deep copy of the source file with units converted to imperial.
"""
cam_file = copy.deepcopy(cam_file)
cam_file.to_inch()
return cam_file
def to_metric(cam_file):
""" Convert Gerber or Excellon file units to metric
Parameters
----------
cam_file : `gerber.cam.CamFile` subclass
Gerber or Excellon file to convert
Returns
-------
gerber_file : `gerber.cam.CamFile` subclass
A deep copy of the source file with units converted to metric.
"""
cam_file = copy.deepcopy(cam_file)
cam_file.to_metric()
return cam_file
def offset(cam_file, x_offset, y_offset):
""" Offset a Cam file by a specified amount in the X and Y directions.
Parameters
----------
cam_file : `gerber.cam.CamFile` subclass
Gerber or Excellon file to offset
x_offset : float
Amount to offset the file in the X direction
y_offset : float
Amount to offset the file in the Y direction
Returns
-------
gerber_file : `gerber.cam.CamFile` subclass
An offset deep copy of the source file.
"""
cam_file = copy.deepcopy(cam_file)
cam_file.offset(x_offset, y_offset)
return cam_file
def scale(cam_file, x_scale, y_scale):
""" Scale a Cam file by a specified amount in the X and Y directions.
Parameters
----------
cam_file : `gerber.cam.CamFile` subclass
Gerber or Excellon file to scale
x_scale : float
X-axis scale factor
y_scale : float
Y-axis scale factor
Returns
-------
gerber_file : `gerber.cam.CamFile` subclass
An scaled deep copy of the source file.
"""
# TODO
pass
def rotate(cam_file, angle):
""" Rotate a Cam file a specified amount about the origin.
Parameters
----------
cam_file : `gerber.cam.CamFile` subclass
Gerber or Excellon file to rotate
angle : float
Angle to rotate the file in degrees.
Returns
-------
gerber_file : `gerber.cam.CamFile` subclass
An rotated deep copy of the source file.
"""
# TODO
pass
|