Message 1 of 6

Not applicable
09-17-2019
01:36 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I posted a couple weeks ago about something similar to this but didn't get an answer. Since my last post I've changed the way I get the surface body I needed so I don't need help with that anymore. However, I'm having a ton of trouble getting the derive function to work properly.
I've been using posts from mod the machine as a reference, but for some reason the exact same syntax is failing at the "Set newPart = ...." line, throwing an "Invalid procedure call or argument" error.
Every reference I've found uses this exact same syntax, so I don't know what the problem is. If anyone can help me figure this out I would appreciate it.
Dim oDoc As PartDocument Set oDoc = ThisApplication.ActiveDocument Dim template As String Dim folder As String template = " " folder = PathName(oDoc.FullFileName) Dim partColl As ObjectCollection Set partColl = ThisApplication.TransientObjects.CreateObjectCollection Dim i As Integer: i = 0 Dim oSB As SurfaceBody For Each oSB In oDoc.ComponentDefinition.SurfaceBodies 'set new part throws invalid procedure call or argument Dim newPart As PartDocument Set newPart = ThisApplication.Documents.Add(kPartDocumentObject, template, True) Dim oDerPartComps As DerivedPartComponents Set oDerPartComps = newPart.ComponentDefinition.ReferenceComponents.DerivedPartComponents Dim oDerPartDef As DerivedPartUniformScaleDef Set oDerPartDef = oDerPartComps.CreateUniformScaleDef(oDoc.FullFileName) ' create definition corresponding to desired type of derived part oDerPartDef.ScaleFactor = 1 Call oDerPartDef.ExcludeAll Dim oDerPartEnt As DerivedPartEntity For Each oDerPartEnt In oDerPartDef.Surfaces If oDerPartEnt.Type = kSurfaceBodiesObject Then oDerPartEnt.IncludeEntity = True End If Next Call oDerPartComps.Add(oDerPartDef) Call partColl.Add(newPart) oDerPartDef.DeriveStyle = kDeriveAsWorkSurface Dim oDerComp As DerivedPartComponent Set oDerComp = oDerPartComps.Add(oDerPartDef) newPart.PropertySets.Item("Inventor Summary Information").Item("Title").Value = oSB.Name i = i + 1 ThisApplication.SilentOperation = True Call newPart.SaveAs(folder & oSB.Name & "_" & i & ".ipt", False) ThisApplication.SilentOperation = False Next oSB End Sub Function PathName(FullPath As String) As String ' return all left of last \ PathName = Left(FullPath, InStrRev(FullPath, "\")) End Function
Solved! Go to Solution.