Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have a closed sketch on a work plane that is a fixed distance offset from the XY plane. I also have a work axis created from one of the lines in the sketch. I am trying to perform a revolve with kNewBodyOperation to create a new solid but keep running into this error "Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))". I tried revolving it manually and it works fine Here is my code:
'------------------------------------------------------------------------------------------------------------------------------------------------------ ' CLEAR IPT Dim oDoc As PartDocument oDoc = ThisDoc.Document Dim oCompDef As PartComponentDefinition oCompDef = oDoc.ComponentDefinition 'Delete all existing features Dim oFeatures As PartFeatures oFeatures = ThisApplication.ActiveDocument.ComponentDefinition.Features For Each oFeature In oFeatures Try oFeature.Delete Catch ex As Exception End Try Next 'Delete all existing sketches Dim oSketches As PlanarSketches Dim oSketch As PlanarSketch oSketches = ThisApplication.ActiveDocument.ComponentDefinition.Sketches For Each oSketch In oSketches oSketch.Delete Next ' Delete all work planes For Each oWP In oDoc.ComponentDefinition.WorkPlanes 'skip origin planes If oWP.IsCoordinateSystemElement = True Then 'do nothing Else oWP.Delete End If Next ' Delete all work axes For Each oWA In oDoc.ComponentDefinition.WorkAxes 'skip origin planes If oWA.IsCoordinateSystemElement = True Then 'do nothing Else oWA.Delete End If Next '------------------------------------------------------------------------------------------------------------------------------------------------------ ' REVOLVE Dim oWP2 As WorkPlane oWP2 = oCompDef.WorkPlanes.Item("XY Plane") Dim Length As Double = 0.9 Dim Major As Double = 0.4/2 Dim blankd As Double = 0.312 / 2 blankWorkPlane = oCompDef.WorkPlanes.AddByPlaneAndOffset(oWP2, 3) Dim blankCoords(6, 1) As Double blankCoords(0, 0) = 0 blankCoords(0, 1) = 0 blankCoords(1, 0) = Length blankCoords(1, 1) = 0 blankCoords(2, 0) = Length blankCoords(2, 1) = Major - (0.05 * System.Math.Tan(PI / 4)) blankCoords(3, 0) = Length - 0.05 blankCoords(3, 1) = Major blankCoords(5, 0) = (Major)*1.25 blankCoords(5, 1) = blankd blankCoords(4, 0) = blankCoords(5, 0) + ((Major - blankd) / (2 * Tan(PI / 3))) blankCoords(4, 1) = Major blankCoords(6, 0) = 0 blankCoords(6, 1) = blankd blankSketch = oCompDef.Sketches.Add(blankWorkPlane) Dim blankPts(6) As SketchPoint ' Identifying points For i As Integer = 0 To 6 Dim x As Double = blankCoords(i, 0) Dim y As Double = blankCoords(i, 1) blankPts(i) = blankSketch.SketchPoints.Add(ThisApplication.TransientGeometry.CreatePoint2d(x, y)) Next ' Specify the Work Axis by name Dim blankRevAxis As WorkAxis = oCompDef.WorkAxes.AddByLine(blankSketch.SketchLines.AddByTwoPoints(blankPts(1), blankPts(0))) ' Create lines connecting consecutive points For i As Integer = 0 To 5 Dim oLine As SketchLine oLine = blankSketch.SketchLines.AddByTwoPoints(blankPts(i), blankPts(i + 1)) Next ' Connect the last point to the first point to close the loop Dim blankFinalLine As SketchLine blankFinalLine = blankSketch.SketchLines.AddByTwoPoints(blankPts(6), blankPts(0)) ' Create a revolution feature using the specified Work Axis Dim blankRev As RevolveFeature blankRev = oCompDef.Features.RevolveFeatures.AddFull(blankSketch.Profiles.AddForSolid, blankRevAxis, kNewBodyOperation) ' Update the document oDoc.Update()
This is where I am currently stuck at:
This is my desired end result:
Solved! Go to Solution.