Merge branch 'master' of ssh://git.code.sf.net/p/free-cad/code

This commit is contained in:
wmayer 2014-03-14 15:29:26 +01:00
commit f0b54d3ee5
10 changed files with 1012 additions and 826 deletions

View File

@ -116,8 +116,10 @@ class ArchWorkbench(Workbench):
if hasattr(FreeCADGui,"draftToolBar"):
if not hasattr(FreeCADGui.draftToolBar,"loadedPreferences"):
FreeCADGui.addPreferencePage(":/ui/userprefs-base.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/userprefs-snap.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/userprefs-visual.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/userprefs-import.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/userprefs-import1.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/userprefs-import2.ui","Draft")
FreeCADGui.draftToolBar.loadedPreferences = True
Log ('Loading Arch module... done\n')

File diff suppressed because one or more lines are too long

View File

@ -134,8 +134,10 @@ class DraftWorkbench (Workbench):
if hasattr(FreeCADGui,"draftToolBar"):
if not hasattr(FreeCADGui.draftToolBar,"loadedPreferences"):
FreeCADGui.addPreferencePage(":/ui/userprefs-base.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/userprefs-snap.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/userprefs-visual.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/userprefs-import.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/userprefs-import1.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/userprefs-import2.ui","Draft")
FreeCADGui.draftToolBar.loadedPreferences = True
Log ('Loading Draft module...done\n')

View File

@ -94,7 +94,9 @@
<file>translations/Draft_ro.qm</file>
<file>translations/Draft_pt-PT.qm</file>
<file>ui/userprefs-base.ui</file>
<file>ui/userprefs-import.ui</file>
<file>ui/userprefs-snap.ui</file>
<file>ui/userprefs-import1.ui</file>
<file>ui/userprefs-import2.ui</file>
<file>ui/userprefs-visual.ui</file>
</qresource>
</RCC>

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>718</width>
<height>808</height>
<width>487</width>
<height>455</height>
</rect>
</property>
<property name="windowTitle">
@ -358,243 +358,6 @@ Values with differences below this value will be treated as same.</string>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Snapping</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox">
<property name="toolTip">
<string>If this is checked, snapping is activated without the need to press the snap mod key</string>
</property>
<property name="text">
<string>Always snap (disable snap mod)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>alwaysSnap</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_20">
<property name="text">
<string>Constrain mod</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::PrefComboBox" name="gui::prefcombobox_5">
<property name="toolTip">
<string>The Constraining modifier key</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>modconstrain</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<item>
<property name="text">
<string>shift</string>
</property>
</item>
<item>
<property name="text">
<string>ctrl</string>
</property>
</item>
<item>
<property name="text">
<string>alt</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_21">
<property name="text">
<string>Snap mod</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::PrefComboBox" name="gui::prefcombobox_6">
<property name="toolTip">
<string>The snap modifier key</string>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>modsnap</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<item>
<property name="text">
<string>shift</string>
</property>
</item>
<item>
<property name="text">
<string>ctrl</string>
</property>
</item>
<item>
<property name="text">
<string>alt</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_22">
<property name="text">
<string>Alt mod</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::PrefComboBox" name="gui::prefcombobox_7">
<property name="toolTip">
<string>The alt modifier key</string>
</property>
<property name="currentIndex">
<number>2</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>modalt</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<item>
<property name="text">
<string>shift</string>
</property>
</item>
<item>
<property name="text">
<string>ctrl</string>
</property>
</item>
<item>
<property name="text">
<string>alt</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_21">
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_7">
<property name="toolTip">
<string>If checked, the Snap toolbar will be shown whenever you use snapping</string>
</property>
<property name="text">
<string>Show Draft Snap toolbar</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>showSnapBar</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_9">
<property name="text">
<string>Hide Draft snap toolbar after use</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>hideSnapBar</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<zorder></zorder>
<zorder></zorder>
<zorder></zorder>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
@ -730,22 +493,5 @@ Values with differences below this value will be treated as same.</string>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>gui::prefcheckbox_7</sender>
<signal>clicked(bool)</signal>
<receiver>gui::prefcheckbox_9</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>158</x>
<y>290</y>
</hint>
<hint type="destinationlabel">
<x>400</x>
<y>293</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>

View File

@ -6,12 +6,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>575</width>
<height>679</height>
<width>496</width>
<height>524</height>
</rect>
</property>
<property name="windowTitle">
<string>Import/Export</string>
<string>DXF / DWG options</string>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
@ -32,71 +32,6 @@
<property name="margin">
<number>9</number>
</property>
<item>
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="textLabel1_3">
<property name="text">
<string>Import style</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefComboBox" name="gui::prefcombobox">
<property name="toolTip">
<string>This is the method choosed for importing or translating DXF object color into FreeCAD.
If color mapping is choosed, you must choose a color mapping file containing a translation table that will convert colors into linewidths.
</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>dxfstyle</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<item>
<property name="text">
<string>None (fastest)</string>
</property>
</item>
<item>
<property name="text">
<string>Use default color and linewidth</string>
</property>
</item>
<item>
<property name="text">
<string>Original color and linewidth</string>
</property>
</item>
<item>
<property name="text">
<string>Color mapped to linewidth</string>
</property>
</item>
<item>
<property name="text">
<string>Create parametric objects</string>
</property>
</item>
<item>
<property name="text">
<string>Create Sketches</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
@ -170,60 +105,59 @@ If color mapping is choosed, you must choose a color mapping file containing a t
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Max Spline Segment</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefSpinBox" name="gui::prefspinbox_2">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>When exporting splines to DXF, they are transformed in polylines. This value is the maximum length of each of the polyline segments. If 0, then the whole spline is treated as a straight segment.</string>
</property>
<property name="value">
<number>5</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>maxsplinesegment</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayout_15">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Color mapping file</string>
<string>Create</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefFileChooser" name="gui::preffilechooser">
<property name="minimumSize">
<size>
<width>300</width>
<height>0</height>
</size>
</property>
<widget class="Gui::PrefRadioButton" name="radioButton">
<property name="toolTip">
<string>The color mapping file for translating dxf colors into linewidths</string>
<string>If thi sis checked, only standard Part objects will be created (fastest)</string>
</property>
<property name="text">
<string>simple Part shapes</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>dxfmappingfile</cstring>
<cstring>dxfCreatePart</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefRadioButton" name="radioButton_2">
<property name="toolTip">
<string>If this is checked, parametric Draft objects will be created whenever possible</string>
</property>
<property name="text">
<string>Draft objects</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>dxfCreateDraft</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefRadioButton" name="radioButton_3">
<property name="toolTip">
<string>If this is checked, sketches will be created whenever possible</string>
</property>
<property name="text">
<string>Sketches</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>dxfCreateSketch</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
@ -233,17 +167,17 @@ If color mapping is choosed, you must choose a color mapping file containing a t
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_5">
<widget class="Gui::PrefCheckBox" name="checkBox_2">
<property name="toolTip">
<string>if this is checked, objects from the same layers will be joined into Draft Blocks, turning the display faster, but making them less easily editable</string>
<string>If this is checked, colors will be retrieved from the DXF objects whenever possible. Otherwise default colors will be applied.</string>
</property>
<property name="text">
<string>Group layers into blocks</string>
<string>Get original colors from the DXF file</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>groupLayers</cstring>
<cstring>dxfGetOriginalColors</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
@ -272,6 +206,26 @@ If color mapping is choosed, you must choose a color mapping file containing a t
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_5">
<property name="toolTip">
<string>if this is checked, objects from the same layers will be joined into Draft Blocks, turning the display faster, but making them less easily editable</string>
</property>
<property name="text">
<string>Group layers into blocks</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>groupLayers</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
@ -380,7 +334,7 @@ If color mapping is choosed, you must choose a color mapping file containing a t
<string>Ellipse export is badly supported. Use this to export them as polylines instead.</string>
</property>
<property name="text">
<string>Treat ellipses and splines as polylines (using Max Spline Segment value)</string>
<string>Treat ellipses and splines as polylines</string>
</property>
<property name="checked">
<bool>true</bool>
@ -393,6 +347,38 @@ If color mapping is choosed, you must choose a color mapping file containing a t
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Max Spline Segment: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefSpinBox" name="gui::prefspinbox_2">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>When exporting splines to DXF, they are transformed in polylines. This value is the maximum length of each of the polyline segments. If 0, then the whole spline is treated as a straight segment.</string>
</property>
<property name="value">
<number>5</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>maxsplinesegment</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -431,183 +417,6 @@ If color mapping is choosed, you must choose a color mapping file containing a t
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="GroupBox12_2">
<property name="title">
<string>SVG format options</string>
</property>
<layout class="QVBoxLayout" name="_3">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>9</number>
</property>
<item>
<layout class="QHBoxLayout" name="_4">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="textLabel1_5">
<property name="text">
<string>Import style</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::PrefComboBox" name="gui::prefcombobox_3">
<property name="toolTip">
<string>This is the method choosed for importing SVG object color into FreeCAD.</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>svgstyle</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<item>
<property name="text">
<string>None (fastest)</string>
</property>
</item>
<item>
<property name="text">
<string>Use default color and linewidth</string>
</property>
</item>
<item>
<property name="text">
<string>Original color and linewidth</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Export Style</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefComboBox" name="svg_export_style_combobox">
<property name="toolTip">
<string>Style of SVG file to write when exporting a Sketch.</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>svg_export_style</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<item>
<property name="text">
<string>Translated (for print &amp; display)</string>
</property>
</item>
<item>
<property name="text">
<string>Raw (for CAM)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_6">
<property name="toolTip">
<string>When exporting SVG views, make all white linework appear in black, for better readability against white backgrounds</string>
</property>
<property name="text">
<string>Translate white line color to black</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>SvgLinesBlack</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="GroupBox12_3">
<property name="title">
<string>OCA format options</string>
</property>
<layout class="QVBoxLayout" name="_6">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>9</number>
</property>
<item>
<layout class="QHBoxLayout" name="_7">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_4">
<property name="toolTip">
<string>Check this if you want the areas (3D faces) to be imported too.</string>
</property>
<property name="text">
<string>Import OCA areas</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>ocaareas</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
@ -642,13 +451,13 @@ If color mapping is choosed, you must choose a color mapping file containing a t
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<class>Gui::PrefRadioButton</class>
<extends>QRadioButton</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefComboBox</class>
<extends>QComboBox</extends>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>

View File

@ -0,0 +1,218 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Gui::Dialog::DlgSettingsDraft</class>
<widget class="QWidget" name="Gui::Dialog::DlgSettingsDraft">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>504</width>
<height>370</height>
</rect>
</property>
<property name="windowTitle">
<string>SVG / OCA options</string>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>9</number>
</property>
<item>
<widget class="QGroupBox" name="GroupBox12_2">
<property name="title">
<string>SVG format options</string>
</property>
<layout class="QVBoxLayout" name="_3">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>9</number>
</property>
<item>
<layout class="QHBoxLayout" name="_4">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="textLabel1_5">
<property name="text">
<string>Import style</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefComboBox" name="gui::prefcombobox_3">
<property name="toolTip">
<string>This is the method choosed for importing SVG object color into FreeCAD.</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>svgstyle</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<item>
<property name="text">
<string>None (fastest)</string>
</property>
</item>
<item>
<property name="text">
<string>Use default color and linewidth</string>
</property>
</item>
<item>
<property name="text">
<string>Original color and linewidth</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Export style</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefComboBox" name="svg_export_style_combobox">
<property name="toolTip">
<string>Style of SVG file to write when exporting a Sketch.</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>svg_export_style</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<item>
<property name="text">
<string>Translated (for print &amp; display)</string>
</property>
</item>
<item>
<property name="text">
<string>Raw (for CAM)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_6">
<property name="toolTip">
<string>When exporting SVG views, make all white linework appear in black, for better readability against white backgrounds</string>
</property>
<property name="text">
<string>Translate white line color to black</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>SvgLinesBlack</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="GroupBox12_3">
<property name="title">
<string>OCA format options</string>
</property>
<layout class="QVBoxLayout" name="_6">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>9</number>
</property>
<item>
<layout class="QHBoxLayout" name="_7">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_4">
<property name="toolTip">
<string>Check this if you want the areas (3D faces) to be imported too.</string>
</property>
<property name="text">
<string>Import OCA areas</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>ocaareas</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefComboBox</class>
<extends>QComboBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,474 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Gui::Dialog::DlgSettingsDraft</class>
<widget class="QWidget" name="Gui::Dialog::DlgSettingsDraft">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>492</width>
<height>432</height>
</rect>
</property>
<property name="windowTitle">
<string>Snapping settings</string>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>9</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Snapping</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox">
<property name="toolTip">
<string>If this is checked, snapping is activated without the need to press the snap mod key</string>
</property>
<property name="text">
<string>Always snap (disable snap mod)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>alwaysSnap</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_20">
<property name="text">
<string>Constrain mod</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::PrefComboBox" name="gui::prefcombobox_5">
<property name="toolTip">
<string>The Constraining modifier key</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>modconstrain</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<item>
<property name="text">
<string>shift</string>
</property>
</item>
<item>
<property name="text">
<string>ctrl</string>
</property>
</item>
<item>
<property name="text">
<string>alt</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_21">
<property name="text">
<string>Snap mod</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::PrefComboBox" name="gui::prefcombobox_6">
<property name="toolTip">
<string>The snap modifier key</string>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>modsnap</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<item>
<property name="text">
<string>shift</string>
</property>
</item>
<item>
<property name="text">
<string>ctrl</string>
</property>
</item>
<item>
<property name="text">
<string>alt</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_22">
<property name="text">
<string>Alt mod</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::PrefComboBox" name="gui::prefcombobox_7">
<property name="toolTip">
<string>The alt modifier key</string>
</property>
<property name="currentIndex">
<number>2</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>modalt</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<item>
<property name="text">
<string>shift</string>
</property>
</item>
<item>
<property name="text">
<string>ctrl</string>
</property>
</item>
<item>
<property name="text">
<string>alt</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_21">
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_7">
<property name="toolTip">
<string>If checked, the Snap toolbar will be shown whenever you use snapping</string>
</property>
<property name="text">
<string>Show Draft Snap toolbar</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>showSnapBar</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_9">
<property name="text">
<string>Hide Draft snap toolbar after use</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>hideSnapBar</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<zorder></zorder>
<zorder></zorder>
<zorder></zorder>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Grid</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QLabel" name="label_16">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Main lines every</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::PrefSpinBox" name="gui::prefspinbox_4">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Mainlines will be drawn thicker. Specify here how many squares between mainlines.</string>
</property>
<property name="value">
<number>10</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>gridEvery</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLabel" name="label_15">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Grid spacing</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::PrefDoubleSpinBox" name="gui::prefdoublespinbox_3">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>The spacing between each grid line</string>
</property>
<property name="decimals">
<number>4</number>
</property>
<property name="maximum">
<double>9999.989999999999782</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>gridSpacing</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_10">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>If checked, the Draft grid will always be visible when the Draft workbench is active. Otherwise only when using a command</string>
</property>
<property name="text">
<string>Always show the grid</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>alwaysShowGrid</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_2">
<property name="toolTip">
<string>If checked, a grid will appear when drawing</string>
</property>
<property name="text">
<string>Use grid</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>grid</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>Gui::PrefSpinBox</class>
<extends>QSpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefComboBox</class>
<extends>QComboBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>gui::prefcheckbox_7</sender>
<signal>clicked(bool)</signal>
<receiver>gui::prefcheckbox_9</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>158</x>
<y>290</y>
</hint>
<hint type="destinationlabel">
<x>400</x>
<y>293</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>537</width>
<height>702</height>
<height>552</height>
</rect>
</property>
<property name="windowTitle">
@ -376,162 +376,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Grid</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_2">
<property name="toolTip">
<string>If checked, a grid will appear when drawing</string>
</property>
<property name="text">
<string>Use grid</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>grid</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_10">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>If checked, the Draft grid will always be visible when the Draft workbench is active. Otherwise only when using a command</string>
</property>
<property name="text">
<string>Always show the grid</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>alwaysShowGrid</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLabel" name="label_15">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Grid spacing</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::PrefDoubleSpinBox" name="gui::prefdoublespinbox_3">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>The spacing between each grid line</string>
</property>
<property name="decimals">
<number>4</number>
</property>
<property name="maximum">
<double>9999.989999999999782</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>gridSpacing</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QLabel" name="label_16">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Main lines every</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::PrefSpinBox" name="gui::prefspinbox_4">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Mainlines will be drawn thicker. Specify here how many squares between mainlines.</string>
</property>
<property name="value">
<number>10</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>gridEvery</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">

View File

@ -76,7 +76,7 @@ if not libsok:
p = None
p = ArchCommands.download(baseurl+f,force=True)
if not p:
FreeCAD.Console.PrintWarning("Download of dxf libraries failed. Please download them manually from https://github.com/yorikvanhavre/Draft-dxf-importer\n")
FreeCAD.Console.PrintWarning("Download of dxf libraries failed. Please download them manually from\nhttps://github.com/yorikvanhavre/Draft-dxf-importer\nand place them in your macros folder\n")
sys.path.append(FreeCAD.ConfigGet("UserAppData"))
try:
@ -219,13 +219,96 @@ def getMultiplePoints(entity):
points.append(Vector(p[0],p[1],0))
return points
def isBrightBackground():
"checks if the current viewport background is bright"
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View")
if p.GetBool("Gradient"):
c1 = p.GetUnsigned("BackgroundColor2")
c2 = p.GetUnsigned("BackgroundColor3")
r1 = float((c1>>24)&0xFF)
g1 = float((c1>>16)&0xFF)
b1 = float((c1>>8)&0xFF)
r2 = float((c2>>24)&0xFF)
g2 = float((c2>>16)&0xFF)
b2 = float((c2>>8)&0xFF)
v1 = FreeCAD.Vector(r1,g1,b1)
v2 = FreeCAD.Vector(r2,g2,b2)
v = v2.sub(v1)
v.multiply(0.5)
cv = v1.add(v)
else:
c1 = p.GetUnsigned("BackgroundColor")
r1 = float((c1>>24)&0xFF)
g1 = float((c1>>16)&0xFF)
b1 = float((c1>>8)&0xFF)
cv = FreeCAD.Vector(r1,g1,b1)
value = cv.x*.3 + cv.y*.59 + cv.z*.11
if value < 128:
return False
else:
return True
def getGroupColor(dxfobj,index=False):
"get color of bylayer stuff"
name = dxfobj.layer
for table in drawing.tables.get_type("table"):
if table.name == "layer":
for l in table.get_type("layer"):
if l.name == name:
if index:
return l.color
else:
if (l.color == 7) and dxfBrightBackground:
return [0.0,0.0,0.0]
else:
return dxfColorMap.color_map[l.color]
def getColor():
if gui and draftui:
r = float(draftui.color.red()/255.0)
g = float(draftui.color.green()/255.0)
b = float(draftui.color.blue()/255.0)
return (r,g,b,0.0)
else:
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View")
c = params.GetUnsigned("DefaultShapeLineColor",0)
r = float(((c>>24)&0xFF)/255)
g = float(((c>>16)&0xFF)/255)
b = float(((c>>8)&0xFF)/255)
return (r,g,b,0.0)
def formatObject(obj,dxfobj=None):
"applies color and linetype to objects"
if dxfGetColors and dxfobj:
if hasattr(obj.ViewObject,"TextColor"):
if dxfobj.color_index == 256:
cm = getGroupColor(dxfobj)[:3]
else:
cm = dxfColorMap.color_map[dxfobj.color_index]
obj.ViewObject.TextColor = (cm[0],cm[1],cm[2])
elif hasattr(obj.ViewObject,"LineColor"):
if dxfobj.color_index == 256:
cm = getGroupColor(dxfobj)
elif (dxfobj.color_index == 7) and dxfBrightBackground:
cm = [0.0,0.0,0.0]
else:
cm = dxfColorMap.color_map[dxfobj.color_index]
obj.ViewObject.LineColor = (cm[0],cm[1],cm[2],0.0)
else:
if hasattr(obj.ViewObject,"TextColor"):
obj.ViewObject.TextColor = dxfDefaultColor
elif hasattr(obj.ViewObject,"LineColor"):
obj.ViewObject.LineColor = dxfDefaultColor
class fcformat:
# OBSOLETED - TO BE REMOVED
"this contains everything related to color/lineweight formatting"
def __init__(self,drawing):
self.dxf = drawing
params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
self.paramtext = params.GetBool("dxftext")
self.paramstarblocks = params.GetBool("dxfstarblocks")
self.dxflayout = params.GetBool("dxflayouts")
self.paramstyle = params.GetInt("dxfstyle")
self.join = params.GetBool("joingeometry")
@ -374,14 +457,14 @@ def vec(pt):
"returns a rounded Vector from a dxf point"
return FreeCAD.Vector(round(pt[0],prec()),round(pt[1],prec()),round(pt[2],prec()))
def drawLine(line,shapemode=False):
def drawLine(line,forceShape=False):
"returns a Part shape from a dxf line"
if (len(line.points) > 1):
v1=vec(line.points[0])
v2=vec(line.points[1])
if not DraftVecUtils.equals(v1,v2):
try:
if (fmt.paramstyle >= 4) and (not shapemode):
if (dxfCreateDraft or dxfCreateSketch) and (not forceShape):
return Draft.makeWire([v1,v2])
else:
return Part.Line(v1,v2).toShape()
@ -389,7 +472,7 @@ def drawLine(line,shapemode=False):
warn(line)
return None
def drawPolyline(polyline,shapemode=False,num=None):
def drawPolyline(polyline,forceShape=False,num=None):
"returns a Part shape from a dxf polyline"
if (len(polyline.points) > 1):
edges = []
@ -435,7 +518,7 @@ def drawPolyline(polyline,shapemode=False,num=None):
if edges:
try:
width = rawValue(polyline,43)
if width and fmt.renderPolylineWidth:
if width and dxfRenderPolylineWidth:
w = Part.Wire(edges)
w1 = w.makeOffset(width/2)
if polyline.closed:
@ -448,7 +531,7 @@ def drawPolyline(polyline,shapemode=False,num=None):
return w2.cut(w1)
else:
return Part.Face(w1)
elif (fmt.paramstyle >= 4) and (not curves) and (not shapemode):
elif (dxfCreateDraft or dxfCreateSketch) and (not curves) and (not forceShape):
ob = Draft.makeWire(verts)
ob.Closed = polyline.closed
return ob
@ -462,7 +545,7 @@ def drawPolyline(polyline,shapemode=False,num=None):
warn(polyline,num)
return None
def drawArc(arc,shapemode=False):
def drawArc(arc,forceShape=False):
"returns a Part shape from a dxf arc"
v=vec(arc.loc)
firstangle=round(arc.start_angle,prec())
@ -471,7 +554,7 @@ def drawArc(arc,shapemode=False):
circle.Center=v
circle.Radius=round(arc.radius,prec())
try:
if (fmt.paramstyle >= 4) and (not shapemode):
if (dxfCreateDraft or dxfCreateSketch) and (not forceShape):
pl = FreeCAD.Placement()
pl.move(v)
return Draft.makeCircle(arc.radius,pl,False,firstangle,lastangle)
@ -481,14 +564,14 @@ def drawArc(arc,shapemode=False):
warn(arc)
return None
def drawCircle(circle,shapemode=False):
def drawCircle(circle,forceShape=False):
"returns a Part shape from a dxf circle"
v = vec(circle.loc)
curve = Part.Circle()
curve.Radius = round(circle.radius,prec())
curve.Center = v
try:
if (fmt.paramstyle >= 4) and (not shapemode):
if (dxfCreateDraft or dxfCreateSketch) and (not forceShape):
pl = FreeCAD.Placement()
pl.move(v)
return Draft.makeCircle(circle.radius,pl)
@ -500,7 +583,6 @@ def drawCircle(circle,shapemode=False):
def drawEllipse(ellipse):
"returns a Part shape from a dxf arc"
try:
c = vec(ellipse.loc)
start = round(ellipse.start_angle,prec())
@ -515,7 +597,7 @@ def drawEllipse(ellipse):
m = DraftVecUtils.getPlaneRotation(x,y,z)
pl = FreeCAD.Placement(m)
pl.move(c)
if (fmt.paramstyle >= 4) and (not shapemode):
if (dxfCreateDraft or dxfCreateSketch) and (not forceShape):
if (start != 0.0) or ((end != 0.0) or (end != round(math.pi/2,prec()))):
shape = el.toShape(start,end)
shape.Placement = pl
@ -613,7 +695,7 @@ def drawSolid(solid):
warn(solid)
return None
def drawSpline(spline,shapemode=False):
def drawSpline(spline,forceShape=False):
"returns a Part Shape from a dxf spline"
flag = rawValue(spline,70)
if flag == 1:
@ -638,8 +720,8 @@ def drawSpline(spline,shapemode=False):
elif dline[0] == 40:
knots.append(dline[1])
try:
if (fmt.paramstyle == 4) and (not shapemode):
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetBool("DiscretizeEllipses",True):
if (dxfCreateDraft or dxfCreateSketch) and (not forceShape):
if dxfDiscretizeCurves:
ob = Draft.makeWire(verts)
else:
ob = Draft.makeBSpline(verts)
@ -660,7 +742,7 @@ def drawSpline(spline,shapemode=False):
def drawBlock(blockref,num=None,createObject=False):
"returns a shape from a dxf block reference"
if not fmt.paramstarblocks:
if not dxfStarBlocks:
if blockref.name[0] == '*':
return None
if len(blockref.entities.data) == 0:
@ -669,38 +751,38 @@ def drawBlock(blockref,num=None,createObject=False):
#print "creating block ", blockref.name, " containing ", len(blockref.entities.data), " entities"
shapes = []
for line in blockref.entities.get_type('line'):
s = drawLine(line,shapemode=True)
s = drawLine(line,forceShape=True)
if s: shapes.append(s)
for polyline in blockref.entities.get_type('polyline'):
s = drawPolyline(polyline,shapemode=True)
s = drawPolyline(polyline,forceShape=True)
if s: shapes.append(s)
for polyline in blockref.entities.get_type('lwpolyline'):
s = drawPolyline(polyline,shapemode=True)
s = drawPolyline(polyline,forceShape=True)
if s: shapes.append(s)
for arc in blockref.entities.get_type('arc'):
s = drawArc(arc,shapemode=True)
s = drawArc(arc,forceShape=True)
if s: shapes.append(s)
for circle in blockref.entities.get_type('circle'):
s = drawCircle(circle,shapemode=True)
s = drawCircle(circle,forceShape=True)
if s: shapes.append(s)
for insert in blockref.entities.get_type('insert'):
#print "insert ",insert," in block ",insert.block[0]
if fmt.paramstarblocks or insert.block[0] != '*':
if dxfStarBlocks or insert.block[0] != '*':
s = drawInsert(insert)
if s: shapes.append(s)
for solid in blockref.entities.get_type('solid'):
s = drawSolid(solid)
if s: shapes.append(s)
for spline in blockref.entities.get_type('spline'):
s = drawSpline(spline,shapemode=True)
s = drawSpline(spline,forceShape=True)
if s: shapes.append(s)
for text in blockref.entities.get_type('text'):
if fmt.paramtext:
if fmt.dxflayout or (not rawValue(text,67)):
if dxfImportTexts:
if dxfImportLayouts or (not rawValue(text,67)):
addText(text)
for text in blockref.entities.get_type('mtext'):
if fmt.paramtext:
if fmt.dxflayout or (not rawValue(text,67)):
if dxfImportTexts:
if dxfImportLayouts or (not rawValue(text,67)):
print "adding block text",text.value, " from ",blockref
addText(text)
try: shape = Part.makeCompound(shapes)
@ -716,7 +798,7 @@ def drawBlock(blockref,num=None,createObject=False):
return None
def drawInsert(insert,num=None,clone=False):
if fmt.paramtext:
if dxfImportTexts:
attrs = attribs(insert)
for a in attrs:
addText(a,attrib=True)
@ -758,7 +840,7 @@ def drawInsert(insert,num=None,clone=False):
def drawLayerBlock(objlist):
"draws a Draft block with the given shapes or objects"
obj = None
if fmt.paramstyle >= 4:
if (dxfCreateDraft or dxfCreateSketch):
try:
obj = Draft.makeBlock(objlist)
except:
@ -799,7 +881,7 @@ def addObject(shape,name="Shape",layer=None):
if layer:
lay=locateLayer(layer)
lay.addObject(newob)
fmt.formatObject(newob)
formatObject(newob)
return newob
def addText(text,attrib=False):
@ -853,7 +935,7 @@ def addText(text,attrib=False):
if attrot:
Draft.rotate(newob,attrot)
newob.LabelText = val.split("\n")
if gui and draftui and fmt.stdSize:
if gui and draftui and dxfUseStandardSize:
fsize = draftui.fontsize
else:
fsize = float(hgt)*TEXTSCALING
@ -875,7 +957,7 @@ def addText(text,attrib=False):
elif text.alignment in [3,6,9]:
newob.ViewObject.Justification = "Right"
newob.ViewObject.DisplayMode = "World"
fmt.formatObject(newob,text)
formatObject(newob,text)
def addToBlock(obj,layer):
"adds given shape to the layer dict"
@ -886,7 +968,7 @@ def addToBlock(obj,layer):
def processdxf(document,filename):
"this does the translation of the dxf contents into FreeCAD Part objects"
global drawing # for debugging - so drawing is still accessible to python after the script
global drawing # for debugging - so drawing is still accessible to python after the script ran
FreeCAD.Console.PrintMessage("opening "+filename+"...\n")
drawing = dxfReader.readDXF(filename)
global layers
@ -902,11 +984,6 @@ def processdxf(document,filename):
global layerBlocks
layerBlocks = {}
sketch = None
# getting config parameters
global fmt
fmt = fcformat(drawing)
shapes = []
# drawing lines
@ -914,11 +991,11 @@ def processdxf(document,filename):
lines = drawing.entities.get_type("line")
if lines: FreeCAD.Console.PrintMessage("drawing "+str(len(lines))+" lines...\n")
for line in lines:
if fmt.dxflayout or (not rawValue(line,67)):
if dxfImportLayouts or (not rawValue(line,67)):
shape = drawLine(line)
if shape:
if fmt.paramstyle == 5:
if fmt.makeBlocks or fmt.join:
if dxfCreateSketch:
if dxfMakeBlocks or dxfJoin:
if sketch:
shape = Draft.makeSketch(shape,autoconstraints=True,addTo=sketch)
else:
@ -926,16 +1003,16 @@ def processdxf(document,filename):
sketch = shape
else:
shape = Draft.makeSketch(shape,autoconstraints=True)
elif fmt.join:
elif dxfJoin:
if isinstance(shape,Part.Shape):
shapes.append(shape)
else:
shapes.append(shape.Shape)
elif fmt.makeBlocks:
elif dxfMakeBlocks:
addToBlock(shape,line.layer)
else:
newob = addObject(shape,"Line",line.layer)
if gui: fmt.formatObject(newob,line)
if gui: formatObject(newob,line)
# drawing polylines
@ -955,15 +1032,15 @@ def processdxf(document,filename):
FreeCAD.Console.PrintMessage("drawing "+str(len(polylines))+" polylines...\n")
num = 0
for polyline in polylines:
if fmt.dxflayout or (not rawValue(polyline,67)):
if dxfImportLayouts or (not rawValue(polyline,67)):
shape = drawPolyline(polyline,num)
if shape:
if fmt.paramstyle == 5:
if dxfCreateSketch:
if isinstance(shape,Part.Shape):
t = FreeCAD.ActiveDocument.addObject("Part::Feature","Shape")
t.Shape = shape
shape = t
if fmt.makeBlocks or fmt.join:
if dxfMakeBlocks or dxfJoin:
if sketch:
shape = Draft.makeSketch(shape,autoconstraints=True,addTo=sketch)
else:
@ -971,16 +1048,16 @@ def processdxf(document,filename):
sketch = shape
else:
shape = Draft.makeSketch(shape,autoconstraints=True)
elif fmt.join:
elif dxfJoin:
if isinstance(shape,Part.Shape):
shapes.append(shape)
else:
shapes.append(shape.Shape)
elif fmt.makeBlocks:
elif dxfMakeBlocks:
addToBlock(shape,polyline.layer)
else:
newob = addObject(shape,"Polyline",polyline.layer)
if gui: fmt.formatObject(newob,polyline)
if gui: formatObject(newob,polyline)
num += 1
# drawing arcs
@ -988,11 +1065,11 @@ def processdxf(document,filename):
arcs = drawing.entities.get_type("arc")
if arcs: FreeCAD.Console.PrintMessage("drawing "+str(len(arcs))+" arcs...\n")
for arc in arcs:
if fmt.dxflayout or (not rawValue(arc,67)):
if dxfImportLayouts or (not rawValue(arc,67)):
shape = drawArc(arc)
if shape:
if fmt.paramstyle == 5:
if fmt.makeBlocks or fmt.join:
if dxfCreateSketch:
if dxfMakeBlocks or dxfJoin:
if sketch:
shape = Draft.makeSketch(shape,autoconstraints=True,addTo=sketch)
else:
@ -1000,20 +1077,20 @@ def processdxf(document,filename):
sketch = shape
else:
shape = Draft.makeSketch(shape,autoconstraints=True)
elif fmt.join:
elif dxfJoin:
if isinstance(shape,Part.Shape):
shapes.append(shape)
else:
shapes.append(shape.Shape)
elif fmt.makeBlocks:
elif dxfMakeBlocks:
addToBlock(shape,arc.layer)
else:
newob = addObject(shape,"Arc",arc.layer)
if gui: fmt.formatObject(newob,arc)
if gui: formatObject(newob,arc)
# joining lines, polylines and arcs if needed
if fmt.join and shapes:
if dxfJoin and shapes:
FreeCAD.Console.PrintMessage("Joining geometry...\n")
edges = []
for s in shapes:
@ -1027,11 +1104,11 @@ def processdxf(document,filename):
circles = drawing.entities.get_type("circle")
if circles: FreeCAD.Console.PrintMessage("drawing "+str(len(circles))+" circles...\n")
for circle in circles:
if fmt.dxflayout or (not rawValue(circle,67)):
if dxfImportLayouts or (not rawValue(circle,67)):
shape = drawCircle(circle)
if shape:
if fmt.paramstyle == 5:
if fmt.makeBlocks or fmt.join:
if dxfCreateSketch:
if dxfMakeBlocks or dxfJoin:
if sketch:
shape = Draft.makeSketch(shape,autoconstraints=True,addTo=sketch)
else:
@ -1039,11 +1116,11 @@ def processdxf(document,filename):
sketch = shape
else:
shape = Draft.makeSketch(shape,autoconstraints=True)
elif fmt.makeBlocks:
elif dxfMakeBlocks:
addToBlock(shape,circle.layer)
else:
newob = addObject(shape,"Circle",circle.layer)
if gui: fmt.formatObject(newob,circle)
if gui: formatObject(newob,circle)
# drawing solids
@ -1051,14 +1128,14 @@ def processdxf(document,filename):
if solids: FreeCAD.Console.PrintMessage("drawing "+str(len(circles))+" solids...\n")
for solid in solids:
lay = rawValue(solid,8)
if fmt.dxflayout or (not rawValue(solid,67)):
if dxfImportLayouts or (not rawValue(solid,67)):
shape = drawSolid(solid)
if shape:
if fmt.makeBlocks:
if dxfMakeBlocks:
addToBlock(shape,lay)
else:
newob = addObject(shape,"Solid",lay)
if gui: fmt.formatObject(newob,solid)
if gui: formatObject(newob,solid)
# drawing splines
@ -1066,14 +1143,14 @@ def processdxf(document,filename):
if splines: FreeCAD.Console.PrintMessage("drawing "+str(len(splines))+" splines...\n")
for spline in splines:
lay = rawValue(spline,8)
if fmt.dxflayout or (not rawValue(spline,67)):
if dxfImportLayouts or (not rawValue(spline,67)):
shape = drawSpline(spline)
if shape:
if fmt.makeBlocks:
if dxfMakeBlocks:
addToBlock(shape,lay)
else:
newob = addObject(shape,"Spline",lay)
if gui: fmt.formatObject(newob,spline)
if gui: formatObject(newob,spline)
# drawing ellipses
@ -1081,24 +1158,24 @@ def processdxf(document,filename):
if ellipses: FreeCAD.Console.PrintMessage("drawing "+str(len(ellipses))+" ellipses...\n")
for ellipse in ellipses:
lay = rawValue(ellipse,8)
if fmt.dxflayout or (not rawValue(ellipse,67)):
if dxfImportLayouts or (not rawValue(ellipse,67)):
shape = drawEllipse(ellipse)
if shape:
if fmt.makeBlocks:
if dxfMakeBlocks:
addToBlock(shape,lay)
else:
newob = addObject(shape,"Ellipse",lay)
if gui: fmt.formatObject(newob,ellipse)
if gui: formatObject(newob,ellipse)
# drawing texts
if fmt.paramtext:
if dxfImportTexts:
texts = drawing.entities.get_type("mtext")
texts.extend(drawing.entities.get_type("text"))
if texts:
FreeCAD.Console.PrintMessage("drawing "+str(len(texts))+" texts...\n")
for text in texts:
if fmt.dxflayout or (not rawValue(text,67)):
if dxfImportLayouts or (not rawValue(text,67)):
addText(text)
else: FreeCAD.Console.PrintMessage("skipping texts...\n")
@ -1111,7 +1188,7 @@ def processdxf(document,filename):
shape = drawFace(face3d)
if shape:
newob = addObject(shape,"Face",face3d.layer)
if gui: fmt.formatObject(newob,face3d)
if gui: formatObject(newob,face3d)
if meshes: FreeCAD.Console.PrintMessage("drawing "+str(len(meshes))+" 3dmeshes...\n")
for mesh in meshes:
me = drawMesh(mesh)
@ -1120,15 +1197,15 @@ def processdxf(document,filename):
lay = locateLayer(rawValue(mesh,8))
lay.addObject(newob)
newob.Mesh = me
if gui: fmt.formatObject(newob,mesh)
if gui: formatObject(newob,mesh)
# drawing dims
if fmt.paramtext:
if dxfImportTexts:
dims = drawing.entities.get_type("dimension")
FreeCAD.Console.PrintMessage("drawing "+str(len(dims))+" dimensions...\n")
for dim in dims:
if fmt.dxflayout or (not rawValue(dim,67)):
if dxfImportLayouts or (not rawValue(dim,67)):
try:
layer = rawValue(dim,8)
x1 = float(rawValue(dim,10))
@ -1174,8 +1251,8 @@ def processdxf(document,filename):
if gui:
dim.layer = layer
dim.color_index = 256
fmt.formatObject (newob,dim)
if fmt.stdSize and draftui:
formatObject (newob,dim)
if dxfUseStandardSize and draftui:
newob.ViewObject.FontSize = draftui.fontsize
else:
st = rawValue(dim,3)
@ -1185,7 +1262,7 @@ def processdxf(document,filename):
# drawing points
if fmt.importPoints:
if dxfImportPoints:
points = drawing.entities.get_type("point")
if points: FreeCAD.Console.PrintMessage("drawing "+str(len(points))+" points...\n")
for point in points:
@ -1193,8 +1270,8 @@ def processdxf(document,filename):
y = rawValue(point,20)
z = rawValue(point,30)
lay = rawValue(point,8)
if fmt.dxflayout or (not rawValue(point,67)):
if fmt.makeBlocks:
if dxfImportLayouts or (not rawValue(point,67)):
if dxfMakeBlocks:
shape = Part.Vertex(x,y,z)
addToBlock(shape,lay)
else:
@ -1202,66 +1279,66 @@ def processdxf(document,filename):
lay = locateLayer(lay)
lay.addObject(newob)
if gui:
fmt.formatObject(newob,point)
formatObject(newob,point)
else:
FreeCAD.Console.PrintMessage("skipping points...\n")
# drawing leaders
if fmt.paramtext:
if dxfImportTexts:
leaders = drawing.entities.get_type("leader")
if leaders:
FreeCAD.Console.PrintMessage("drawing "+str(len(leaders))+" leaders...\n")
for leader in leaders:
if fmt.dxflayout or (not rawValue(leader,67)):
if dxfImportLayouts or (not rawValue(leader,67)):
points = getMultiplePoints(leader)
newob = Draft.makeWire(points)
lay = locateLayer(rawValue(leader,8))
lay.addObject(newob)
if gui:
newob.ViewObject.EndArrow = True
fmt.formatObject(newob,leader)
formatObject(newob,leader)
else:
FreeCAD.Console.PrintMessage("skipping leaders...\n")
# drawing hatches
if fmt.importDxfHatches:
if dxfImportHatches:
hatches = drawing.entities.get_type("hatch")
if hatches:
FreeCAD.Console.PrintMessage("drawing "+str(len(hatches))+" hatches...\n")
for hatch in hatches:
if fmt.dxflayout or (not rawValue(hatch,67)):
if dxfImportLayouts or (not rawValue(hatch,67)):
points = getMultiplePoints(hatch)
if len(points) > 1:
lay = rawValue(hatch,8)
points = points[:-1]
newob = None
if (fmt.paramstyle == 0) or fmt.makeBlocks:
if dxfCreatePart or dxfMakeBlocks:
points.append(points[0])
s = Part.makePolygon(points)
if fmt.makeBlocks:
if dxfMakeBlocks:
addToBlock(s,lay)
else:
newob = addObject(s,"Hatch",lay)
if gui:
fmt.formatObject(newob,hatch)
formatObject(newob,hatch)
else:
newob = Draft.makeWire(points)
locateLayer(lay).addObject(newob)
if gui:
fmt.formatObject(newob,hatch)
formatObject(newob,hatch)
else:
FreeCAD.Console.PrintMessage("skipping hatches...\n")
# drawing blocks
inserts = drawing.entities.get_type("insert")
if not fmt.paramstarblocks:
if not dxfStarBlocks:
FreeCAD.Console.PrintMessage("skipping *blocks...\n")
newinserts = []
for i in inserts:
if fmt.dxflayout or (not rawValue(i,67)):
if dxfImportLayouts or (not rawValue(i,67)):
if i.block[0] != '*':
newinserts.append(i)
inserts = newinserts
@ -1269,27 +1346,27 @@ def processdxf(document,filename):
FreeCAD.Console.PrintMessage("drawing "+str(len(inserts))+" blocks...\n")
blockrefs = drawing.blocks.data
for ref in blockrefs:
if fmt.paramstyle >= 4:
if dxfCreateDraft or dxfCreateSketch:
drawBlock(ref,createObject=True)
else:
drawBlock(ref,createObject=False)
num = 0
for insert in inserts:
if (fmt.paramstyle >= 4) and not(fmt.makeBlocks):
if (dxfCreateDraft or dxfCreateSketch) and not(dxfMakeBlocks):
shape = drawInsert(insert,num,clone=True)
else:
shape = drawInsert(insert,num)
if shape:
if fmt.makeBlocks:
if dxfMakeBlocks:
addToBlock(shape,insert.layer)
else:
newob = addObject(shape,"Block."+insert.block,insert.layer)
if gui: fmt.formatObject(newob,insert)
if gui: formatObject(newob,insert)
num += 1
# make blocks, if any
if fmt.makeBlocks:
if dxfMakeBlocks:
print "creating layerblocks..."
for k,l in layerBlocks.iteritems():
shape = drawLayerBlock(l)
@ -1311,7 +1388,6 @@ def processdxf(document,filename):
doc.recompute()
FreeCAD.Console.PrintMessage("successfully imported "+filename+"\n")
if badobjects: print "dxf: ",len(badobjects)," objects were not imported"
del fmt
del doc
del blockshapes
@ -1698,10 +1774,23 @@ def exportPage(page,filename):
tempobj = tempdoc.Objects
export(tempobj,filename,nospline=True,lwPoly=False)
FreeCAD.closeDocument(tempdoc.Name)
# reading parameters
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
dxfCreatePart = p.GetBool("dxfCreatePart",True)
dxfCreateDraft = p.GetBool("dxfCreateDraft",False)
dxfCreateSketch = p.GetBool("dxfCreateSketch",False)
dxfDiscretizeCurves = p.GetBool("DiscretizeEllipses",True)
dxfStarBlocks = p.GetBool("dxfstarblocks",False)
dxfMakeBlocks = p.GetBool("groupLayers",False)
dxfJoin = p.GetBool("joingeometry",False)
dxfRenderPolylineWidth = p.GetBool("renderPolylineWidth",False)
dxfImportTexts = p.GetBool("dxftext",False)
dxfImportLayouts = p.GetBool("dxflayouts",False)
dxfImportPoints = p.GetBool("dxfImportPoints",False)
dxfImportHatches = p.GetBool("importDxfHatches",False)
dxfUseStandardSize = p.GetBool("dxfStdSize",False)
dxfGetColors = p.GetBool("dxfGetOriginalColors",False)
dxfBrightBackground = isBrightBackground()
dxfDefaultColor = getColor()