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: 

"Object variable or With block variable not set" error declaring a worksurface

1 REPLY 1
SOLVED
Reply
Message 1 of 2
jpblower
2348 Views, 1 Reply

"Object variable or With block variable not set" error declaring a worksurface

I get an error

 

Run-time error '91':

Object variable or With block variable not set

 

when running this code

 

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'm not sure why.  I've tried Item ("Srf5"), Item(1), and Item("Surface2").  All give the same result.

1 REPLY 1
Message 2 of 2
jpblower
in reply to: jpblower

Found the answer, oWorkSurface=.... needs to be   Set oWorkSurface=.....

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

Post to forums  

Autodesk Design & Make Report