<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Problems with draft features on cylindrical face. in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/problems-with-draft-features-on-cylindrical-face/m-p/10552142#M8199</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The attached code will crash if I run it on any face that is connected to a cylindrical wall.&amp;nbsp; (see pics below)&amp;nbsp; The code works well on all other features.&amp;nbsp; Can someone explain why the createInput call on line 75 crashes when selecting a cylindrical face.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for the help.&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ebunn3_0-1629210752703.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/953840i489AAC1DDAE398E7/image-size/large?v=v2&amp;amp;px=999" role="button" title="ebunn3_0-1629210752703.png" alt="ebunn3_0-1629210752703.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ebunn3_1-1629210773710.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/953842iE2D81E5DE037A3E3/image-size/large?v=v2&amp;amp;px=999" role="button" title="ebunn3_1-1629210773710.png" alt="ebunn3_1-1629210773710.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;import adsk.core, adsk.fusion, traceback

draft = 5

def surfNormal(app,ui,ent):
    # ui = adsk.core.UserInterface.cast(None)
    try:
        # app: adsk.fusion.Application = adsk.core.Application.get()
        # ui = app.userInterface
        des: adsk.fusion.Design = app.activeProduct
        root: adsk.fusion.Component = des.rootComponent

        face: adsk.fusion.BRepFace = ent.entity
        click: adsk.core.Point3D = ent.point

        # get SurfaceEvaluator
        eva: adsk.core.SurfaceEvaluator = face.evaluator

        # get Normal
        normal: adsk.core.Vector3D
        _, normal = eva.getNormalAtPoint(click)
        normal.normalize()
        return normal

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def selectEnt(msg: str,filtterStr: str) -&amp;gt; adsk.core.Selection:
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        sel = ui.selectEntity(msg, filtterStr)
        return sel
    except:
        return None
        
def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface


        # Get active design        
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)
        
        # Get root component in this design
        rootComp = design.rootComponent

        i=1
        while i&amp;lt;=10:
            dialogResult = ui.messageBox('Select the face(s) parallel to the base plane to draft from. Click "Yes" to add a face, "No to finish selections"','Draft Selection', adsk.core.MessageBoxButtonTypes.YesNoButtonType, adsk.core.MessageBoxIconTypes.QuestionIconType) 
            if dialogResult == adsk.core.DialogResults.DialogYes:            
                #select entity (ent = ui.selectEntity("Select a face to draft from.","Faces"))
                ent = selectEnt("Select a face to draft from.","Faces",)
                #get surface normal
                norm = surfNormal(app,ui,ent);print(int(norm.x),int(norm.y),int(norm.z))
                norm = str( int(norm.x) )  +  str( int(norm.y) )  +  str( int(norm.z)  )
                #get the face from the selection
                face1 = adsk.fusion.BRepFace.cast(ent.entity)

                # Get all faces which connect to the first face
                connectedFaces = [];
                for edge in face1.edges:
                    for face in edge.faces:
                        if face1 != face:
                            connectedFaces.append(face)
            
                # Create draft feature
                drafts = rootComp.features.draftFeatures

                draftFeatInput = drafts.createInput(connectedFaces, face1, True)

                #set the draft direction based on the normal
                # draftFeatInput.isDirectionFlipped = False
                if norm == "001":
                    draftFeatInput.isDirectionFlipped = False
                else:
                    draftFeatInput.isDirectionFlipped = True
                #set the value of the angle
                angle = adsk.core.ValueInput.createByString(str(int(draft)) + " deg")
                angle2 = adsk.core.ValueInput.createByString(str(int(draft*-1)) + " deg")
                #set for single angle
                draftFeatInput.setTwoAngles(angle,angle2)
                # draftFeatInput.setSingleAngle(False, angle)
                #add the draft
                drafts.add(draftFeatInput)   
            elif dialogResult == adsk.core.DialogResults.DialogNo:
                break
            i += 1

      
        
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Aug 2021 14:34:10 GMT</pubDate>
    <dc:creator>ebunn3</dc:creator>
    <dc:date>2021-08-17T14:34:10Z</dc:date>
    <item>
      <title>Problems with draft features on cylindrical face.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/problems-with-draft-features-on-cylindrical-face/m-p/10552142#M8199</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The attached code will crash if I run it on any face that is connected to a cylindrical wall.&amp;nbsp; (see pics below)&amp;nbsp; The code works well on all other features.&amp;nbsp; Can someone explain why the createInput call on line 75 crashes when selecting a cylindrical face.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for the help.&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ebunn3_0-1629210752703.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/953840i489AAC1DDAE398E7/image-size/large?v=v2&amp;amp;px=999" role="button" title="ebunn3_0-1629210752703.png" alt="ebunn3_0-1629210752703.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ebunn3_1-1629210773710.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/953842iE2D81E5DE037A3E3/image-size/large?v=v2&amp;amp;px=999" role="button" title="ebunn3_1-1629210773710.png" alt="ebunn3_1-1629210773710.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;import adsk.core, adsk.fusion, traceback

draft = 5

def surfNormal(app,ui,ent):
    # ui = adsk.core.UserInterface.cast(None)
    try:
        # app: adsk.fusion.Application = adsk.core.Application.get()
        # ui = app.userInterface
        des: adsk.fusion.Design = app.activeProduct
        root: adsk.fusion.Component = des.rootComponent

        face: adsk.fusion.BRepFace = ent.entity
        click: adsk.core.Point3D = ent.point

        # get SurfaceEvaluator
        eva: adsk.core.SurfaceEvaluator = face.evaluator

        # get Normal
        normal: adsk.core.Vector3D
        _, normal = eva.getNormalAtPoint(click)
        normal.normalize()
        return normal

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def selectEnt(msg: str,filtterStr: str) -&amp;gt; adsk.core.Selection:
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        sel = ui.selectEntity(msg, filtterStr)
        return sel
    except:
        return None
        
def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface


        # Get active design        
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)
        
        # Get root component in this design
        rootComp = design.rootComponent

        i=1
        while i&amp;lt;=10:
            dialogResult = ui.messageBox('Select the face(s) parallel to the base plane to draft from. Click "Yes" to add a face, "No to finish selections"','Draft Selection', adsk.core.MessageBoxButtonTypes.YesNoButtonType, adsk.core.MessageBoxIconTypes.QuestionIconType) 
            if dialogResult == adsk.core.DialogResults.DialogYes:            
                #select entity (ent = ui.selectEntity("Select a face to draft from.","Faces"))
                ent = selectEnt("Select a face to draft from.","Faces",)
                #get surface normal
                norm = surfNormal(app,ui,ent);print(int(norm.x),int(norm.y),int(norm.z))
                norm = str( int(norm.x) )  +  str( int(norm.y) )  +  str( int(norm.z)  )
                #get the face from the selection
                face1 = adsk.fusion.BRepFace.cast(ent.entity)

                # Get all faces which connect to the first face
                connectedFaces = [];
                for edge in face1.edges:
                    for face in edge.faces:
                        if face1 != face:
                            connectedFaces.append(face)
            
                # Create draft feature
                drafts = rootComp.features.draftFeatures

                draftFeatInput = drafts.createInput(connectedFaces, face1, True)

                #set the draft direction based on the normal
                # draftFeatInput.isDirectionFlipped = False
                if norm == "001":
                    draftFeatInput.isDirectionFlipped = False
                else:
                    draftFeatInput.isDirectionFlipped = True
                #set the value of the angle
                angle = adsk.core.ValueInput.createByString(str(int(draft)) + " deg")
                angle2 = adsk.core.ValueInput.createByString(str(int(draft*-1)) + " deg")
                #set for single angle
                draftFeatInput.setTwoAngles(angle,angle2)
                # draftFeatInput.setSingleAngle(False, angle)
                #add the draft
                drafts.add(draftFeatInput)   
            elif dialogResult == adsk.core.DialogResults.DialogNo:
                break
            i += 1

      
        
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 14:34:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/problems-with-draft-features-on-cylindrical-face/m-p/10552142#M8199</guid>
      <dc:creator>ebunn3</dc:creator>
      <dc:date>2021-08-17T14:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with draft features on cylindrical face.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/problems-with-draft-features-on-cylindrical-face/m-p/10553254#M8200</link>
      <description>&lt;P&gt;I'm able to reproduce the problem and will make sure a bug gets filed.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 21:42:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/problems-with-draft-features-on-cylindrical-face/m-p/10553254#M8200</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2021-08-17T21:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with draft features on cylindrical face.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/problems-with-draft-features-on-cylindrical-face/m-p/10553281#M8201</link>
      <description>&lt;P&gt;Brian&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there somewhere that these issues are tracked so I can see when there is a fix for it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 22:03:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/problems-with-draft-features-on-cylindrical-face/m-p/10553281#M8201</guid>
      <dc:creator>ebunn3</dc:creator>
      <dc:date>2021-08-17T22:03:55Z</dc:date>
    </item>
  </channel>
</rss>

