Message 1 of 5

Not applicable
03-03-2016
01:50 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to rotate a body, (ideally to align to vector). I have some test code that just rotates by 78 degrees along the yAxis at the origin. However it does nothing. Its based on teh Move example code. How do I rotate a body?
import adsk.core, adsk.fusion, traceback def createNewComponent(rootComp): allOccs = rootComp.occurrences newOcc = allOccs.addNewComponent(adsk.core.Matrix3D.create()) return newOcc.component def run(context): ui = None try: app = adsk.core.Application.get() ui = app.userInterface # Create a document. doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType) product = app.activeProduct design = adsk.fusion.Design.cast(product) # Get the root component of the active design. rootComp = createNewComponent(design.rootComponent) ui.messageBox("FirstOrigin: "+ str(rootComp.originConstructionPoint.geometry.asArray())) features = rootComp.features # Create sketch circle on the xz plane. sketches = rootComp.sketches sketch = sketches.add(rootComp.xZConstructionPlane) sketchCircles = sketch.sketchCurves.sketchCircles centerPoint = adsk.core.Point3D.create(0, 0, 0) sketchCircles.addByCenterRadius(centerPoint, 10) # Create a collection of entities for extrude entities0 = adsk.core.ObjectCollection.create() entities0.add(sketch.profiles.item(0)) # Create a cylinder with ExtrudeFeature using the profile above. extrudeFeats = features.extrudeFeatures extrudeFeatureInput = extrudeFeats.createInput(entities0, adsk.fusion.FeatureOperations.NewBodyFeatureOperation) extrudeFeatureInput.isSolid = True extrudeFeatureInput.setDistanceExtent(False, adsk.core.ValueInput.createByReal(2.0)) extrudeFeature = extrudeFeats.add(extrudeFeatureInput) # Create a collection of entities for move entities1 = adsk.core.ObjectCollection.create() entities1.add(rootComp.bRepBodies.item(0)) # Create a transform to do move transform = adsk.core.Matrix3D.create() transform.setToRotation(78,rootComp.yConstructionAxis.geometry.getData()[2],rootComp.originConstructionPoint.geometry) # Create a move feature moveFeats = features.moveFeatures moveFeatureInput = moveFeats.createInput(entities1, transform) moveFeats.add(moveFeatureInput) ui.messageBox("FirstOrigin: "+ str(rootComp.originConstructionPoint.geometry.asArray())) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.