Creating a cross section view in Drawing

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!
rjschwei
Posts: 1
Joined: Sun Feb 22, 2015 8:05 pm

Creating a cross section view in Drawing

Post by rjschwei »

Hi,

I managed to create a drawing from a 3D part I designed. The part is cylindrical and thus providing a cross sectional view is very helpful for dimensioning etc.

How do I get FreeCAD to create a cross sectional view, or how do I manually add it to the drawing?
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Creating a cross section view in Drawing

Post by yorik »

Currently there is no dedicated tool for that in the Drawing WB, but have a look at the Arch SectionPlane tool, it should be able to help you.
User avatar
NormandC
Veteran
Posts: 18587
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Creating a cross section view in Drawing

Post by NormandC »

Yorik, it appears that an Arch Section that is projected as a view on a drawing page does not have an option to display hatching or solid filling of the shape, am I correct?
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Creating a cross section view in Drawing

Post by yorik »

Indeed. What it does under the hood, is just create a big invisible solid behind the section plane, subtract it from the object(s) cut by the section plane, and project the result.

You have two projection options, though: The normal Drawing module algorithm, which is used by other Drawing tools, and the Arch renderer I did some time ago, which unlike the former one does project faces as closed paths, so they can receive filling. But this renderer is still very buggy (and awfully slow).

But, even when using the Drawing algorithm, the edge loops at the intersection of the object(s) and the section plane are gathered (so they can be drawn with thicker line). So, turning these edge loops into closed paths (and therefore give them color or pattern fills) would not be hard to do...
User avatar
NormandC
Veteran
Posts: 18587
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Creating a cross section view in Drawing

Post by NormandC »

yorik wrote:You have two projection options, though: The normal Drawing module algorithm, which is used by other Drawing tools, and the Arch renderer I did some time ago, which unlike the former one does project faces as closed paths, so they can receive filling. But this renderer is still very buggy (and awfully slow).
Not sure what you mean. I don't see any projection tool in the Arch workbench.

BTW contrary to what the Arch Section wiki page says, it does not automatically create a view on a drawing page.

Before you first replied, I had toyed with a workaround.

First, I created a cylinder with a hole in it, then I cut it in half longitudinally ("Pocket" in my FreeCAD file).
FC_Cyl_Drawing_Section_01.png
FC_Cyl_Drawing_Section_01.png (9.05 KiB) Viewed 27820 times
Then I selected the two planar faces resulting from the cut and I created a Image Draft Facebinder object that I rotated to the XY plane.

Since the two faces are unconnected, I selected the Pocket and created a Image Draft Shape2DView, changed its projection to (0,-1,0) and rotated it to the XY plane. With the Facebinder and Shape2DView placed over each other, this creates an acceptable section view representation.
FC_Cyl_Drawing_Section_02.png
FC_Cyl_Drawing_Section_02.png (8.4 KiB) Viewed 27820 times
Then in the Model tree I created a group that I renamed "Section", and drag & dropped both the Facebinder and the Shape2DView object. The idea was to create a single projected view with both elements, which is only possible with a view created from a group.

I created the view from the "Section" group using the Draft Drawing tool. In the ViewSection properties, I changed the "Fill Style" to "shape color". I tried using another fill style, but I could'nt control their scale. When viewing the drawing page in the browser view, the hatching for "simple" is incredibly small, you have to zoom like crazy to see they are slanted lines.

I created a top view of the "Pad" object, and in the 3D view I drew a section symbol using Draft tools (lines and text), made a new "Section2" group and projected it over my orthogonal view.
FC_Cyl_Drawing_Section_04.png
FC_Cyl_Drawing_Section_04.png (19.04 KiB) Viewed 27820 times
This is the result. I added the centerlines and the diameter dimensions with the "Drawing Dimensioning workbench" external add-on from hamish (it requires the 0.15 development version).
FC_Cyl_Drawing_Section_03.png
FC_Cyl_Drawing_Section_03.png (49.66 KiB) Viewed 27820 times
I should add that the Facebinder and Shape2DView objects are fully parametric, i.e. they are linked to the Pocket feature. If there's any change to the original "Pad", these changes will propagate to them, and to the drawing view as well.
Attachments
Cylinder_Drawing_Section.fcstd
(42.95 KiB) Downloaded 505 times
SebLiss
Posts: 16
Joined: Mon Apr 13, 2015 12:14 pm

Re: Creating a cross section view in Drawing

Post by SebLiss »

Thank you very much NormandC, that is exactly what I needed that to draw an acceptable CAD drawing. That would be better with different fill style but I can deal easily with that, waiting for a futur realease including a drawing cross section tool!

Sebastien L.

My drawing :
Image
SebLiss
Posts: 16
Joined: Mon Apr 13, 2015 12:14 pm

Re: Creating a cross section view in Drawing

Post by SebLiss »

Hi again,

For the hatch pattern I use this python script :

Code: Select all

# ajout du pattern
f = open("./renduSVG.svg", "r")
contents = f.readlines()
f.close()

contents.insert(36, " \
<pattern id=\"diagonalHatch\" width=\"2\" height=\"2\"\n \
    patternTransform=\"rotate(-45 0 0)\" \n \
    patternUnits=\"userSpaceOnUse\"> \n \
    <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"30\" style=\"stroke:black; stroke-width:0.2\" /> \n \
</pattern> \n")

# remplacement de toutes les zone filled avec du gris par le pattern
f = open("./renduSVG_h.svg", "w")
contents = "".join(contents)
f.write(contents)
f.close()


infile = open('./renduSVG_h.svg', 'r+')
outfile = open('./renduSVG_hm.svg', 'w')

replacements = {'fill:#cccccc':'fill:url(#diagonalHatch)', 'trytrytry':'nothing'}

for line in infile:
    for src, target in replacements.items():
        line = line.replace(src, target)
    outfile.write(line)
infile.close()
outfile.close()
It takes a file "renduSVG_h.svg" (exported with freecad), and modify all the grey fill (color #cccccc) by the hatch pattern. Maybe you will have to change the line number (36 here) by 35 of 37, depends of the file.
It's just a trick that I would like to share, not the better solution in my opinion^^, but it works.
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Creating a cross section view in Drawing

Post by yorik »

Very nice drawing!

I'm working on something to be able to make decent fill patterns in the Drawing view, with precise control over size and linewidth... More to come...
SebLiss
Posts: 16
Joined: Mon Apr 13, 2015 12:14 pm

Re: Creating a cross section view in Drawing

Post by SebLiss »

Ok, thank you very much Yorik, it seems to be the last thing missing to get a nice CAD drawing ;)
janeks
Posts: 21
Joined: Fri Jan 02, 2015 6:41 pm

Re: Creating a cross section view in Drawing

Post by janeks »

Hi,

Are there same new solutions/tools after last post included in last versions regarding "Creating a cross section view in Drawing"?

I am using:
OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.5958 (Git)
Build type: Release
Branch: master
Hash: b3e0e8272f0ed017caf7644808e929c87a85937e
Python version: 2.7.8
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17

brgds
Janeks
Post Reply