KnitFeatures.Add Method Failed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am fairly new to incorporating VBA with Inventor (not new to VBA). Most of the code I've learned has been using snippets found on this forum or other sites when I hit snags...to fit my needs. However, I've hit a bump with the knitfeatures.add method. The overall goal I'm trying to accomplish is to move a part in an assembly to a different location and get the minimum distance. I want to iterate this until I hit a minimum value. I'm attempting to create a transient surface body for each component I want to measure between. Each part file is a multi-body part file. So I am incrementing through each body for that part file and creating a transient surface body and adding that to an object collection. This works, but when I set my knitfeatures.add to stitch the surface bodies to create a singular surface body on the last line of the code below, I get the .Add Method failed error. I am in the beginning stages of this process...as I am only working in a single Part file at the moment (not from the assembly) in order to take baby steps and learn. Any help or insight would be helpful. I have search for a couple days trying to find a solution (i'm afraid it's simple and I'm just missing it).
Private Sub TransBody()
Dim partdoc As PartDocument
Set partdoc = ThisApplication.ActiveDocument
Dim pcDef As PartComponentDefinition, surfbody As SurfaceBodies
Set pcDef = partdoc.ComponentDefinition
Dim oTransBRep As TransientBRep, cnt As Integer
Set oTransBRep = ThisApplication.TransientBRep
cnt = pcDef.SurfaceBodies.Count
Dim sbCollection As ObjectCollection, oTO As TransientObjects
Set oTO = ThisApplication.TransientObjects
Set sbCollection = oTO.CreateObjectCollection
Dim oBody1 As SurfaceBody, i As Integer
For i = 1 To cnt
Set oBody1 = oTransBRep.Copy(pcDef.SurfaceBodies(i))
Call sbCollection.Add(oBody1)
'Call partdoc.ComponentDefinition.Features.NonParametricBaseFeatures.Add(oBody1)
Next i
Dim oKnitFeature As KnitFeature
Set oKnitFeature = pcDef.Features.KnitFeatures.Add(sbCollection)