Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Internal Validation Error: SetByCenter(Sphere Surface)

1 REPLY 1
Reply
Message 1 of 2
nnamfoh
327 Views, 1 Reply

Internal Validation Error: SetByCenter(Sphere Surface)

I get an internal validation when using the setByCenter(Spherical Surphace) method to create a construction point at the center of a sphere. I'm trying to use this in order to create an  effective project body method in the python API. Can anyone explain this error? I've attached the script below. I'm running a test where there is a rectangular prism body, a cylinder body, and a sphere body, then a construction point that is a distance way from them. The basic cylinder and recangular bodies project correctly, however a sphere will make no projection and I can't get the center in order to create the circular projection.

#Author-
#Description-
ui = None

import adsk.core, adsk.fusion, adsk.cam, traceback

def curveProjection(root):
    # Get the sketch named "ProjectTest"
    sketches = root.sketches
    sketch = sketches.itemByName('ProjectTest')
    bodies = root.bRepBodies
    points = root.constructionPoints
    
        # Get the set of currently selected entities.   
    for body in bodies:           
        for face in body.faces:
            if face.geometry.surfaceType == 3:
                centerInput = points.createInput()
                centerInput.setByCenter(face.geometry)
                center = points.add(centerInput)
                radius = face.geometry.radius
                sketch.sketchCurves.sketchCircles.addByCenterRadius(center,radius)
            else:
                sketch.project(face)
def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        global ui
        ui  = app.userInterface
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)
        root = design.rootComponent
        curveProjection(root)
        
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
1 REPLY 1
Message 2 of 2
liujac
in reply to: nnamfoh

Sketch.project supports to project a body since the update of May 25 2016. You may project a body instead of faces to sketch, that supports sphere (sketch.project(body)).


BTW, there are some problems in your script:
1. About the setByCenter method of ConstructionPointInput, the parameter should be a spherical face (sphere or torus), circular edge or sketch arc/circle not geometry.
2. About the the addByCenterRadius method of SketchCircles, the centerPoint parameter should be a SketchPoint or Point3D not ConstructionPoint. If it’s a Point3D, it should be in the sketch space.
The following changes on your script should work.

if face.geometry.surfaceType == 3:
                centerInput = points.createInput()
                centerInput.setByCenter(face)
                center = points.add(centerInput)
                radius = face.geometry.radius
                sketch.sketchCurves.sketchCircles.addByCenterRadius(sketch.modelToSketchSpace(center.geometry),radius)

 

Thanks,

Jack

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report