Hatch patterns on Draft objects
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Hatch patterns on Draft objects
I just finished to implement hatch patterns for Draft objects. The implementation is inspired from what they did in sketchup: http://sketchupdate.blogspot.com.br/201 ... ayout.html
Basically I am using the same svg hatch patterns as already in use by the Draft->Drawing tool. When applied to a Draft object, a high-resolution transparent image is generated from the svg, and applied to the object as a texture. You can then set the pattern size, which doesn't depend on the size of the object, so you can have several objects with the exact same hatching.
Currently the implementation is still a bit rough, basically fillable Draft objects (rectangles, closed wires, circles, ...) have two new properties in their View tab: "Texture" and "Pattern Size". In Texture you can either specify a path to an image, or a pattern name (currently available: simple, cross, concrete, line and square). If you used a pattern name, the Pattern Size property allows you to adjust their size. The pattern only appears in "Flat Lines" display mode.
In the draft preferences there is a new setting to set the resolution of the texture, that is, the size of the sample image that is generated from the svg file. The higher, the better the quality of the pattern.
There are still strange graphic bugs happening (the textures get somehow "corrupted", specially when loading several. I must still investigate. Also I plan to maybe add a separate "Textured" display mode, and find a better way to add patterns than typing the pattern name, but I'm not too keen of a drop-down list, since it can be problematic if a file is opened on a machine which has nto the same patterns available.
This is still not finished, so if you guys have more ideas, fire away!
Basically I am using the same svg hatch patterns as already in use by the Draft->Drawing tool. When applied to a Draft object, a high-resolution transparent image is generated from the svg, and applied to the object as a texture. You can then set the pattern size, which doesn't depend on the size of the object, so you can have several objects with the exact same hatching.
Currently the implementation is still a bit rough, basically fillable Draft objects (rectangles, closed wires, circles, ...) have two new properties in their View tab: "Texture" and "Pattern Size". In Texture you can either specify a path to an image, or a pattern name (currently available: simple, cross, concrete, line and square). If you used a pattern name, the Pattern Size property allows you to adjust their size. The pattern only appears in "Flat Lines" display mode.
In the draft preferences there is a new setting to set the resolution of the texture, that is, the size of the sample image that is generated from the svg file. The higher, the better the quality of the pattern.
There are still strange graphic bugs happening (the textures get somehow "corrupted", specially when loading several. I must still investigate. Also I plan to maybe add a separate "Textured" display mode, and find a better way to add patterns than typing the pattern name, but I'm not too keen of a drop-down list, since it can be problematic if a file is opened on a machine which has nto the same patterns available.
This is still not finished, so if you guys have more ideas, fire away!
Re: Hatch patterns on Draft objects
Hello Yorik.
Looks really good.
Another way would have been to use the already existing .pat - format from AutoCAD.
See here for more documentation:
- AutoCAD
- CAD Addict
- Ellen Finkelstein AutoCAD Blog
Regards
Roland
Looks really good.
Another way would have been to use the already existing .pat - format from AutoCAD.
See here for more documentation:
- AutoCAD
- CAD Addict
- Ellen Finkelstein AutoCAD Blog
Regards
Roland
Deutsche FreeCAD Tutorials auf Youtube
My GrabCAD FreeCAD-Projects
FreeCAD lessons for beginners in english
Native german speaker - so apologies for my english, no offense intended
My GrabCAD FreeCAD-Projects
FreeCAD lessons for beginners in english
Native german speaker - so apologies for my english, no offense intended
Re: Hatch patterns on Draft objects
Interesting... One could write a convertor that creates svg code on top of those patterns... The syntax is simple
The problem is the linetypes... Will be hard to recreate the exact spacings in svg. Probably at the moment the easiest way
to get those patterns in FreeCAD will be to create a sample in autocad, and convert it to svg. But I'll keep this in a
corner of my mind
The problem is the linetypes... Will be hard to recreate the exact spacings in svg. Probably at the moment the easiest way
to get those patterns in FreeCAD will be to create a sample in autocad, and convert it to svg. But I'll keep this in a
corner of my mind
Re: Hatch patterns on Draft objects
Very nice work Yorik.
Re: Hatch patterns on Draft objects
Ok there is now a better interface for setting hatch patterns, I finally decided to use a drop-down list, it shouldn't harm if some pattern is not there, only an error message should appear.
There is still the graphics artifact bug I must try to solve, then make this compatible with the dxf exporter, then I think we can say it's done...
There is still the graphics artifact bug I must try to solve, then make this compatible with the dxf exporter, then I think we can say it's done...
Re: Hatch patterns on Draft objects
Hi Yorik,
Firstly thanks for the great work that you and the others have done on FreeCAD.
I'm trying to generate some arch drawings but I don't seem to be able to get the hatching to work with my Ubuntu PPA install. I've tried with both a 100mm Draft rectangle and a ~2500mm Shape2DView rectangle. When I select a hatch pattern for the Draft rect it is filled with a mostly transparent grey colour that doesn't change however much I change the Pattern Size property (from 0.01 to 1000000000.00 going up by a factor of 10 each time). Changing the pattern doesn't seem to affect this behaviour.
Also the wood.svg pattern (from viewtopic.php?f=3&t=5250) above doesn't come up in the list when I point FreeCAD to the directory it's in.
Any pointers as to what I am doing wrong?
OS: Ubuntu 14.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.15.3981 (Git)
Branch: master
Hash: 8f54360226041453340797a62b586ea78a4ac764
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
SoQt version: 1.6.0a
OCC version: 6.7.0
Firstly thanks for the great work that you and the others have done on FreeCAD.
I'm trying to generate some arch drawings but I don't seem to be able to get the hatching to work with my Ubuntu PPA install. I've tried with both a 100mm Draft rectangle and a ~2500mm Shape2DView rectangle. When I select a hatch pattern for the Draft rect it is filled with a mostly transparent grey colour that doesn't change however much I change the Pattern Size property (from 0.01 to 1000000000.00 going up by a factor of 10 each time). Changing the pattern doesn't seem to affect this behaviour.
Also the wood.svg pattern (from viewtopic.php?f=3&t=5250) above doesn't come up in the list when I point FreeCAD to the directory it's in.
Any pointers as to what I am doing wrong?
OS: Ubuntu 14.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.15.3981 (Git)
Branch: master
Hash: 8f54360226041453340797a62b586ea78a4ac764
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
SoQt version: 1.6.0a
OCC version: 6.7.0
Re: Hatch patterns on Draft objects
Hm strange... All seems to work correctly here. Try putting the wood.svg in your /home/$USER/.FreeCAD folder?
As for the hatches not displaying, I'm not sure what is the problem, maybe it's related to your 3D driver that can't display textures with transparency.. Can you try adding a Texture image to the rectangle to see if that works?
As for the hatches not displaying, I'm not sure what is the problem, maybe it's related to your 3D driver that can't display textures with transparency.. Can you try adding a Texture image to the rectangle to see if that works?
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Hatch patterns on Draft objects
Hallo, I have tested the patterns on
OS: Ubuntu 14.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.15.4090 (Git)
Branch: master
Hash: ac010de9c966b1b05c6a3b3f6fa0794cf9b89247
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.7.1
In Draft the pattern work as expected but when I map the rectangles to the drawing the patterns are only placed one time to the center (look into the circle).
whats wrong?
OS: Ubuntu 14.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.15.4090 (Git)
Branch: master
Hash: ac010de9c966b1b05c6a3b3f6fa0794cf9b89247
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.7.1
In Draft the pattern work as expected but when I map the rectangles to the drawing the patterns are only placed one time to the center (look into the circle).
whats wrong?
- Attachments
-
- Auswahl_001.png (70.32 KiB) Viewed 8456 times
-
- m01_muster_demo.fcstd
- (52.23 KiB) Downloaded 163 times
Re: Hatch patterns on Draft objects
The patterns won't appear in the Drawing viewer unfortunately, because the qt-based internal viewer doesn't support many of those more advanced things... If you use the "preview in browser" button in the Drawing WB, you should see your file with all its features.
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Hatch patterns on Draft objects
Thank you. Works fine.