- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I think that this bug is the same as the one reported 5 years ago in this discussion: Creating sketch from baseFeature - aka not parametric - fail to update transform
The following code try to translate a plane according to a direction:
- If direction is set to X => translation of the plane YZ
- If direction is set to Y => translation of the plane XZ
- If direction is set to Z => translation of the plane XY
But if direction is set to 'X' or 'Y', the translation of the plane is incorrect.
- For 'X', instead of translating the YZ plane in the X direction, it translates the XY plane in the X direction
- For 'Y', instead of translating the XZ plane in the Y direction, it translates the XY plane in the Y direction
import adsk.core, adsk.fusion, traceback
def run(context):
try:
direction = 'X'
app = adsk.core.Application.get()
ui = app.userInterface
design = adsk.fusion.Design.cast(app.activeProduct)
rootComponent = design.rootComponent
baseFeats = rootComponent.features.baseFeatures
baseFeat = baseFeats.add()
baseFeat.startEdit()
planes = rootComponent.constructionPlanes
planeInput = planes.createInput()
planeInput.targetBaseOrFormFeature = baseFeat
offset = adsk.core.ValueInput.createByReal(0.0)
if direction.lower() == 'x':
refPlane = rootComponent.yZConstructionPlane
elif direction.lower() == 'y':
refPlane = rootComponent.xZConstructionPlane
elif direction.lower() == 'z':
refPlane = rootComponent.xYConstructionPlane
planeInput.setByOffset(refPlane, offset)
plane = planes.add(planeInput)
transform = adsk.core.Matrix3D.create()
vector = adsk.core.Vector3D.create(0.0, 0.0, 0.0)
if direction.lower() == 'x':
vector.x = 10
elif direction.lower() == 'y':
vector.y = 10
elif direction.lower() == 'z':
vector.z = 10
transform.translation = vector
plane.transform = transform
baseFeat.finishEdit()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
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
Solved! Go to Solution.