打开一个现存的文件,并选择一个表面,执行下列代码:

let testSelectFace(swApp: ISldWorks) =
    let swModel = 
        swApp.ActiveDoc
        |> unbox<ModelDoc2>

    let swSelMgr = swModel.SelectionManager :?> SelectionMgr
  
    //Do some validation before running routines....
    let SelObjType = swSelMgr.GetSelectedObjectType3(1, -1)

    if SelObjType = int swSelectType_e.swSelFACES then
        //Get the selected face, ignore marks
        let swSelFace = swSelMgr.GetSelectedObject6(1, -1)
        //Create a Safe Entity so we can select it when the face
        //becomes invalid
        let swEntity = swSelFace |> unbox<Entity>
        let swSafeSelFace = swEntity.GetSafeEntity()
        swApp.SendMsgToUser $"{swSafeSelFace.ToString()}"
    else
        swApp.SendMsgToUser "You did not select a face."