Message 1 of 14
[bug] addByThreePoints method fails to create arc if the 3 points are too close
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
The code below crashes whereas the 3 points are disctinct. Setting the factor value f to 100 solves the issue.
The error message:
RuntimeError: 5 : Some input argument is invalid.
It seems that there is a problem with the precision of the numbers during the computation.
import adsk.core, traceback
p1 = [-0.00047752000000000005, 0.15192502000000002]
p2 = [-0.0006226001152828134, 0.15214303759958947]
p3 = [-0.0006731, 0.1524]
# The code works with f = 100
f = 1
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
product = app.activeProduct
rootComp = product.rootComponent
sketches = rootComp.sketches
sketchesPlane = rootComp.xYConstructionPlane
sketch = sketches.add(sketchesPlane)
arcs = sketch.sketchCurves.sketchArcs
pt1 = adsk.core.Point3D.create(p1[0]*f, p1[1]*f, 0.0)
pt2 = adsk.core.Point3D.create(p2[0]*f, p2[1]*f, 0.0)
pt3 = adsk.core.Point3D.create(p3[0]*f, p3[1]*f, 0.0)
arcs.addByThreePoints(pt1, pt2, pt3)
ui.messageBox('OK')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
The issue occurs when trying to import a geometry from a file.
Here are all the triplets values that failed:
*****
-0.00047752000000000005 0.15192502000000002 0.0
-0.0006226001152828134 0.15214303759958947 0.0
-0.0006731 0.1524 0.0
*****
0.21081746 4.1827069 0.0
0.21083651 4.182706638774926 0.0
0.21085556 4.1827069 0.0
*****
-0.0006731 6.05536 0.0
-0.00047595357441652345 6.055835953574417 0.0
0.0 6.0560331 0.0
*****
0.07552690000000001 6.13156 0.0
0.07572404642558347 6.132035953574417 0.0
0.0762 6.1322331 0.0
*****
0.22860000000000003 6.1322331 0.0
0.22907595357441654 6.132035953574417 0.0
0.2292731 6.13156 0.0
*****
0.47744634 6.06242374 0.0
0.47746294213947027 6.062431160364481 0.0
0.4774793600000001 6.06243898 0.0
*****
0.5225669000000001 6.13156 0.0
0.5227640464255835 6.132035953574417 0.0
0.52324 6.1322331 0.0
*****
0.7518400000000001 6.1322331 0.0
0.7523159535744166 6.132035953574417 0.0
0.7525131 6.13156 0.0
*****
2.32301542 6.10663498 0.0
2.3232331941927846 6.106781307383965 0.0
2.3234904000000003 6.1068331 0.0
*****
2.8391104 6.1068331 0.0
2.8394962006423152 6.106711677988141 0.0
2.8397428600000003 6.10639114 0.0
*****
3.22893182 6.13170732 0.0
3.2291685860022112 6.132085526306413 0.0
3.22958968 6.1322331 0.0
*****
3.5775696800000003 6.1322331 0.0
3.578045633574417 6.132035953574417 0.0
3.5782427800000005 6.13156 0.0
*****
3.58109266 6.11100124 0.0
3.5810981213636035 6.1109835689610295 0.0
3.5811028200000004 6.11096568 0.0
*****
3.5811028200000004 6.11096568 0.0
3.581097665305647 6.1109834386587565 0.0
3.58109266 6.11100124 0.0
*****
3.7292965800000006 6.13156 0.0
3.729493726425584 6.132035953574417 0.0
3.72996968 6.1322331 0.0
*****
3.9598600000000004 6.1322331 0.0
3.960335953574417 6.132035953574417 0.0
3.9605331000000006 6.13156 0.0
*****
4.0284882600000005 6.0564141000000005 0.0
4.02893295481865 6.056200340963728 0.0
4.029113100000001 6.055741 0.0
*****
4.029113100000001 0.1524 0.0
4.029061396913553 0.15214275684889197 0.0
4.02891498 0.15192502000000002 0.0
*****
3.87651498 -0.00047498 0.0
3.8762972058072154 -0.0006213073839646991 0.0
3.87604 -0.0006731 0.0
*****
3.7846 -0.0006731 0.0
3.784124046425583 -0.00047595357441670744 0.0
3.7839269 0.0 0.0
*****
3.1401131000000007 0.0 0.0
3.1399159535744174 -0.0004759535744167994 0.0
3.13944 -0.0006731 0.0
*****
2.9171773 -0.0006731 0.0
2.9168084710412754 -0.0005632027482395946 0.0
2.91656008 -0.00026924 0.0
*****
2.7781173800000003 -0.00026924 0.0
2.777869005845322 -0.0005632285560581688 0.0
2.7775001599999998 -0.0006731 0.0
*****
2.42062 -0.0006731 0.0
2.4201440464255835 -0.00047595357441661544 0.0
2.4199469000000002 0.0 0.0
*****
1.6084931 0.0 0.0
1.6082959535744166 -0.00047595357441666136 0.0
1.60782 -0.0006731 0.0
*****
1.1077092400000002 -0.0006731 0.0
1.1072699286841035 -0.0005096272777208597 0.0
1.10704376 -9.906e-05 0.0
*****
0.70143624 -9.906e-05 0.0
0.7012100848537824 -0.0005096429720839872 0.0
0.70077076 -0.0006731 0.0
*****
0.46099730000000005 -0.0006731 0.0
0.4606284711372198 -0.000563202601607623 0.0
0.4603800800000001 -0.00026924 0.0
*****
0.32193738 -0.00026924 0.0
0.32168900584532195 -0.000563228556058086 0.0
0.32132016 -0.0006731 0.0
*****
0.1524 -0.0006731 0.0
0.15214153574088737 -0.0006215323168355681 0.0
0.15192248 -0.00047498 0.0
*****
Thank you
Jérôme Briot, Freelance engineer - Mechanical design and prototyping
3D Print Plus / Pro | IDF Import | GitHub To Fusion 360 | Tube Bending Data Exchanger | Slice Data Export
Memory Used | Basic Calculator | Check Computer Specifications | Import spline from any CSV file