Skip to content

offset2d

arnholm edited this page May 1, 2017 · 1 revision

offset2d

The operator <offset2d> offsets a set of 2d shapes in positive (outward) or negative (inward) directions and optionally rounds off convex corners. The result is a new 2d shape. No 3d objects may occur in this context.

Parameter name Description Status
delta Offset distance required
round Boolean true/false, true for rounded corners required
chamfer Boolean true/false optional (default=false)

The feature and parameters can be illustrated using a few examples using a square with size=10 as reference:

First a basic square size=10 without offset:

<?xml version="1.0" encoding="utf-8"?>
<xcsg version="1.0">
    <linear_extrude dz="1">
        <square size="10" center="false"/>
    </linear_extrude>
</xcsg>

Basic square size=10 with delta=2 offset and rounding:

<?xml version="1.0" encoding="utf-8"?>
<xcsg version="1.0">
    <linear_extrude dz="1">
        <offset2d delta="2" round="true" chamfer="false">
            <square size="10" center="false"/>
        </offset2d>
    </linear_extrude>
</xcsg>

Basic square size=10 with delta=2 offset, no rounding:

<?xml version="1.0" encoding="utf-8"?>
<xcsg version="1.0">
    <linear_extrude dz="1">
        <offset2d delta="2" round="false" chamfer="false">
            <square size="10" center="false"/>
        </offset2d>
    </linear_extrude>
</xcsg>

Basic square size=10 with delta=2 offset, no rounding, with chamfer:

<?xml version="1.0" encoding="utf-8"?>
<xcsg version="1.0">
    <linear_extrude dz="1">
        <offset2d delta="2" round="false" chamfer="true">
            <square size="10" center="false"/>
        </offset2d>
    </linear_extrude>
</xcsg>

Notice that offset2d with a positive delta, round=”false” in combination with offset2d and a negative delta, round=”true” is a way to create 2d fillets:

<?xml version="1.0" encoding="utf-8"?>
<xcsg version="1.0">
    <linear_extrude dz="1">
        <offset2d delta="-2" round="true" chamfer="false">
            <offset2d delta="2" round="false" chamfer="false">
                <union2d>
                    <square size="10" center="false"/>
                    <square size="10" center="false">
                        <tmatrix>
                            <trow c0="1" c1="0" c2="0" c3="5"/>
                            <trow c0="0" c1="1" c2="0" c3="5"/>
                            <trow c0="0" c1="0" c2="1" c3="0"/>
                            <trow c0="0" c1="0" c2="0" c3="1"/>
                        </tmatrix>
                    </square>
                </union2d>
            </offset2d>
        </offset2d>
    </linear_extrude>
</xcsg>

Clone this wiki locally