View Issue Details

IDProjectCategoryView StatusLast Update
0003066PartDesignBugpublic2017-06-05 15:46
Reportersheinz Assigned Toyorik  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformx86_64OSArch LinuxOS Version4.10.10-1
Product Version0.17 
Fixed in Version0.17 
Summary0003066: Draft clone fails with "name 'Draft' is not defined" if used first time in Draft workbench
DescriptionIt seems like variable Draft is dynamically created when a tool from Draft workbench is used.
But if the first used tool from Draft workbench is Clone it fails with:

Running the Python command 'Draft_Clone' failed:
Traceback (most recent call last):
  File "$HOME/src/freecad-build/Mod/Draft/DraftTools.py", line 4832, in Activated
    self.proceed()
  File "$HOME/src/freecad-build/Mod/Draft/DraftTools.py", line 4841, in proceed
    FreeCADGui.doCommand("Draft.clone(FreeCAD.ActiveDocument."+obj.Name+")")
  File "<string>", line 1, in <module>

name 'Draft' is not defined
After using some other tool from Draft workbench (for example move) clone operation starts to work.
Steps To Reproduce1. New document
2. Create a solid cube in Part workbench.
3. Switch to Draft workbench.
4. Select the cube and clone it.
- Error is generated and clone operation fails.
5. Move the cube.
6. Try to clone the cube one more time. This time it works.
Additional InformationOS: Linux
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.11206 (Git)
Build type: Debug
Branch: master
Hash: 749d666099ce5d201e67917d491c9dad2c0ccf32
Python version: 2.7.13
Qt version: 4.8.7
Coin version: 3.1.3
OCC version: 7.1.0
TagsDraft
FreeCAD Information

Relationships

related to 0003036 closed Draft Draft -> Clone feature doesn't work when you open file directly 

Activities

sheinz

2017-06-02 21:41

reporter   ~0009268

I quickly had a look at the code and adding the following line in method DraftClone.proceed fixes the issue.

FreeCADGui.addModule("Draft")
I'm not sure if it is the right approach or if it is the right place but might be a hint for the developers.
I also included the patch.
freecad_draft_clone.patch (650 bytes)   
diff --git a/src/Mod/Draft/DraftTools.py b/src/Mod/Draft/DraftTools.py
index 079b89928..4d4981da7 100644
--- a/src/Mod/Draft/DraftTools.py
+++ b/src/Mod/Draft/DraftTools.py
@@ -4836,6 +4836,7 @@ class Draft_Clone(Modifier):
             self.view.removeEventCallback("SoEvent",self.call)
         if FreeCADGui.Selection.getSelection():
             l = len(FreeCADGui.Selection.getSelection())
+            FreeCADGui.addModule("Draft")
             FreeCAD.ActiveDocument.openTransaction("Clone")
             for obj in FreeCADGui.Selection.getSelection():
                 FreeCADGui.doCommand("Draft.clone(FreeCAD.ActiveDocument."+obj.Name+")")
freecad_draft_clone.patch (650 bytes)   

Kunda1

2017-06-03 02:04

administrator   ~0009270

Thanks sheinz.
@yorik can you confirm the patch is 'kosher'?

yorik

2017-06-03 02:43

administrator   ~0009272

Good catch! Thanks for the patch @sheinz

yorik

2017-06-03 02:45

administrator   ~0009273

Fixed in master. Source integration doesn't work anymore...

Kunda1

2017-06-03 15:13

administrator   ~0009275

c:FreeCAD:83095ca574c48e146894df2a7757f6a94659ee0b:
FYI @yorik shell access would be helpful to fix source integration

yorik

2017-06-05 15:46

administrator   ~0009288

I know, I know...

Issue History

Date Modified Username Field Change
2017-06-02 14:54 sheinz New Issue
2017-06-02 14:54 sheinz Tag Attached: Draft
2017-06-02 15:36 Kunda1 Description Updated
2017-06-02 15:37 Kunda1 Relationship added related to 0003036
2017-06-02 21:41 sheinz File Added: freecad_draft_clone.patch
2017-06-02 21:41 sheinz Note Added: 0009268
2017-06-03 02:04 Kunda1 Note Added: 0009270
2017-06-03 02:43 yorik Note Added: 0009272
2017-06-03 02:45 yorik Note Added: 0009273
2017-06-03 02:46 yorik Assigned To => yorik
2017-06-03 02:46 yorik Status new => closed
2017-06-03 02:46 yorik Resolution open => fixed
2017-06-03 02:46 yorik Fixed in Version => 0.17
2017-06-03 15:13 Kunda1 Note Added: 0009275
2017-06-05 15:46 yorik Note Added: 0009288