Cannot get profile plane when plane is a planar face

Cannot get profile plane when plane is a planar face

robertASTUP
Contributor Contributor
325 Views
1 Reply
Message 1 of 2

Cannot get profile plane when plane is a planar face

robertASTUP
Contributor
Contributor

Hi,

 

I am having an issue getting the profile plane for an extrude feature if the profile plane is a BRepFace. This seems to reoccur in many places in the API. For example the attached script and model will always raise a RuntimeError when the profile plane is a face. Are there plans to fix this issue or is there some workaround I can use?

 

Thanks

 

Robert

 

 

 

import adsk.core, adsk.fusion, traceback


def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface

product = app.activeProduct
design = adsk.fusion.Design.cast(product)

# Get the root component of the active design.
rootComp = design.rootComponent

# get all extrude features
extrude_features = rootComp.features.extrudeFeatures

# get the last extrude feature
last_extrude_feature = extrude_features.item(extrude_features.count - 1)

# get start extent
start_extent = last_extrude_feature.startExtent

# get profile plane
profile_plane = start_extent.profilePlane

except:
if ui:
ui.messageBox("Failed:\n{}".format(traceback.format_exc()))


run(None)

 

 

0 Likes
326 Views
1 Reply
Reply (1)
Message 2 of 2

kandennti
Mentor
Mentor

Hi @robertASTUP -San.

 

I also tried to make it possible to get BrepFace.

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface

        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)

        # Get the root component of the active design.
        rootComp = design.rootComponent

        # get all extrude features
        extrude_features = rootComp.features.extrudeFeatures

        # get the last extrude feature
        last_extrude_feature: adsk.fusion.ExtendFeature = extrude_features.item(extrude_features.count - 1)

        # roll to before
        stateMark = design.timeline.markerPosition
        last_extrude_feature.timelineObject.rollTo(True)

        # get profile plane/face
        prof: adsk.fusion.Profile = last_extrude_feature.profile
        if prof.classType() == adsk.fusion.BRepFace.classType():
            profile_plane = prof # BRepFace
        elif prof.classType() == adsk.fusion.Profile.classType():
            profile_plane = prof.plane # Plane
        else:
            profile_plane = None

        # Restore timeline to original position
        design.timeline.markerPosition = stateMark

    except:
        if ui:
            print("Failed:\n{}".format(traceback.format_exc()))