How do I identify if a split command is an error?

How do I identify if a split command is an error?

Anonymous
Not applicable
397 Views
3 Replies
Message 1 of 4

How do I identify if a split command is an error?

Anonymous
Not applicable

I have a routine that performs a split on each solid body in a model based on a surface.  The command will run but it performs splits on each solid even if there's an error.  I'd like to be able to know when an error occurs so that I can skip the split for that body.

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

rossano_praderi
Collaborator
Collaborator
May you post the code?


--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes
Message 3 of 4

Anonymous
Not applicable
Option Explicit
Dim oWorkSurf As WorkSurface
Dim oWorkSurfs As WorkSurfaces
Dim oSurfBody As SurfaceBody
Dim oSurfBodies As SurfaceBodies
Dim oCompDef As ComponentDefinition
Dim oPartCompDef As PartComponentDefinition
Dim oPartDoc As PartDocument
Dim oSplitFeat As SplitFeature


Public Sub SplitAllFaces()

    Set oPartDoc = ThisApplication.ActiveDocument
    Set oPartCompDef = oPartDoc.ComponentDefinition
    Set oSurfBodies = oPartCompDef.SurfaceBodies
    Set oWorkSurfs = oPartCompDef.WorkSurfaces
    
    oWorkSurf = oWorkSurfs.Item("Srf5")
    
    For Each oSurfBody In oSurfBodies
        
        Set oSplitFeat = oPartCompDef.Features.SplitFeatures.SplitBody(oWorkSurf, oSurfBody)
    
    Next oSurfBody

End Sub

 I have some items that are outside of the surface that cause an error.  I'd like to be able to ID them as they come by rather than just have the program run and find out when it's done. 

 

Also I'm running into a problem declaring the surface.  I didn't have this problem before and I'm not sure what changed but that's a seperate issue.

0 Likes
Message 4 of 4

Anonymous
Not applicable
Accepted solution

Talked to a computer programmer who gave me this.

 

Option Explicit
Dim oWorkSurf As WorkSurface
Dim oWorkSurfs As WorkSurfaces
Dim oSurfBody As SurfaceBody
Dim oSurfBodies As SurfaceBodies
Dim oCompDef As ComponentDefinition
Dim oPartCompDef As PartComponentDefinition
Dim oPartDoc As PartDocument
Dim oSplitFeat As SplitFeature


Public Sub SplitAllFaces()
    On Error GoTo err_SplitAllFaces

    Set oPartDoc = ThisApplication.ActiveDocument
    Set oPartCompDef = oPartDoc.ComponentDefinition
    Set oSurfBodies = oPartCompDef.SurfaceBodies
    Set oWorkSurfs = oPartCompDef.WorkSurfaces
    
    Set oWorkSurf = oWorkSurfs.Item("Srf5")
    
    For Each oSurfBody In oSurfBodies
        
        Set oSplitFeat = oPartCompDef.Features.SplitFeatures.SplitBody(oWorkSurf, oSurfBody)
    
    Next oSurfBody
    
end_SplitAllFaces:
    Exit Sub

err_SplitAllFaces:
    Select Case Err.Number
    Case -2147467259  'Place holder for no split surface
        Resume Next
    Case Else
      MsgBox ("Error ")
      Resume end_SplitAllFaces
    End Select
End Sub

 

0 Likes