Can not create a plane by setByTangentAtPoint in design history

Can not create a plane by setByTangentAtPoint in design history

ho-kou
Advocate Advocate
414 Views
2 Replies
Message 1 of 3

Can not create a plane by setByTangentAtPoint in design history

ho-kou
Advocate
Advocate

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

 

0 Likes
Accepted solutions (1)
415 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor
Accepted solution

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")

・・・
0 Likes
Message 3 of 3

ho-kou
Advocate
Advocate

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()