Message 1 of 4
python api rectangular pattern get warning: Reference Failures, Failed to get owner occurrence transform
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to make a script for fusion360 to generate scaffolding(some tubes pattern with component structure); But when the final step(rectangular pattern) is done I got the warning: Reference Failures, Failed to get owner occurrence transform; I also create a simple test script trying to identify the problem, and I find that the issues only happened when the activeComponent is not the rootComponent. I need some advice to figure out the problem and avoid this.
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = adsk.fusion.Design.cast(app.activeProduct)
# get the active component of the design
activeComp = design.activeComponent
# create a new sub component
subOccs = activeComp.occurrences.addNewComponent(adsk.core.Matrix3D.create())
subComp = subOccs.component
subComp.name = "subComp"
# draw a circle in the new component
sketches = subComp.sketches
xyPlane = subComp.xYConstructionPlane
sketche = sketches.add(xyPlane)
sketche.sketchCurves.sketchCircles.addByCenterRadius(
adsk.core.Point3D.create(0, 0, 0), 1
)
profile = sketche.profiles.item(0)
# create an extrusion
extInput = subComp.features.extrudeFeatures.createInput(
profile, adsk.fusion.FeatureOperations.NewBodyFeatureOperation
)
distance = adsk.core.ValueInput.createByReal(1)
extInput.setDistanceExtent(False, distance)
subComp.features.extrudeFeatures.add(extInput)
# retangle pattern the sub component
inputEntities = adsk.core.ObjectCollection.create()
inputEntities.add(subOccs)
quantityOne = adsk.core.ValueInput.createByReal(2)
quantityTwo = adsk.core.ValueInput.createByReal(2)
distanceOne = adsk.core.ValueInput.createByReal(2)
distanceTwo = adsk.core.ValueInput.createByReal(2)
rectangPatternFeats = subComp.features.rectangularPatternFeatures
rectangPatternFeatInput = rectangPatternFeats.createInput(
inputEntities,
subComp.zConstructionAxis,
quantityOne,
distanceOne,
adsk.fusion.PatternDistanceType.SpacingPatternDistanceType,
)
rectangPatternFeatInput.setDirectionTwo(
subComp.xConstructionAxis, quantityTwo, distanceTwo
)
rectangPatternFeats.add(rectangPatternFeatInput)
except:
if ui:
ui.messageBox("Failed:\n{}".format(traceback.format_exc()))