FreeCAD-Doc/localwiki/Draft_mapping_files.html
2018-07-08 12:11:49 -05:00

111 lines
5.1 KiB
HTML

<html><head><title>Draft mapping files</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link type='text/css' href='wiki.css' rel='stylesheet'></head><body><h1>Draft mapping files</h1></div>
<div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><div class="mw-parser-output"><p>The Draft module is able to import files created form any program capable of exporting DXF files. But since FreeCAD is very different from <a rel="nofollow" class="external text" href="http://en.wikipedia.org/wiki/Autocad">AutoCAD</a> and other usual 2D CAD programs, you might want to translate automatically the way DXF entities appear in FreeCAD.
</p><p>For example 2D CAD programs often use a black background, so you make your drawing using bright colors, like yellow, green, etc. Then, when you want to print your drawing, those ugly colors will be mapped to nice black colors with different linewidths.
</p><p>Since FreeCAD is not an AutoCAD clone, we don't need to stick to those ugly colors. The concepts of colors, linewidth, or layers are actually very different in FreeCAD. So, we can take advantage of this new environment and work, for example, with black lines on white background. We can also use different linewidths, so our drawing will look on the screen pretty much the same way as it will be printed (note that printing your drawing from FreeCAD is still not supported at the moment, a little bit more patience!).
</p><p>To use a mapping file, simply navigate to Edit -&gt; Preferences -&gt; Draft -&gt; dxf settings and select those two options:
</p>
<ul><li> Import style: Map colors to linewidths</li>
<li> Mapping file: navigate to a .csv file (see below)</li></ul>
<p>These settings will then be your defaults next time you import a DXF file.
</p><p>The Draft module accepts two types of .csv (comma- or tab-separated file) as mapping file:
</p>
<h4><span class="mw-headline" id="converting_from_autocad_plot_styles">converting from autocad plot styles</span></h4>
<p><a rel="nofollow" class="external text" href="http://en.wikipedia.org/wiki/Autocad">AutoCAD</a> saves its plot styles as .CTB files. If you open your plot style manager from AutoCAD, you will actually open an explorer window showing the location where those files are saved. The DXF importer cannot use these files directly because, you will have guessed, they are encoded. Fortunately, there is a nice free <a rel="nofollow" class="external text" href="http://www.noliturbare.com/index.php">CTB viewer &amp; converter</a> that can convert CTB files to TAB-separated CSV files.
The .csv files generated by this program can be used immediately, they can also be edited with any spreadsheet application.
</p>
<h4><span class="mw-headline" id="making_your_own_.csv_files">making your own .csv files</span></h4>
<p>Making your own mapping files is very easy too. It can be made in a spreadsheet application or in any text editor. The rule is simple: you need 3 columns separated by a tabulation (hit the TAB key). First column is the AutoCAD color, second column is the FreeCAD linecolor RGB value formatted like this: 255,255,255 and the third column is the FreeCAD linewidth in pixels. The first line won't be read. So, you can make one like this, for example:
</p>
<table>
<tr>
<td> dxf color
</td>
<td> freecad color
</td>
<td> freecad linewidth
</td></tr>
<tr>
<td> 1
</td>
<td> 0,0,0
</td>
<td> 1
</td></tr>
<tr>
<td> 2
</td>
<td> 0,0,0
</td>
<td> 2
</td></tr>
<tr>
<td> 3
</td>
<td> 0,0,0
</td>
<td> 3
</td></tr>
<tr>
<td> 4
</td>
<td> 0,0,0
</td>
<td> 4
</td></tr>
<tr>
<td> 5
</td>
<td> 0,0,0
</td>
<td> 5
</td></tr>
<tr>
<td> 6
</td>
<td> 0,0,0
</td>
<td> 6
</td></tr>
<tr>
<td> 7
</td>
<td> 0,0,0
</td>
<td> 1
</td></tr>
<tr>
<td> 8
</td>
<td> 80,80,80
</td>
<td> 1
</td></tr>
<tr>
<td> 9
</td>
<td> 160,160,160
</td>
<td> 1
</td></tr></table>
<p>The above table would convert color 1 (red) to black (0,0,0)/1 pixel, color 2 (yellow) to black/2 pixels, color 8 (darkgrey) to some dark shade of grey(80,80,80) and 1 pixel wide, etc, etc. You can specify only the colors that you need. What you didn't specify will receive default color/linewidth.
</p><p>Don't forget that the first line won't be used, so you can use it for writing column titles for example.
If you write a .csv file in a spreadsheet application (such as <a rel="nofollow" class="external text" href="http://en.wikipedia.org/wiki/Openoffice">OpenOffice</a>), be careful that sometimes your spreadsheet will think that something written 100,100,100 is one number (hundred million one hundred thousand hundred) and will want to remove the commas. Also, when you save the file as .csv, be sure to specify that it must be TAB-separated and not COMMA-separated.
</p>
<div style="clear:both"></div>
</div>
</div>
</div><div class="printfooter">
Online version: "<a dir="ltr" href="https://www.freecadweb.org/wiki/index.php?title=Draft_mapping_files&amp;oldid=100546">http://www.freecadweb.org/wiki/index.php?title=Draft_mapping_files&amp;oldid=100546</a>"</div>
<div id="catlinks" class="catlinks" data-mw="interface"></div><div class="visualClear"></div>
</div>
</div>
<div id="mw-navigation">
<h2>Navigation menu</h2>
</body></html>