Search face

Search face

Anonymous
Not applicable
648 Views
1 Reply
Message 1 of 2

Search face

Anonymous
Not applicable

 

Ptr<BRepFaces>faces = rootComp->bRepBodies()->item(0)->faces();

pic.PNG

 

What use for search face?

 

0 Likes
Accepted solutions (1)
649 Views
1 Reply
Reply (1)
Message 2 of 2

marshaltu
Autodesk
Autodesk
Accepted solution

Hello,

 

If you have more data about the face you are going to select, you can walk through all faces and compare data of every face to the date of selected data. If they match, the face will what you want to select.

 

You can probably get data of a cylinder face by "BRepFace.geometry and Cylinder.getData()" APIs. Please refer to the following sample codes:

 

import adsk.core, adsk.fusion, traceback

def run(context):
  ui = None
  try:
    app = adsk.core.Application.get()
    ui  = app.userInterface
            
    face = adsk.fusion.BRepFace.cast(ui.activeSelections.item(0).entity)
    
    cylinderface = adsk.core.Cylinder.cast(face.geometry)
    if cylinderface:
        res, origin, axis, radius = cylinderface.getData()
        ui.messageBox('origin: ({}, {}, {}), axis: ({}, {}, {}), radius: {}'.format(origin.x, origin.y, origin.z, axis.x, axis.y, axis.z, radius))
    else:
        ui.messageBox('It is not cylider face.')
    
  except:
    if ui:
      ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) 

Thanks,

Marshal



Marshal Tu
Fusion Developer
>