Skip to content

Commit b2e858a

Browse files
committed
Add compensation for top and left margins when fitView is used
1 parent 65de218 commit b2e858a

File tree

1 file changed

+8
-2
lines changed
  • cadquery/occ_impl/exporters

1 file changed

+8
-2
lines changed

cadquery/occ_impl/exporters/svg.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,12 @@ def getSVG(shape, opts=None):
247247
else:
248248
width = height * (bb.xlen / bb.ylen)
249249

250+
image_width = width + (marginLeft * 2.0)
251+
image_height = height + (marginTop * 2.0)
252+
else:
253+
image_width = width
254+
image_height = height
255+
250256
# width pixels for x, height pixels for y
251257
unitScale = min(width / bb.xlen * bb_scale, height / bb.ylen * bb_scale)
252258

@@ -290,8 +296,8 @@ def getSVG(shape, opts=None):
290296
"visibleContent": visibleContent,
291297
"xTranslate": str(xTranslate),
292298
"yTranslate": str(yTranslate),
293-
"width": str(width),
294-
"height": str(height),
299+
"width": str(image_width),
300+
"height": str(image_height),
295301
"textboxY": str(height - 30),
296302
"uom": str(uom),
297303
"axesIndicator": axesIndicator,

0 commit comments

Comments
 (0)