Fillet of non simple geometry

Fillet of non simple geometry

ione_ianniruberto
Contributor Contributor
1,041 Views
11 Replies
Message 1 of 12

Fillet of non simple geometry

ione_ianniruberto
Contributor
Contributor

Hi everyone, 

I have a problem with the fillet. I have the geometry in the picture and I want to obtain the fillet as it is in the second image. If i do this using the ui I have no problem, but when I try to obtain the same result with an API script it dosen't work. Even more the code works before but after the latest update it seems to not work anymore and I get the error in the third image. 

If i run the same code without the extrude componet the code works. 

Does someone know how to deal with this? 

Thanks 

Screenshot 2023-06-13 121403.png

Screenshot 2023-06-13 121336.png

Screenshot 2023-06-13 121655.png

0 Likes
Accepted solutions (1)
1,042 Views
11 Replies
Replies (11)
Message 2 of 12

BrianEkins
Mentor
Mentor

This looks very case specific, so anyone will need a model and a simple script that reproduces the problem so we can see exactly what's going on.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 12

ione_ianniruberto
Contributor
Contributor

Thanks for your answer, this is the code: 

import adsk.core, adsk.fusion, adsk.cam, traceback
import os
import numpy as np
import csv

def run(context😞
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        document = adsk.core.Document.cast(app.activeDocument)
        design = adsk.fusion.Design.cast(app.activeProduct)
       
        #get the coordinate of the points of the spline from a txt file
        coordinate = {}

        with open ('C:/Users/ionei/OneDrive/Desktop/TESI/Geometria/Coordinate_punti_spline.txt', 'r' ) as file:
            lines = file.readlines()
            for line in lines:
                variable = line.strip().split(',')
                nome = variable[0]
                coordinatax = variable[1]
                coordinatay = variable[2]
                coordinataz = variable[3]

                coordinate[nome] = (coordinatax, coordinatay, coordinataz)
       

        x0 = float(coordinate['PuntoVALVE'][0])/10
        y0 = float(coordinate['PuntoVALVE'][1])/10
        z0 = float(coordinate['PuntoVALVE'][2])/10

        x1 = float(coordinate['PuntoPolmonare'][0])/10
        y1 = float(coordinate['PuntoPolmonare'][1])/10
        z1 = float(coordinate['PuntoPolmonare'][2])/10

        x2 = float(coordinate['PuntofineASC'][0])/10
        y2 = float(coordinate['PuntofineASC'][1])/10
        z2 = float(coordinate['PuntofineASC'][2])/10

        x3 = float(coordinate['PuntoBCT'][0])/10
        y3 = float(coordinate['PuntoBCT'][1])/10
        z3 = float(coordinate['PuntoBCT'][2])/10

        x4 = float(coordinate['Puntocarotide'][0])/10
        y4 = float(coordinate['Puntocarotide'][1])/10
        z4 = float(coordinate['Puntocarotide'][2])/10

        x5 = float(coordinate['Puntosucclavia'][0])/10
        y5 = float(coordinate['Puntosucclavia'][1])/10
        z5 = float(coordinate['Puntosucclavia'][2])/10

        x6 = float(coordinate['Puntofinearco'][0])/10
        y6 = float(coordinate['Puntofinearco'][1])/10
        z6 = float(coordinate['Puntofinearco'][2])/10

        x7 = float(coordinate['PuntoDISC'][0])/10
        y7 = float(coordinate['PuntoDISC'][1])/10
        z7 = float(coordinate['PuntoDISC'][2])/10

        x8 = float(coordinate['Puntofineaorta'][0])/10
        y8 = float(coordinate['Puntofineaorta'][1])/10 -0.5
        z8 = float(coordinate['Puntofineaorta'][2])/10 -2

       

        rootComp = design.rootComponent
        doc = adsk.core.Document.cast(app.activeDocument)
        dataProject = adsk.core.DataProject.cast(app.data.activeProject)
        sketchnurb = rootComp.sketches.add(rootComp.xYConstructionPlane)

        points = adsk.core.ObjectCollection.create()

        # Define the points the spline with fit through.
        points.add(adsk.core.Point3D.create(x0, y0, z0))
        points.add(adsk.core.Point3D.create(x1, y1, z1 ))
        points.add(adsk.core.Point3D.create(x2,y2, z2))
        points.add(adsk.core.Point3D.create(x3,y3,z3))
        points.add(adsk.core.Point3D.create(x4,y4,z4))
        points.add(adsk.core.Point3D.create(x5, y5,z5))
        points.add(adsk.core.Point3D.create(x6, y6, z6))
        points.add(adsk.core.Point3D.create(x7, y7, z7))
        points.add(adsk.core.Point3D.create(x8, y8, z8))

        spline = sketchnurb.sketchCurves.sketchFittedSplines.add(points)
                       
           
        #planes along the spline  
        planes = rootComp.constructionPlanes
        planeInput = planes.createInput()

        distance0 = adsk.core.ValueInput.createByReal(0.0)
        planeInput.setByDistanceOnPath(spline, distance0)
        plane0 = planes.add(planeInput)

        distance1 = adsk.core.ValueInput.createByReal(0.155) #polmonare
        planeInput.setByDistanceOnPath(spline, distance1)
        plane1 = planes.add(planeInput)

        distance1_5 = adsk.core.ValueInput.createByReal(0.23)
        planeInput.setByDistanceOnPath(spline, distance1_5)
        plane1_5 = planes.add(planeInput)

        distance2 = adsk.core.ValueInput.createByReal(0.288) #fine asc
        planeInput.setByDistanceOnPath(spline, distance2)
        plane2 = planes.add(planeInput)
       
        distance3 = adsk.core.ValueInput.createByReal(0.31) #bct
        planeInput.setByDistanceOnPath(spline, distance3)
        plane3 = planes.add(planeInput)

        distance4 = adsk.core.ValueInput.createByReal(0.36)
        planeInput.setByDistanceOnPath(spline, distance4)
        plane4 = planes.add(planeInput)

        distance5 = adsk.core.ValueInput.createByReal(0.42)
        planeInput.setByDistanceOnPath(spline, distance5)
        plane5 = planes.add(planeInput)

        distance6 = adsk.core.ValueInput.createByReal(0.53)
        planeInput.setByDistanceOnPath(spline, distance6)
        plane6 = planes.add(planeInput)

        distance7 = adsk.core.ValueInput.createByReal(1.0)
        planeInput.setByDistanceOnPath(spline, distance7)
        plane7 = planes.add(planeInput)

        #sketcehs on the planes define
        sketchplane0 = rootComp.sketches.add(plane0) #PianoVALVE
        circleplane0 = sketchplane0.sketchCurves.sketchCircles
        circle01 = circleplane0.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 0.74)
        circle02 = circleplane0.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 0.94)
        profilo01 = sketchplane0.profiles.item(0)
        profilo02 = sketchplane0.profiles.item(1)

        sketchplane1 = rootComp.sketches.add(plane1) #polmonare
        circleplane1 = sketchplane1.sketchCurves.sketchCircles
        circle11 = circleplane1.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 1.6)
        circle12 = circleplane1.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 1.8)
        profilo11 = sketchplane1.profiles.item(0)
        profilo12 = sketchplane1.profiles.item(1)

        sketchplane1_5 = rootComp.sketches.add(plane1_5)
        circleplane1_5 = sketchplane1_5.sketchCurves.sketchCircles
        circle151 = circleplane1_5.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 1.36)
        circle152 = circleplane1_5.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 1.56)
        profilo151 = sketchplane1_5.profiles.item(0)
        profilo152 = sketchplane1_5.profiles.item(1)

        sketchplane2 = rootComp.sketches.add(plane2) #fineASC
        circleplane2 = sketchplane2.sketchCurves.sketchCircles
        circle21 = circleplane2.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 1.19)
        circle22 = circleplane2.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 1.39)
        profilo21 = sketchplane2.profiles.item(0)
        profilo22 = sketchplane2.profiles.item(1)

        sketchplane3 = rootComp.sketches.add(plane3) #BCT
        circleplane3 = sketchplane3.sketchCurves.sketchCircles
        circle31 = circleplane3.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 1.15)
        circle32 = circleplane3.addByCenterRadius(adsk.core.Point3D.create(0,0,0),1.35)
        profilo31 = sketchplane3.profiles.item(0)
        profilo32 = sketchplane3.profiles.item(1)
       
        sketchplane4 = rootComp.sketches.add(plane4) #carotide
        circleplane4 = sketchplane4.sketchCurves.sketchCircles
        circle41 = circleplane4.addByCenterRadius(adsk.core.Point3D.create(0,0,0),1.0)
        circle42 = circleplane4.addByCenterRadius(adsk.core.Point3D.create(0,0,0),1.2)
        profilo41 = sketchplane4.profiles.item(0)
        profilo42 = sketchplane4.profiles.item(1)  

        sketchplane5 = rootComp.sketches.add(plane5) #succlavia
        circleplane5 = sketchplane5.sketchCurves.sketchCircles
        circle51 = circleplane5.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 0.9)
        circle52 = circleplane5.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 1.1)
        profilo51 = sketchplane5.profiles.item(0)
        profilo52 = sketchplane5.profiles.item(1)

        sketchplane6 = rootComp.sketches.add(plane6) #finearco
        circleplane6 = sketchplane6.sketchCurves.sketchCircles
        circle61 = circleplane6.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 1.1)
        circle62 = circleplane6.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 1.3)
        profilo61 = sketchplane6.profiles.item(0)
        profilo62 = sketchplane6.profiles.item(1)  

        sketchplane7 = rootComp.sketches.add(plane7) #fineDISC
        circleplane7 = sketchplane7.sketchCurves.sketchCircles
        circle71 = circleplane7.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 1.25)
        circle72 = circleplane7.addByCenterRadius(adsk.core.Point3D.create(0,0,0), 1.45)
        profilo71 = sketchplane7.profiles.item(0)
        profilo72 = sketchplane7.profiles.item(1)

        #creating the outer loft
        loftFeats2 = rootComp.features.loftFeatures
        loftInput2 = loftFeats2.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        loftcenterlineinput2 = loftInput2.centerLineOrRails
        centerline = loftcenterlineinput2.addCenterLine(spline)
        loftSectionsObj2 = loftInput2.loftSections

        loftSectionsObj2.add(profilo02)
        loftSectionsObj2.add(profilo12)
        loftSectionsObj2.add(profilo152)        
        loftSectionsObj2.add(profilo22)        
        loftSectionsObj2.add(profilo32)        
        loftSectionsObj2.add(profilo42)      
        loftSectionsObj2.add(profilo52)        
        loftSectionsObj2.add(profilo62)        
        loftSectionsObj2.add(profilo72)
        loftInput2.isSolid = True
        loftInput2.isClosed = False
        loftInput2.isTangentEdgesMerged = True

        loft2 = loftFeats2.add(loftInput2)
        corpiloft2 = loft2.bodies
        corpoesterno = corpiloft2.item(0)  
        facceloft2 = corpoesterno.faces
        facciaesterna = facceloft2.item(0)

        #creating the inner loft with cut operation
        loftFeats = rootComp.features.loftFeatures
        loftInput1 = loftFeats.createInput(adsk.fusion.FeatureOperations.CutFeatureOperation)
        loftcenterlineinput = loftInput1.centerLineOrRails
        centerline = loftcenterlineinput.addCenterLine(spline)
        loftSectionsObj = loftInput1.loftSections
        loftSectionsObj.add(profilo01)
        loftSectionsObj.add(profilo11)
        loftSectionsObj.add(profilo151)
        loftSectionsObj.add(profilo21)
        loftSectionsObj.add(profilo31)  
        loftSectionsObj.add(profilo41)  
        loftSectionsObj.add(profilo51)
        loftSectionsObj.add(profilo61)
        loftSectionsObj.add(profilo71)
        loftInput1.isSolid = True
        loftInput1.isClosed = False
        loftInput1.isTangentEdgesMerged = True  
        loft1 = loftFeats.add(loftInput1)
        facciainterna = loft1.faces.item(0)
       
        #Creating the supraortic BCT by definign a line in the plane3 define above and then creating a new plane along the line
        lines3 = sketchplane3.sketchCurves.sketchLines
        BCtLine = lines3.addByTwoPoints(adsk.core.Point3D.create(0,2.5,0), adsk.core.Point3D.create(0,-2.5,0))
        distanceBCT = adsk.core.ValueInput.createByReal(0.0)
        planeInput.setByDistanceOnPath(BCtLine, distanceBCT)
        pianoBCT = planes.add(planeInput)

        sketchBCT = rootComp.sketches.add(pianoBCT)
        circleBCT = sketchBCT.sketchCurves.sketchCircles
        circleBCT1 = circleBCT.addByCenterRadius(adsk.core.Point3D.create(0,0,0),0.45)
        circleBCT2 = circleBCT.addByCenterRadius(adsk.core.Point3D.create(0,0,0),0.545)
        profiloBCT1 = sketchBCT.profiles.item(0)
        profiloBCT2 = sketchBCT.profiles.item(1)

        sketchnurbBCT = rootComp.sketches.add(plane3)
        pointsBCT = adsk.core.ObjectCollection.create()
        pointsBCT.add(adsk.core.Point3D.create(0, 2.5 ,0))  
        pointsBCT.add(adsk.core.Point3D.create(0, 3 ,0))
        pointsBCT.add(adsk.core.Point3D.create(0, 4 ,0))
       
        pointsBCT.add(adsk.core.Point3D.create(0, 5, -0.7))      
        splineBCT = sketchnurbBCT.sketchCurves.sketchFittedSplines.add(pointsBCT)

        #creating the first extrusion to cut the base loft geometry
        extrudeFeatures = rootComp.features.extrudeFeatures
        operation = adsk.fusion.FeatureOperations.CutFeatureOperation
        distanceside1 = adsk.core.ValueInput.createByString("-30 mm")
        side = adsk.fusion.DistanceExtentDefinition.create(distanceside1)
        directionBCT = adsk.fusion.ExtentDirections.NegativeExtentDirection
        inputBCT = extrudeFeatures.createInput(profiloBCT1, operation)
        inputBCT.setOneSideExtent(side, directionBCT)
        extrudebucoBCT = extrudeFeatures.add(inputBCT)

        #creating the holes for the other two supraortic succlavia and carotide with cut operation
        #succlavia
        sketchsucclavia = rootComp.sketches.add(plane4)
        lines = sketchsucclavia.sketchCurves.sketchLines
        succlavialine = lines.addByTwoPoints(adsk.core.Point3D.create(2.5, -1.0,0), adsk.core.Point3D.create(-2.5,1.0,0))
        distancesucclavia = adsk.core.ValueInput.createByReal(1.0)
        planeInput.setByDistanceOnPath(succlavialine, distancesucclavia)
        pianosucclavia = planes.add(planeInput)

        sketchsucclavia = rootComp.sketches.add(pianosucclavia)
        circlesucclavia = sketchsucclavia.sketchCurves.sketchCircles
        circlesucc1 = circlesucclavia.addByCenterRadius(adsk.core.Point3D.create(0,0,0),0.45)
        circlesucc1 = circlesucclavia.addByCenterRadius(adsk.core.Point3D.create(0,0,0),0.545)
        profilos1 = sketchsucclavia.profiles.item(0)
        profilos2 = sketchsucclavia.profiles.item(1)

        extrudeFeatures = rootComp.features.extrudeFeatures
        operationS = adsk.fusion.FeatureOperations.CutFeatureOperation
        distanceside = adsk.core.ValueInput.createByString("30 mm")
        side = adsk.fusion.DistanceExtentDefinition.create(distanceside)
        directionS = adsk.fusion.ExtentDirections.NegativeExtentDirection
        inputSucclaviabuco = extrudeFeatures.createInput(profilos1, operationS)
        inputSucclaviabuco.setOneSideExtent(side,directionS)
        extrudebuco = extrudeFeatures.add(inputSucclaviabuco)

        #carotide
        sketchescarotide = rootComp.sketches.add(plane5)
        linescarotide = sketchescarotide.sketchCurves.sketchLines
        lineacarotide = linescarotide.addByTwoPoints(adsk.core.Point3D.create(2.5,0,0), adsk.core.Point3D.create(-2.5,0,0))
       
        planeInput.setByDistanceOnPath(lineacarotide,distancesucclavia)
        pianocarotide = planes.add(planeInput)

        sketchcarotide = rootComp.sketches.add(pianocarotide)
        circlecarotide = sketchcarotide.sketchCurves.sketchCircles
        circlecarotide1 = circlecarotide.addByCenterRadius(adsk.core.Point3D.create(0,0,0),0.45)
        circlecarotide2 = circlecarotide.addByCenterRadius(adsk.core.Point3D.create(0,0,0),0.545)
        profilocarotide1 = sketchcarotide.profiles.item(0)
        profilocarotide2 = sketchcarotide.profiles.item(1)
       
        ExtrudeFeaturesCa = rootComp.features.extrudeFeatures
        operationCa = adsk.fusion.FeatureOperations.CutFeatureOperation
        distancesideca = adsk.core.ValueInput.createByString("30 mm")
        sidecarotide = adsk.fusion.DistanceExtentDefinition.create(distancesideca)
        directionCa = adsk.fusion.ExtentDirections.NegativeExtentDirection
        inputcarotide = ExtrudeFeaturesCa.createInput(profilocarotide1, operationCa)
        inputcarotide.setOneSideExtent(sidecarotide,directionCa)
        extrudebucoCA = ExtrudeFeaturesCa.add(inputcarotide)

        #get the edges for the fillet
        edges = corpoesterno.faces.item(0).edges
        edgeCa = edges.item(0)
        edgeCaex = edges.item(1)
        edgeS = edges.item(2)
        edgesSex = edges.item(3)
        edgesBCT = edges.item(4)
        edgesBCTex = edges.item(5)
       

        #creating the extrude bodies
        #BCT first supraortic
        isChained = True
        sideOneBCT = adsk.fusion.ToEntityExtentDefinition.create(corpoesterno, isChained)
        operation2 = adsk.fusion.FeatureOperations.JoinFeatureOperation
        inputBCTvaso = extrudeFeatures.createInput(profiloBCT2, operation2)        
        inputBCTvaso.setOneSideExtent(sideOneBCT, directionBCT)
        extrudeBCT = extrudeFeatures.add(inputBCTvaso)
        path = rootComp.features.createPath(splineBCT)

        sweeps = rootComp.features.sweepFeatures        
        sweepInput = sweeps.createInput(profiloBCT2, path, operation2)
        sweepInput.orientation = adsk.fusion.SweepOrientationTypes.PerpendicularOrientationType    
        sweepBCT = sweeps.add(sweepInput)


        #succlavia  
        distanceside1 = adsk.core.ValueInput.createByString("30 mm")
        sideOne = adsk.fusion.DistanceExtentDefinition.create(distanceside1)
        isChained=True
        sideTwo = adsk.fusion.ToEntityExtentDefinition.create(corpoesterno, isChained)
        operationSjoin = adsk.fusion.FeatureOperations.JoinFeatureOperation
        inputS = extrudeFeatures.createInput(profilos2, operationSjoin)
        inputS.setTwoSidesExtent(sideOne, sideTwo)
        extrudesucclavia = extrudeFeatures.add(inputS)
     
                       
        #CAROTIDE              
        sketchnurbCa = rootComp.sketches.add(plane5)

        # Create an object collection for the points.
        pointscarotide = adsk.core.ObjectCollection.create()

        # Define the points the spline with fit through.
        pointscarotide.add(adsk.core.Point3D.create(-2.5,0, 0))
        pointscarotide.add(adsk.core.Point3D.create(-3, 0, 0))
        pointscarotide.add(adsk.core.Point3D.create(-4, 0, 0))      
        pointscarotide.add(adsk.core.Point3D.create(-5, 0 , 0.5))      
        splinecarotide = sketchnurbCa.sketchCurves.sketchFittedSplines.add(pointscarotide)        
           
        #estrusion
        isChained = True
        sideOneCA = adsk.fusion.ToEntityExtentDefinition.create(corpoesterno, isChained)          
        operation3 = adsk.fusion.FeatureOperations.JoinFeatureOperation
        inputCa = ExtrudeFeaturesCa.createInput(profilocarotide2, operation3)        
        inputCa.setOneSideExtent(sideOneCA, directionCa)
        extrudeCa = ExtrudeFeaturesCa.add(inputCa)
        extrudeCAedge = extrudeCa.bodies.item(0).edges.item(0)
             
        #creo lo sweep lungo la spline
        pathCA = rootComp.features.createPath(splinecarotide)        
        sweeps = rootComp.features.sweepFeatures
        operationcarotide = adsk.fusion.FeatureOperations.JoinFeatureOperation
        sweepInputCA = sweeps.createInput(profilocarotide2, pathCA, operationcarotide)
        sweepInputCA.orientation = adsk.fusion.SweepOrientationTypes.PerpendicularOrientationType    
        sweepcarotide = sweeps.add(sweepInputCA)              
       
        #creating the fillet starting with the supraortich on the right
        fillet = rootComp.features.filletFeatures
        radius = adsk.core.ValueInput.createByReal(0.4)  
               
        edgeCollectionCa = adsk.core.ObjectCollection.create()
        edgeCollectionCa.add(edgeCa)
        input1 = fillet.createInput()
        input1.isRollingBallCorner = True
        constanRadiusInput = input1.edgeSetInputs.addConstantRadiusEdgeSet(edgeCollectionCa, radius, True)
        constanRadiusInput.continuity = adsk.fusion.SurfaceContinuityTypes.TangentSurfaceContinuityType
        fillet1 = fillet.add(input1)      

        #edgeCaex = ui.selectEntity('Select an edge', 'Edges').entity
        edgeCaCollectionex = adsk.core.ObjectCollection.create()
        edgeCaCollectionex.add(edgeCaex)
        radius2 = adsk.core.ValueInput.createByReal(0.4)  
        input2 = fillet.createInput()
        input2.isRollingBallCorner = True
        constanRadiusInput2 = input2.edgeSetInputs.addConstantRadiusEdgeSet(edgeCaCollectionex, radius2, True)
        constanRadiusInput2.continuity = adsk.fusion.SurfaceContinuityTypes.TangentSurfaceContinuityType
        fillet1 = fillet.add(input2)
       

        #fillet succlavia
        edgeCollectionS = adsk.core.ObjectCollection.create()
        edgeCollectionS.add(edgeS)
        inputfilletS = fillet.createInput()
        inputfilletS.isRollingBallCorner = True
        constanRadiusInputS = inputfilletS.edgeSetInputs.addConstantRadiusEdgeSet(edgeCollectionS, radius, True)
        constanRadiusInputS.continuity = adsk.fusion.SurfaceContinuityTypes.TangentSurfaceContinuityType
        filletS = fillet.add(inputfilletS)      

        #edgeCaex = ui.selectEntity('Select an edge', 'Edges').entity
        edgeCaCollectionSex = adsk.core.ObjectCollection.create()
        edgeCaCollectionSex.add(edgesSex)
        radius2 = adsk.core.ValueInput.createByReal(0.4)  
        inputS2 = fillet.createInput()
        inputS2.isRollingBallCorner = True
        constanRadiusInputS2 = inputS2.edgeSetInputs.addConstantRadiusEdgeSet(edgeCaCollectionSex, radius2, True)
        constanRadiusInputS2.continuity = adsk.fusion.SurfaceContinuityTypes.TangentSurfaceContinuityType
        filletSex = fillet.add(inputS2)      

        #fillet BCT supraortic on the left
        edgeCollectionBCT = adsk.core.ObjectCollection.create()
        edgeCollectionBCT.add(edgesBCT)
        inputfilletBCT = fillet.createInput()
        inputfilletBCT.isRollingBallCorner = True
        constanRadiusInputBCT = inputfilletS.edgeSetInputs.addConstantRadiusEdgeSet(edgeCollectionBCT, radius, True)
        constanRadiusInputBCT.continuity = adsk.fusion.SurfaceContinuityTypes.TangentSurfaceContinuityType
        filletBCT = fillet.add(inputfilletBCT)      

        #edgeCaex = ui.selectEntity('Select an edge', 'Edges').entity
        edgeCaCollectionBCTex = adsk.core.ObjectCollection.create()
        edgeCaCollectionBCTex.add(edgesSex)
        radius2 = adsk.core.ValueInput.createByReal(0.4)  
        inputBCT2 = fillet.createInput()
        inputBCT2.isRollingBallCorner = True
        constanRadiusInputBCT2 = inputBCT2.edgeSetInputs.addConstantRadiusEdgeSet(edgeCaCollectionBCTex, radius2, True)
        constanRadiusInputBCT2.continuity = adsk.fusion.SurfaceContinuityTypes.TangentSurfaceContinuityType
        filletBCTex = fillet.add(inputBCT2)
0 Likes
Message 4 of 12

BrianEkins
Mentor
Mentor

You forgot to include the "Coordinate_punti_spline.txt" file.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 5 of 12

ione_ianniruberto
Contributor
Contributor

Sorry, here it is

0 Likes
Message 6 of 12

kandennti
Mentor
Mentor

Hi @ione_ianniruberto .

 

I tried with the attached file.

When I tried this one, I got an error at this point.

1.png

When I stop the process at the breakpoint and check, the number of "edges" is 2.
I understood the cause of the error.

 

I tried to figure out which face was "corpoesterno.faces.item(0)" and found that it was this face.

1.png

I think that the error is caused by the fact that I have to search for the desired face in corpoesterno.faces simply by index.


In the end, I could not reproduce the situation of the first question.

0 Likes
Message 7 of 12

ione_ianniruberto
Contributor
Contributor

Thanks so much, for me it works before but I will check again. If you remove those lines of code and run it again do you get the error that I get?

0 Likes
Message 8 of 12

kandennti
Mentor
Mentor

@ione_ianniruberto .

 

The part where you are selecting the edges for the fillets, I have changed the face selection to specify the largest surface area rather than the index.

・・・
        #get the edges for the fillet
        # edges = corpoesterno.faces.item(0).edges
        targetFace: adsk.fusion.BRepFace = max(corpoesterno.faces, key=lambda f: f.area)
        edges = targetFace.edges

        edgeCa = edges.item(0)
        edgeCaex = edges.item(1)
        edgeS = edges.item(2)
        edgesSex = edges.item(3)
        edgesBCT = edges.item(4)
        edgesBCTex = edges.item(5)
・・・

However, I get an error in the first fillet section.
Perhaps this reproduces the same situation.

 

To confirm, I added the following line just before executing the fillet

・・・
        #creating the fillet starting with the supraortich on the right
        fillet = rootComp.features.filletFeatures
        radius = adsk.core.ValueInput.createByReal(0.4)

        print(edgeCa.isValid) # <-Here
        edgeCollectionCa = adsk.core.ObjectCollection.create()
        edgeCollectionCa.add(edgeCa)
        input1 = fillet.createInput()
        input1.isRollingBallCorner = True
        constanRadiusInput = input1.edgeSetInputs.addConstantRadiusEdgeSet(edgeCollectionCa, radius, True)
        constanRadiusInput.continuity = adsk.fusion.SurfaceContinuityTypes.TangentSurfaceContinuityType
        fillet1 = fillet.add(input1)
・・・

"False" is returned. In other words, it is missing.

 

If you actually check, you will see that the body was in this state when the edge was selected, and the red arrow was selected.

1.png

 

However, at the time of filleting, the body looks like this.

1.png

The edge that was selected has disappeared due to the addition of the pipe.

 

The main reason for this is that the proper edge was not selected.
My honest opinion is that it was not working correctly before.

0 Likes
Message 9 of 12

ione_ianniruberto
Contributor
Contributor

Thanks so much for your answer, you're right in my previuos code the external radius of the pipe was exactly the same of the radius of the hole. Do you know how I can select the proper edge?

0 Likes
Message 10 of 12

kandennti
Mentor
Mentor

@ione_ianniruberto .

 

It did not come to me immediately. I would need to have a deeper understanding of the original code.

0 Likes
Message 11 of 12

BrianEkins
Mentor
Mentor
Accepted solution

There are a few possible solutions here. Here's one approach that finds the edges based on the geometry of the model. It gets the main face of the and saves the entity token of the face. Later, after the model has been modified and it's time to create the fillets, it uses the token to get the modified face. It then finds cylindrical faces that connect to this face and uses them to create fillets.

 

Here are the modified portions of the code. In this first section, it get the entity token of the loft face.

        loft2 = loftFeats2.add(loftInput2)
        corpiloft2 = loft2.bodies
        corpoesterno = corpiloft2.item(0)  
        facceloft2 = corpoesterno.faces
        facciaesterna = facceloft2.item(0)

        # Get the entity token of the loft surface.
        loftFace = loft2.sideFaces[0]
        loftToken = loftFace.entityToken

 

Here, it finds the three edges and creates the fillets.

        # Find the three edges to fillet.
        loftFace: adsk.fusion.BRepFace = design.findEntityByToken(loftToken)[0]
        filletEdges = []
        for edge in loftFace.edges:
            if edge.faces.count == 2:
                otherFace: adsk.fusion.BRepFace = None
                if edge.faces[0] == loftFace:
                    otherFace = edge.faces[1]
                else:
                    otherFace = edge.faces[0]

                if otherFace.geometry.objectType == adsk.core.Cylinder.classType():
                    filletEdges.append(edge)


        #creating the fillet starting with the supraortich on the right
        fillet = rootComp.features.filletFeatures
        radius = adsk.core.ValueInput.createByReal(0.4)          

        edgeCollectionCa = adsk.core.ObjectCollection.create()
        edgeCollectionCa.add(filletEdges[0])
        input1 = fillet.createInput()
        input1.isRollingBallCorner = True
        constanRadiusInput = input1.edgeSetInputs.addConstantRadiusEdgeSet(edgeCollectionCa, radius, True)
        constanRadiusInput.continuity = adsk.fusion.SurfaceContinuityTypes.TangentSurfaceContinuityType
        fillet1 = fillet.add(input1)      

        #edgeCaex = ui.selectEntity('Select an edge', 'Edges').entity
        edgeCaCollectionex = adsk.core.ObjectCollection.create()
        edgeCaCollectionex.add(filletEdges[1])
        radius2 = adsk.core.ValueInput.createByReal(0.4)  
        input2 = fillet.createInput()
        input2.isRollingBallCorner = True
        constanRadiusInput2 = input2.edgeSetInputs.addConstantRadiusEdgeSet(edgeCaCollectionex, radius2, True)
        constanRadiusInput2.continuity = adsk.fusion.SurfaceContinuityTypes.TangentSurfaceContinuityType
        fillet1 = fillet.add(input2)
       

        #fillet succlavia
        edgeCollectionS = adsk.core.ObjectCollection.create()
        edgeCollectionS.add(filletEdges[2])
        inputfilletS = fillet.createInput()
        inputfilletS.isRollingBallCorner = True
        constanRadiusInputS = inputfilletS.edgeSetInputs.addConstantRadiusEdgeSet(edgeCollectionS, radius, True)
        constanRadiusInputS.continuity = adsk.fusion.SurfaceContinuityTypes.TangentSurfaceContinuityType
        filletS = fillet.add(inputfilletS)   
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 12 of 12

ione_ianniruberto
Contributor
Contributor

Thanks so much for your help!

0 Likes