View Issue Details

IDProjectCategoryView StatusLast Update
0001619FreeCADBugpublic2014-07-27 12:32
Reporterjessefreecad Assigned Towmayer  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
OSWindowsOS Version7 x64 
Summary0001619: Python script generating 3D model works in V0.13, error in V0.14
DescriptionThe script here:
http://forum.freecadweb.org/viewtopic.php?f=22&t=6881
works in freecad V0.13, but in V0.14 at the line:
"lcdrect.Placement= App.Placement(App.Vector(5.0,4,pcb_thickness+foambox.Height),App.Rotation(0,0,0,1))"
I get this error reported in the python console:
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: First arg must be Quantity
Steps To Reproduceload python script posted into freecad
Additional InformationThis could easily be a coding error that somehow worked in V0.13 and is now being flagged in V0.14. If so any info on how to fix the script is appreciated.
TagsNo tags attached.
FreeCAD Information

Activities

normandc

2014-07-17 04:11

manager   ~0004803

Please enquire first on the forum before reporting such problems as a bug. There were changes to the Python Draft API during development of V0.14 to make it compatible with the new units system. I couldn't tell you how to fix your script but I'm pretty sure it's the reason for it not working.

A developer will probably confirm.

wmayer

2014-07-17 09:27

administrator   ~0004808

Last edited: 2014-07-17 09:30

To fix the error write: lcdrect.Placement= App.Placement(App.Vector(5.0,4,pcb_thickness+float(foambox.Height)),App.Rotation(0,0,0,1))

Currently the + and - operators do not allow to mix up quantities and floating numbers but for the <,<=,>,>=,!= and == operators we already do (see the linked change set).

However, I am unsure whether it's a good idea to support this because it might cause some confusion.

Example:
l = App.Units.Quantity("1m")
d = 5
l + d # this would give "1.005 m" and not "6 m" as some people may expect

The point is that the internally stored number of a quantity is ALWAYS given in FreeCAD's standard unit system which is in (mm,kg,s,deg)

Btw, the reason why it worked in 0.13 is that the unit system wasn't activated and the appropriate property classes returned real floating numbers and not a quantity.

wmayer

2014-07-27 12:14

administrator   ~0004859

I think it's best NOT to allow any mixture of units and floating numbers (for + and - operator) as this can cause many kind of ambiguities. There is now a better error message which gives the script coder a hint what to do.

Related Changesets

FreeCAD: master 8aec46fb

2014-07-14 17:17:41

wmayer

Details Diff
+ support comparison with double in quantity number protocol Affected Issues
0001619
mod - src/App/Application.cpp Diff File
mod - src/Base/QuantityPyImp.cpp Diff File

FreeCAD: master a1da4bb4

2014-07-27 14:08:31

wmayer

Details Diff
+ fixes 0001619: Python script generating 3D model works in V0.13, error in V0.14 Affected Issues
0001619
mod - src/Base/Quantity.cpp Diff File
mod - src/Base/QuantityPyImp.cpp Diff File

Issue History

Date Modified Username Field Change
2014-07-17 03:32 jessefreecad New Issue
2014-07-17 04:11 normandc Note Added: 0004803
2014-07-17 09:04 wmayer Changeset attached => FreeCAD Master master 8aec46fb
2014-07-17 09:27 wmayer Note Added: 0004808
2014-07-17 09:30 wmayer Note Edited: 0004808
2014-07-27 12:14 wmayer Note Added: 0004859
2014-07-27 12:32 wmayer Changeset attached => FreeCAD Master master a1da4bb4
2014-07-27 12:32 wmayer Assigned To => wmayer
2014-07-27 12:32 wmayer Status new => closed
2014-07-27 12:32 wmayer Resolution open => fixed