Message 1 of 3
'NurbsCurve3D.extract' method does not work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there.
If anyone knows, please let me know.(Fusion360 Ver2.0.8335)
I used extract method to get a part of NurbsCurve3D, but I get an error.
The following example creates a partial sketch curve in a new sketch by selecting the on-screen sketch curve (Spline).
import adsk.core, adsk.fusion, traceback
_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)
def run(context):
try:
global _app, _ui
_app = adsk.core.Application.get()
_ui = _app.userInterface
des :adsk.fusion.Design = _app.activeProduct
root :adsk.fusion.Component = des.rootComponent
# select SketchCurve
msg :str = 'Select SketchCurve'
selFiltter :str = 'SketchCurves'
sel :adsk.core.Selection = selectEnt(msg ,selFiltter)
if not sel: return
# get NurbsCurve3D
geo :adsk.core.NurbsCurve3D = sel.entity.geometry
# get Parameter
eva :adsk.core.SurfaceEvaluator = geo.evaluator
_, sPrm, ePrm = eva.getParameterExtents()
print('SelectParameter:{} - {}'.format(sPrm, ePrm))
# new Parameter
unitPrm = (ePrm - sPrm) * 0.25
sPrmNew = sPrm + unitPrm
ePrmNew = sPrm + (unitPrm * 3)
print('NewParameter:{} - {}'.format(sPrmNew, ePrmNew))
# extract
print('hasattr-extract? - {}'.format(hasattr(geo,'extract')))
splitCrv :adsk.core.NurbsCurve3D = geo.extract(sPrm, ePrm) # err!
# https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-979a5453-b28b-42d2-8816-d76b47d4ee24
# draw sketch
skt :adsk.fusion.Sketch = root.sketches.add(root.xYConstructionPlane)
sktFits :adsk.fusion.SketchFittedSplines = skt.sketchCurves.sketchFittedSplines
sktFits.addByNurbsCurve(splitCrv)
except:
if _ui:
_ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def selectEnt(
msg :str,
filtterStr :str) -> adsk.core.Selection :
try:
sel = _ui.selectEntity(msg, filtterStr)
return sel
except:
return None
An error will occur in the extract method.
Is my processing wrong?
I don't know if this is what happened from the previous version.