Failed to parse expression in windows

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
ebrahim raeyat
Posts: 185
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

Failed to parse expression in windows

Postby ebrahim raeyat » Mon Oct 07, 2019 7:04 pm

for parsing expression in FreeCAD, i found when i add dot(.) before property in windows os, it sounds an error, but it works in linux, this is my script:

Code: Select all

import Sketcher
import FreeCAD
import Draft
import Part


xcoord = 0
yc = 0
r = 1
text = 'A'

doc = App.newDocument()

sketch = doc.addObject('Sketcher::SketchObject', 'x_sketch')
g4 = sketch.addGeometry(Part.Circle(FreeCAD.Vector(xcoord, yc, 0), FreeCAD.Vector(0, 0, 1), r), False)
t = Draft.makeText(text, FreeCAD.Vector(xcoord, yc, 0))

const_num = sketch.addConstraint(Sketcher.Constraint('DistanceX', -1, 1, g4, 3, xcoord))
sketch.renameConstraint(const_num, f'x_{text}')
sketch.toggleDriving(const_num)
t.setExpression('.Placement.Base.x', f'{sketch.Name}.Constraints.x_{text}')


const_num = sketch.addConstraint(Sketcher.Constraint('DistanceY', -1, 1, g4, 3, yc))
sketch.renameConstraint(const_num, f'y_{text}')
sketch.toggleDriving(const_num)
t.setExpression('Placement.Base.y', f'{sketch.Name}.Constraints.y_{text}')
please note dot (.) before Placement for x constraints and not for y.

FreeCAD prop:

Code: Select all

OS: Ubuntu 18.04.2 LTS (ubuntu:GNOME/ubuntu)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18227 (Git)
Build type: Release
Branch: master
Hash: a374ecc8ef2abf38b146a1013a0f9700d1cb5fe9
Python version: 3.7.3
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United States (en_US)

Code: Select all

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17505 (Git)
Build type: Release
Branch: master
Hash: 755536e9df94d2d39da1468420f1fd333c35da7a
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)