How do I specify size of a dxf in openscad?

2.2k Views Asked by At

I am new to openscad and trying to make a 3d model from a dxf file. I want to specify its size as 130x130. I've been able to get as far as the code below but it still does not assert the size I want:

linear_extrude(height = 5, center = true, convexity = 10) import (file="bahtinov.dxf");

Any help is appreciated!

3

There are 3 best solutions below

0
On

I don't think you can, but you can scale it afterwards.

scaling_factor=0.5;
scale([scaling_factor,scaling_factor,1])
linear_extrude(height = 5, center = true, convexity = 10) import (file="bahtinov.dxf");
0
On

You can achieve this by using resize() on the imported DXF:

linear_extrude(height = 5, center = true, convexity = 10) resize([130,130]) import (file="bahtinov.dxf");
4
On

You can use dxf_dim(): create a further layer in your dxf, e.g. "dimensions", draw a horizontal and a vertical dimension line with the max. width resp. the max. height as described in Documentation, as identifier e.g. "TotalWidth" and "TotalHeight", here my test-drawing as example:

dimension line with identifier

get the values with:

tw = dxf_dim(file="bahtinov.dxf", name="TotalWidth", layer="dimensions", scale=1);
th = dxf_dim(file="bahtinov.dxf", name="TotalHeight", layer="dimensions", scale=1);

scale the part:

scale([130/tw,130/th,1]) linear_extrude(height = 5, center = true) import(file="bahtinov.dxf", layer="layerName", scale=1);