getParameterByLength vs. split

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
jbi
Posts: 117
Joined: Sun Apr 24, 2016 3:28 pm

getParameterByLength vs. split

Post by jbi »

Hello,

Something I observed today.

Code: Select all

sf = FreeCADGui.Selection.getSelectionEx()[0]
edge=sf.SubObjects[0]

param=edge.getParameterByLength(edge.Length/4)
pt=edge.valueAt(param)
split_edge=edge.split(param)
split_edge.Edges[0].Length
split_edge.Edges[1].Length
edge.Length/4
yielding:
>>> split_edge.Edges[0].Length
3.4396291030641475
>>> split_edge.Edges[1].Length
16.380574078167562
>>> edge.Length/4
4.955050795307929

In my opinion this methods should yield the same result. Obvious there is a difference of 1.5mm. Any explanation for this behaviour or which method is correct? My edge is a <BSplineCurve object>.

I tested also with a straight edge and there the results are correct (both methods yielding the same result).

OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 32-bit
Version: 0.15.4671 (Git)
Branch: releases/FreeCAD-0-15
Hash: 244b3aef360841646cbfe80a1b225c8b39c8380c
Python version: 2.7.8
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
mario52
Veteran
Posts: 4690
Joined: Wed May 16, 2012 2:13 pm

Re: getParameterByLength vs. split

Post by mario52 »

hi
off topic you must upgrade your FreeCAD https://github.com/FreeCAD/FreeCAD/releases

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
Post Reply