View Issue Details

IDProjectCategoryView StatusLast Update
0002664PathBugpublic2017-01-09 03:38
Reportersliptonic Assigned Tomlampert  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformlinuxOSmint OS Version(various)
Product Version0.17 
Target Version0.17Fixed in Version0.17 
Summary0002664: created tool object is invalid on first access
Descriptionhttp://pastebin.com/RYyFQpee

When a path tool object is created, an error is thrown the first time the object is accessed. After that, the object behaves normally.
Steps To ReproducePython 2.7.6 (default, Jun 22 2015, 18:01:27)
[GCC 4.8.2] on linux2
Type 'help', 'copyright', 'credits' or 'license' for more information.
>>> import Path
>>> tt = Path.Tooltable()
>>> print tt
Tooltable containing 0 tools
>>> t = Path.Tool()
>>> print t
TypeError: bad argument type for built-in operation
>>> print t
Tool Default tool
>>>
Additional InformationThis is a separate issue but I'll throw it here for comment:
Objects can store a reference to a tooltable:
 obj.addProperty("Path::PropertyTooltable", "Tooltable", "Base", "The tooltable used for this CNC program")

But a tool can only be referred to by tool number which is then used to look up the tool in the tooltable. Can we add the python wrapper so we can store a direct reference to the tool in the operation? Like:

obj.addProperty("Path::PropertyTool", "Tool", "Base", "The tool used for this operation")

TagsNo tags attached.
FreeCAD Information

Activities

sliptonic

2016-08-12 20:12

manager   ~0007266

After rebuilding today, the issue is much improved and doesn't happen anywhere near as often. The following does cause it to occur in the python console.

#This doesn't work
FreeCADGui.doCommand('import Path')
FreeCADGui.doCommand('t = Path.Tool()')
FreeCADGui.doCommand('t.Name = "Bob"')
FreeCADGui.doCommand('print t.Name')
 
#This works fine
snippet = '''
import Path
t = Path.Tool()
t.Name = "Bob"
print t.Name
'''
FreeCADGui.doCommand(snippet)

yorik

2016-10-19 17:10

administrator   ~0007399

Is this still an issue?

This works for me:

FreeCADGui.doCommand('import Path')
FreeCADGui.doCommand('t = Path.Tool()')
FreeCADGui.doCommand('t.Name = "Bob"')
FreeCADGui.doCommand('print t.Name')

as well as the other code snippets in this report

yorik

2016-10-19 17:12

administrator   ~0007400

About your other request, it's possible, but it won't be the same tool as in the tooltable. So I don't think this is what you want. To have a tool that is both a property and inside a tooltable, the only way I see is that everything becomes document object. Then the tool object can be linked to from both a tooltable and an operation.

sliptonic

2016-10-19 20:17

manager   ~0007402

Last edited: 2016-10-19 20:19

I'm still seeing it.

>>> snippet = '''
... import Path
... t = Path.Tool()
... t.Name = "Bob"
... print t.Name
... '''
>>> FreeCADGui.doCommand(snippet)
Bob
>>>
>>> import Path
>>> t = Path.Tool()
>>> t.Name = "Bob"
>>> print t.Name
>>>
>>> #This doesn't work
>>> FreeCADGui.doCommand('import Path')
>>> import Path
>>> FreeCADGui.doCommand('t = Path.Tool()')
>>> t = Path.Tool()
>>> FreeCADGui.doCommand('t.Name = "Bob"')
TypeError: bad argument type for built-in operation
>>> FreeCADGui.doCommand('t.Name = "Bob"')
>>> t.Name = "Bob"
>>>

yorik

2016-10-19 20:34

administrator   ~0007403

still no problem for me... I don't get the TypeError: bad argument type for built-in operation
This error message is a standard python error message... It seems to be complaining that "Bob" is not of a valid type. Strange!

mlampert

2017-01-06 22:25

developer   ~0007567

The simplest case to reproduce is
"t = Path.Tool()<enter>"
"<enter>"

The issue is the initialisation of Tool, disabling that eliminates the error.

The problem is that all arguments are optional, and if an optional argument isn't specified the argument parser does not modify provided pointer. In turn the 0 pointer PyObject can not be used to be converted to a double with PyFloat_AsDouble(ptr).

mlampert

2017-01-09 01:07

developer   ~0007576

fix merged, commit 25fc1d3ddf81c03f31ff8f8a5d460f786d926538

Related Changesets

FreeCAD: master 25fc1d3d

2017-01-07 03:21:53

yorik


Committer: GitHub Details Diff
Merge pull request 0000422 from mlampert/issue-2664

Path: fix for issue 2664
Affected Issues
0002664
mod - src/Mod/Path/App/TooltablePyImp.cpp Diff File

Issue History

Date Modified Username Field Change
2016-08-08 15:06 sliptonic New Issue
2016-08-08 15:06 sliptonic Status new => assigned
2016-08-08 15:06 sliptonic Assigned To => yorik
2016-08-12 20:12 sliptonic Note Added: 0007266
2016-10-19 17:10 yorik Note Added: 0007399
2016-10-19 17:12 yorik Note Added: 0007400
2016-10-19 20:17 sliptonic Note Added: 0007402
2016-10-19 20:19 sliptonic Note Edited: 0007402
2016-10-19 20:34 yorik Note Added: 0007403
2017-01-06 22:05 mlampert Assigned To yorik => mlampert
2017-01-06 22:25 mlampert Note Added: 0007567
2017-01-09 01:07 mlampert Note Added: 0007576
2017-01-09 01:07 mlampert Status assigned => closed
2017-01-09 01:07 mlampert Resolution open => fixed
2017-01-09 01:07 mlampert Fixed in Version => 0.17
2017-01-09 03:38 yorik Changeset attached => FreeCAD Master master 25fc1d3d