Inset object along XY

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
kefir
Posts: 30
Joined: Wed Jul 23, 2014 9:03 pm

Inset object along XY

Post by kefir »

I have a design that was made by importing an SVG drawing (path), making it a face, and then extruding that along the Z axis. It turns out that the SVG was based on a sketch that was made by overlaying a part on paper and tracing a line around it with a pen - so the sketch was offset around 1-2mm outside the perimeter of the original object.

As a result, I'd like to virtually shave off a couple of mm around the perimeter, or do a negative offset (inset?) of the outline of my object on the XY plane. Is this practically feasible? Do I have to go back and try to do this with the SVG, or the original sketch? I don't want to shrink the entire object, that would result in wrong measurements other places. I want holes/gaps to be bigger, but the outline to be smaller.

fcstd attached.

OS: Ubuntu 16.04.2 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6707 (Git)
Build type: None
Branch: releases/FreeCAD-0-16
Hash: 5465bc47c95db45e0be85dc0e2872419efadce0f
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
Attachments
sample.fcstd
(11.25 KiB) Downloaded 28 times
chrisb
Veteran
Posts: 54207
Joined: Tue Mar 17, 2015 9:14 am

Re: Inset object along XY

Post by chrisb »

- You could use a fillet around the face. The inner edges are then offset by the fillet radius.
- Next you can Draft downgrade until you get the faces.
- Delete all fillet faces, and keep the inner face which is what you wanted.
- Last you can Part->Extrude the face again.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
bejant
Veteran
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

Re: Inset object along XY

Post by bejant »

Or you can just hide the things you aren't going to use, but that makes for a bigger file size. The attached file uses the method explained by chisb, but I didn't delete anything. The blue outline is the original shape and grey is 2mm offset (the odd coloration of the top surface is the result of z-fighting):
20170311.png
20170311.png (23.82 KiB) Viewed 2579 times
20170311-016-sample-bejant.fcstd
(237.56 KiB) Downloaded 29 times
OS: Ubuntu 16.04.2 LTS
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.16.6707 (Git)
Build type: None
Branch: releases/FreeCAD-0-16
Hash: 5465bc47c95db45e0be85dc0e2872419efadce0f
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
User avatar
Willem
Veteran
Posts: 1854
Joined: Fri Aug 12, 2016 3:27 pm
Location: Lisse, The Netherlands

Re: Inset object along XY

Post by Willem »

hi, a more simple method
Extrude SVGface with the extrude function in part design, this is what you already did, but change the taper angle to -10 or another angle that creates the inset you want
In draft workbench make a facebinder to the smaller top face
Extrude the facebinder
Attachments
sample-willem.fcstd
(103.2 KiB) Downloaded 25 times
kefir
Posts: 30
Joined: Wed Jul 23, 2014 9:03 pm

Re: Inset object along XY

Post by kefir »

Thanks for the suggestions! I think chrisb's suggestion is the simplest since I know the distance I want to inset, with Willem's suggestion I need to do some (simple) calculation.

A drawback I think so far is that I'd like to script this, and doing the Draft -> Downgrade I get lots of faces. How will I know which face to keep? I guess I could traverse all App.ActiveDocument.Face* and sort by .Shape.Area, keeping the second largest.

Also, another shape I have just disappears when I try to create a fillet of 1mm or more. I can manage a fillet of a bit less than 1mm, but I think that's too little. None of the details are that small, as far as I can tell. Any ideas why it won't fillet?
Attachments
sample2.fcstd
(18.05 KiB) Downloaded 25 times
kefir
Posts: 30
Joined: Wed Jul 23, 2014 9:03 pm

Re: Inset object along XY

Post by kefir »

Seems like insetting in inkscape may be easier. Editing the SVG in inkscape, I could simply choose Edit -> Preferences -> Behaviour -> Steps to define the inset distance, and then simply select the path and choose Path -> Inset. I use this "script" to convert to an object:

Code: Select all

from FreeCAD import Base
import importSVG
import Part

def extrudeSVG(filename, thickness):

    doc = App.ActiveDocument

    # Import SVG
    importSVG.insert(filename, doc.Name) # returns None
    Gui.SendMsgToActiveView("ViewFit")
    # Get latest object in document:
    SVG = doc.Objects[-1]
    # Gui.ActiveDocument.activeObject()
    # Gui.ActiveDocument.path3400
    # All objects: App.ActiveDocument.Objects[0] etc

    # Create face, hide SVG
    tmp = Part.Face(Part.Wire(Part.__sortEdges__(SVG.Shape.Edges)))
    if tmp.isNull(): raise RuntimeError('Failed to create face')

    doc.addObject('Part::Feature', 'SVGFace').Shape = tmp
    del tmp
    SVG.ViewObject.Visibility=False

    # Extrude face
    SVGFace = doc.Objects[-1]
    SVGExtrude = doc.addObject("Part::Extrusion", "SVGExtrude")
    SVGExtrude.Base = doc.SVGFace
    SVGExtrude.Dir = (0, 0, thickness)
    SVGExtrude.Solid = (True)
    SVGExtrude.TaperAngle = (0)
    doc.SVGFace.ViewObject.Visibility = False
    doc.recompute()

# Demo use:
# extrudeSVG(u"/path/to/file/design.svg", 4)
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Inset object along XY

Post by DeepSOIC »

Last but not least, in 0.17 Part workbench got a 2D Offset tool.
chrisb
Veteran
Posts: 54207
Joined: Tue Mar 17, 2015 9:14 am

Re: Inset object along XY

Post by chrisb »

kefir wrote:Any ideas why it won't fillet?
I cannot tell for sure, but here seems something going wrong (please have in mind that filleting is performed by the OCC kernel, lying out of scope of the FreeCAD developers):
Attachments
Bildschirmfoto 2017-03-12 um 19.56.48.png
Bildschirmfoto 2017-03-12 um 19.56.48.png (32.97 KiB) Viewed 2540 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply