Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can someone explain what happens to surfacebodies when using combine feature?

0 REPLIES 0
Reply
Message 1 of 1
Anonymous
238 Views, 0 Replies

Can someone explain what happens to surfacebodies when using combine feature?

I need to know why the object collection and surfacbody value get this error in the watchlist right after performing a combine.

<Application-defined or object-defined error>

 

This doesn' always happen and I can't figure out why.

 

Option Explicit
Dim oSurfBody As SurfaceBody

Dim oCompDef As ComponentDefinition
Dim oPartCompDef As PartComponentDefinition
Dim oPartDoc As PartDocument

Public Sub DeriveInterference()

    On Error GoTo error_checking
    Dim lngErr As Long
    Dim i As Long
    Dim oSurfBodies As SurfaceBodies

    Dim oRemoveSB As ObjectCollection
    Dim oTO As TransientObjects
    
    Set oTO = ThisApplication.TransientObjects
    'Set o2CutSurfBodies = oTO.CreateObjectCollectionByVarian
    
    Set oRemoveSB = oTO.CreateObjectCollection
    
    Set oPartDoc = ThisApplication.ActiveDocument
    Set oPartCompDef = oPartDoc.ComponentDefinition
    
    Dim oSBInt As SurfaceBody
    Dim oSBCaut As SurfaceBody
    Dim oSBMain As SurfaceBody
    Set oSurfBodies = oPartCompDef.SurfaceBodies
    
    For Each oSurfBody In oPartCompDef.SurfaceBodies
        If oSurfBody.Name = "INT" Then
            Set oSBInt = oSurfBody
        ElseIf oSurfBody.Name = "CAUT" Then
            Set oSBCaut = oSurfBody
        ElseIf oSurfBody.Name = "Main" Then
            Set oSBMain = oSurfBody
        End If
    Next oSurfBody

    oSBInt.Visible = False
    oSBCaut.Visible = False
    oSBMain.Visible = False
    Call oRemoveSB.Add(oSBInt)
    Call oRemoveSB.Add(oSBMain)
    
    For i = 1 To oPartCompDef.SurfaceBodies.Count
    'For Each oSurfBody In oPartCompDef.SurfaceBodies
        Set oSurfBody = oPartCompDef.SurfaceBodies.Item(i)
        Call CutCombine(oSurfBody, oRemoveSB)
    Next i
    'Next oSurfBody
    
error_checking:
lngErr = Err.Number


End Sub

Public Sub CutCombine(sbBase As SurfaceBody, ocRemove As ObjectCollection)
    Dim oCombFeat As CombineFeature
    Dim oCombFeats As CombineFeatures
    If Not sbBase.Name = "INT" Or Not sbBase.Name = "CAUT" _
        Or Not sbBase.Name = "Main" Then
        sbBase.Visible = True
        Set oCombFeats = oPartCompDef.Features.CombineFeatures
        Set oCombFeat = oCombFeats.Add _
            (sbBase, ocRemove, kCutOperation, True)
        End If
End Sub

 

 

 

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report