Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

NurbsCurve3D.extract always throws exception

3 REPLIES 3
Reply
Message 1 of 4
JesusFreke
220 Views, 3 Replies

NurbsCurve3D.extract always throws exception

When I try to call the extract method on a NurbsCurve3D object,  I get a RuntimeError with the message "RuntimeError: 3 : invalid argument startParam".

 

For example:

import adsk.core
import adsk.fusion
import traceback

def run(_):
try:
brep = adsk.fusion.TemporaryBRepManager.get()

cylinder = brep.createCylinderOrCone(
adsk.core.Point3D.create(0, 0, 0),
1,
adsk.core.Point3D.create(0, 0, 1),
1)

for face in cylinder.faces:
if isinstance(face.geometry, adsk.core.Plane):
nurbs = face.edges[0].geometry.asNurbsCurve
print(nurbs.evaluator.getParameterExtents())
extracted = nurbs.extract(1.0, 2.0)
print(extracted)
except Exception as ex:
print(traceback.format_exc())

 

which results in:

 

 

[True, 0.0, 6.283185307179586]
Traceback (most recent call last):
File "[...]\test.py", line 36, in run
extracted = nurbs.extract(1.0, 2.0)
File "[...]/AppData/Local/Autodesk/webdeploy/production/c23c4c7ff2652eaacfec153295bbc3d6e4b9657f/Api/Python/packages\adsk\core.py", line 24329, in extract
return _core.NurbsCurve3D_extract(self, *args)
RuntimeError: 3 : invalid argument startParam

The above exception was the direct cause of the following exception:

SystemError: <built-in function delete_BRepFaces> returned a result with an error set

 

 

Seems like a bug in the API? 

3 REPLIES 3
Message 2 of 4
MichaelT_123
in reply to: JesusFreke

Hi Mr. JesusFreke,

 

Is it a bug?

Might be not...

 

Please, consider to follow the schema:

baseFeature.startEdit()
(your tempBody code)
thisBody      = thisComp.bRepBodies.add( tempBody, baseFeature )
baseFeature.finishEdit()
.....
extracted = nurbs.extract(1.0, 2.0) 
 
Regards
MichaelT
 
MichaelT
Message 3 of 4
JesusFreke
in reply to: MichaelT_123

Were you actually able to get that to work? Because I still get the "invalid argument startParam" exception.

 

import adsk.core
import adsk.fusion
import traceback

def run(_):
app = adsk.core.Application.get()
design: adsk.fusion.Design = app.activeProduct

root: adsk.fusion.Component = design.rootComponent

brep = adsk.fusion.TemporaryBRepManager.get()

base_feature = root.features.baseFeatures.add()
base_feature.startEdit()

try:
cylinder = brep.createCylinderOrCone(
adsk.core.Point3D.create(0, 0, 0),
1,
adsk.core.Point3D.create(0, 0, 1),
1)

cylinder = root.bRepBodies.add(cylinder, base_feature)

for face in cylinder.faces:
if isinstance(face.geometry, adsk.core.Plane):
nurbs = face.edges[0].geometry.asNurbsCurve
print(nurbs.evaluator.getParameterExtents())
extracted = nurbs.extract(1.0, 2.0)
print(extracted)

except Exception:
print(traceback.format_exc())
finally:
base_feature.finishEdit()

 

It also, happens if I finish the base feature before trying to split the spline, and also when the document is in direct mode instead of parametric mode.

Message 4 of 4
BrianEkins
in reply to: JesusFreke

It looks like a bug in the API to me.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report