Can`t create profile as AddForSolid on Inventor VBA

Can`t create profile as AddForSolid on Inventor VBA

Anonymous
Not applicable
1,056 Views
1 Reply
Message 1 of 2

Can`t create profile as AddForSolid on Inventor VBA

Anonymous
Not applicable

I was following the example of the Sweep feature Add API sample and try to learn how to use the Sweep feature on my project, but I can`t create the profile as Addforsolid. I have tried the Addforsurface and it's not working too. 

 

This is the code below.

Any help would be much appreciated!

 

 

Public Sub Cover()
' Create a new part document, using the default part template.
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))
' Set a reference to the component definition.
Dim oCompDef As PartComponentDefinition
Set oCompDef = oPartDoc.ComponentDefinition
'Create a new sketch on the XZ work plane.
Dim oSketch As PlanarSketch
Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes(2))
Dim oTransGeom As TransientGeometry
Set oTransGeom = ThisApplication.TransientGeometry
Dim oCoord(1 To 9) As Point2d
Set oCoord(1) = oTransGeom.CreatePoint2d(0, 30)
Set oCoord(2) = oTransGeom.CreatePoint2d(0, 33)
Set oCoord(3) = oTransGeom.CreatePoint2d(0, 0)
Set oCoord(4) = oTransGeom.CreatePoint2d(0, -33)
Set oCoord(5) = oTransGeom.CreatePoint2d(0, -30)
Set oCoord(6) = oTransGeom.CreatePoint2d(0, 30)
Dim oLines(1 To 2) As SketchLine
Set oLines(1) = oSketch.SketchLines.AddByTwoPoints(oCoord(1), oCoord(2))
Dim oArc(1 To 3) As SketchArc
Set oArc(1) = oSketch.SketchArcs.AddByCenterStartEndPoint(oCoord(3), oLines(1).EndSketchPoint, oCoord(4))
Set oLines(2) = oSketch.SketchLines.AddByTwoPoints(oArc(1).EndSketchPoint, oCoord(5))
Set oArc(2) = oSketch.SketchArcs.AddByCenterStartEndPoint(oCoord(3), oLines(2).EndSketchPoint, oCoord(6), False)
Dim oProfile As Profile
Set oProfile = oSketch.Profiles.AddForSolid
'Create a path on XY work plane
Dim oSketchline As PlanarSketch
Set oCurve = oCompDef.Sketches.Add(oCompDef.WorkPlanes.Item(3))
Set oCoord(7) = oTransGeom.CreatePoint2d(33, 0)
Set oCoord(8) = oTransGeom.CreatePoint2d(34.5, 80)
Set oCoord(9) = oTransGeom.CreatePoint2d(-43.24, 40.89)
Set oArc(3) = oCurve.SketchArcs.AddByCenterStartEndPoint(oCoord(9), oCoord(7), oCoord(8), True)
Dim oPath As Path
Set oPath = oCompDef.Features.CreatePath(oArc(3))
Dim oSweep As SweepFeature
Set oSweep = oCompDef.Features.SweepFeatures.AddUsingPath(oProfile, oPath, kJoinOperation)

 

End Sub

 

0 Likes
Accepted solutions (1)
1,057 Views
1 Reply
Reply (1)