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: 

Can not create a plane by setByTangentAtPoint in design history

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
ho-kou
238 Views, 2 Replies

Can not create a plane by setByTangentAtPoint in design history

hi, everyone

 

I want to create a plane by setByTangentAtPoint.

I can do it not in design history,

but it's wrong result in design history.

who know how can create tangentAtPoint plane in  design history.

 

This is my code which to create tangentAtPoint plane at face's centor point.

Thank you very much for your help.

 

_app = adsk.core.Application.get()
        _ui = _app.userInterface
        product = _app.activeProduct
        _design = adsk.fusion.Design.cast(product)

        _rootComp = _design.rootComponent

        # get target body
        targetbody = _rootComp.bRepBodies.item(_rootComp.bRepBodies.count - 1)

        # get the target face
        targetface = targetbody.faces[0]

        # create plane by setByTangentAtPoint at center of the target face
        planes     = _rootComp.constructionPlanes
        planeInput = planes.createInput()
     
        planeInput.setByTangentAtPoint(targetface, targetface.centroid)
        tangentplane = planes.add(planeInput)

 

1.png

 

2 REPLIES 2
Message 2 of 3
kandennti
in reply to: ho-kou

Hi @ho-kou -San.

 

It can be reproduced. It must be a bug.

In the meantime, if you are in a hurry, this may help.

・・・
        # create plane by setByTangentAtPoint at center of the target face
        planes: adsk.fusion.ConstructionPlanes = _rootComp.constructionPlanes
        planeInput = planes.createInput()

        if _design.designType == adsk.fusion.DesignTypes.DirectDesignType:
            planeInput.setByTangentAtPoint(targetface, targetface.centroid)
            tangentplane = planes.add(planeInput)
        else:
            sels: adsk.core.Selections = _ui.activeSelections
            sels.clear()
            sels.add(targetface)
            sels.add(
                _rootComp.constructionPoints.itemByName("center point")
            )
            _app.executeTextCommand(
                u"Commands.Start WorkPlaneFromPointAndFaceCommand"
            )
            _app.executeTextCommand(u"NuCommands.CommitCmd")

・・・
Message 3 of 3
ho-kou
in reply to: kandennti

Tnank you very much for your help. I create the plane use this code.

_app = adsk.core.Application.get()
        _ui = _app.userInterface
        product = _app.activeProduct
        _design = adsk.fusion.Design.cast(product)

        _rootComp = _design.rootComponent

        # get target body
        targetbody = _rootComp.bRepBodies.item(_rootComp.bRepBodies.count - 1)

        # get the target face
        targetface = targetbody.faces[0]

        # create plane by setByTangentAtPoint at center of the target face
        planes     = _rootComp.constructionPlanes
        planeInput = planes.createInput()

        returnValue, facenormal = targetface.evaluator.getNormalAtPoint(targetface.pointOnFace)
        root = _design.rootComponent

        if _design.designType == adsk.fusion.DesignTypes.DirectDesignType:
     
            planeInput.setByTangentAtPoint(targetface, targetface.centroid)
            tangentplane = planes.add(planeInput)

        else:
            baseFeature = root.features.baseFeatures.add()
            baseFeature.startEdit()

            planeInput.setByTangentAtPoint(targetface, targetface.centroid)
            tangentplane = planes.add(planeInput)

            baseFeature.finishEdit()

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

Post to forums  

Autodesk Design & Make Report