Message 1 of 2
Enviroment Not supported error: creating a construction point

Not applicable
06-06-2016
12:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to create a construction point at the rough center of a component using the center point of the Components Bounding box.
When I try to create the point I get "RuntimeTimeError 3: Enviroment is not supported".
What does this mean and how can it be avoided. I need a point at center of the component in order to "blow it out" but I cannot find away to access this and use it as an origin for the scale. Please reference the code below:
#Author- #Description- import adsk.core, adsk.fusion, adsk.cam, traceback ui = None def generatePrototypeGeometry(root, scale =1.2, faces =[]): occurencesOfCopy = root.allOccurrencesByComponent(root) occ =occurencesOfCopy.item(0) collection = adsk.core.ObjectCollection.create() for body in root.bRepBodies: collection.add(body) bounding = root.boundingBox constructionPoints = root.constructionPoints scalePointInput = constructionPoints.createInput() scalePointInput.setByPoint(adsk.core.Point3D.create((bounding.maxPoint.x-bounding.minPoint.x)/2,(bounding.maxPoint.z-bounding.minPoint.z)/2, (bounding.maxPoint.z-bounding.minPoint.z)/2)) scalePoint = constructionPoints.add(scalePointInput) scalePoint = scalePoint.createForAssemblyContext(occ) scales = root.features.scaleFeatures scaleFactor = adsk.core.ValueInput.createByReal(scale) scaleUniformInput = scales.createInput(collection, scalePoint, scaleFactor) scales.add(scaleUniformInput) dist = bounding.minPoint.distanceTo(bounding.maxPoint) distance = adsk.core.ValueInput.createByReal(dist) extrudes = root.features.extrudeFeatures for face in faces: extInput = extrudes.createInput(face, adsk.fusion.FeatureOperations.CutFeatureOperation) extInput.setDistanceExtent(False, distance) extrudes.add(extInput) def run(context): try: app = adsk.core.Application.get() global ui ui = app.userInterface product = app.activeProduct design = adsk.fusion.Design.cast(product) root = design.rootComponent faces = [root.bRepBodies.item(0).faces.item(0)] generatePrototypeGeometry(root, 1.2, faces) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))