replaceFaceFeature --> RuntimeError: 3 invalid target faces

Anonymous

replaceFaceFeature --> RuntimeError: 3 invalid target faces

Anonymous
Not applicable

Hello,

I am trying to access the replace face tool from the solid body modification tools from the API.

The top surface of the strut should be replaced by the inclined surface of the second part (see figure). This works perfectly fine by manually executing the replace face feature and selecting the faces in the GUI.

 

replaceFace.JPGreplaceFeature.gif

 

Using the following code snippet for the replace feature leads to a runtimeError:3

 

repFaceFeats = rootComp.features.replaceFaceFeatures
    # source is the strut face as result of a loft feature
    source = adsk.core.ObjectCollection.create()
    source.add(loftFeat.startFace)
    # target is a BrepFace of the target body
    target = face[0]
    repFaceInp = repFaceFeats.createInput(source,False,target)
    repFace = repFaceFeats.add(repFaceInp)

 

 

 

Error:

RuntimeError: 3 : invalid target faces, it should be surface face or body

 

The target face is of type BrepFace and I can confirm that it is the desired face of the body. Selecting the same face using the UI.selectEntity() method and using the returned entity as target face for the replaceFaceFeatureInput leads to the same error.

 

Any suggestions on what might be my mistake here?

 

Thank you all in advance!

 

0 Likes
Reply
Accepted solutions (1)
342 Views
1 Reply
Reply (1)

Anonymous
Not applicable
Accepted solution

A possible workaround for the API is to create a surface face by offsetting the original body face by a value of 0. This face can then be selected for the ReplaceFaceFeature and afterwards removed by a soft delete.

 

    inputFace = adsk.core.ObjectCollection.create()
    inputFace.add(face)
    offsetFeat:adsk.fusion.OffsetFeatures = rootComp.features.offsetFeatures
    offsetInp = offsetFeat.createInput(inputFace,
                adsk.core.ValueInput.createByReal(0),
                adsk.fusion.FeatureOperations.NewBodyFeatureOperation,False)
    offsetFace:adsk.fusion.OffsetFeature = offsetFeat.add(offsetInp)

# insert code for the face replacement here

    remove:adsk.fusion.RemoveFeatures = rootComp.features.removeFeatures
    remove.add(offsetFace.bodies[0])
1 Like