sweep works on rootComponent but not on newOccuranceComponent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Ich habe im folgenden Code ein möglichst einfaches Sweep erstellt (ein Kreis entlang eines geraden Pfades), um dem Fehler auf die Spur zu kommen. Es funktioniert auf der root Component, wenn ich Zeile 15 aktiviere. Ich will es aber auf der new_occurrence.component zum funktionieren bringen. Eine einfache Extrusion klappt, aber das Sweep bringt folgenden Fehler:
..... line 24, in run
path = adsk.fusion.Path.create(pathLine, chainedOption)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File .....line 37652, in create
return _fusion.Path_create(curves, chainOptions)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: 2 : InternalValidationError : Utils::getObjectPath(obj.get(), objPath, nullptr, contextPath)
Hier mein Code:
import adsk.core, adsk.fusion, traceback
def run(context😞
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
new_occurrence = design.rootComponent.occurrences.addNewComponent(adsk.core.Matrix3D.create())
comp = new_occurrence.component
comp.isActive = True
#comp = design.rootComponent
# create pathline
path_sketch = comp.sketches.add(comp.xYConstructionPlane)
pathLine = path_sketch.sketchCurves.sketchLines.addByTwoPoints(adsk.core.Point3D.create(0,0,0), adsk.core.Point3D.create(9,0,0))
feats = comp.features
chainedOption = adsk.fusion.ChainedCurveOptions.connectedChainedCurves
if adsk.fusion.BRepEdge.cast(pathLine😞
chainedOption = adsk.fusion.ChainedCurveOptions.tangentChainedCurves
path = adsk.fusion.Path.create(pathLine, chainedOption)
path = feats.createPath(pathLine)
# create circle-profile
radius = 2.5
profile_sketch = comp.sketches.add(comp.yZConstructionPlane)
center = comp.yZConstructionPlane.geometry.origin
center = profile_sketch.modelToSketchSpace(center)
profile_sketch.sketchCurves.sketchCircles.addByCenterRadius(center, radius)
profile = profile_sketch.profiles[0]
# create sweep
sweepFeats = feats.sweepFeatures
sweepInput = sweepFeats.createInput(profile, path, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
sweepInput.orientation = adsk.fusion.SweepOrientationTypes.PerpendicularOrientationType
sweepFeat = sweepFeats.add(sweepInput)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Link copied