Message 1 of 4
Hole Feature Error at CreateSketchPlacementDefinition?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Here's what I have. It adds a sketch in the flat pattern, projects the ends of the bend lines, and adds a points to the ends of each.
SyntaxEditor Code Snippet
Sub Main() If ThisApplication.ActiveDocument.Subtype <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then 'not sheet metal document Exit Sub End If Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument Dim oSMDef As ComponentDefinition = oPartDoc.ComponentDefinition Dim oFeatures As SheetMetalFeatures = oSMDef.Features Dim oFlat As FlatPattern = oSMDef.FlatPattern Dim oEdge As Edge Dim oEdges As Edges Dim oEnt1 As SketchEntity Dim oMdPt1 As SketchPoint Dim oMdPt2 As SketchPoint Dim oHoles As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection Dim oHoleDef As SketchHolePlacementDefinition Dim oBendMarks As HoleFeature Dim oSketch As PlanarSketch 'enter flat pattern and add sketch oFlat.Edit System.Threading.Thread.CurrentThread.Sleep(100) oSketch = oFlat.Sketches.Add(oFlat.TopFace, False) System.Threading.Thread.CurrentThread.Sleep(100) oSketch.Edit 'get all bend lines, both up and down oEdges = oFlat.GetEdgesOfType(64005, True) For Each oEdge In oEdges oEnt1 = oSketch.AddByProjectingEntity(oEdge) oMdPt1 = oSketch.SketchPoints.Add(oEnt1.StartSketchPoint.Geometry, True) oMdPt1.Merge(oEnt1.StartSketchPoint) oMdPt2 = oSketch.SketchPoints.Add(oEnt1.EndSketchPoint.Geometry, True) oMdPt2.Merge(oEnt1.EndSketchPoint) oHoles.Add(oMdPt1) oHoles.Add(oMdPt2) Next oEdges = oFlat.GetEdgesOfType(64004, True) For Each oEdge In oEdges oEnt1 = oSketch.AddByProjectingEntity(oEdge) oMdPt1 = oSketch.SketchPoints.Add(oEnt1.StartSketchPoint.Geometry, True) oMdPt1.Merge(oEnt1.StartSketchPoint) oMdPt2 = oSketch.SketchPoints.Add(oEnt1.EndSketchPoint.Geometry, True) oMdPt2.Merge(oEnt1.EndSketchPoint) oHoles.Add(oMdPt1) oHoles.Add(oMdPt2) Next oSketch.ExitEdit oSketch.Name = "Bend Mark Sketch" oHoleDef = oFlat.Features.HoleFeatures.CreateSketchPlacementDefinition(oHoles)'ERROR THIS LINE - PARAMETER INCORRECT oBendMarks = oFlat.Features.HoleFeatures.AddDrilledByThroughAllExtent(oHoleDef, 0.254, kPositiveExtentDirection) oBendMarks.Name = "Bend Marks" End Sub
It consistently works all the way to the CreateSketchPlacementDefinition line; all sketch points are correctly placed, and the object collection count indicates that all sketch points have been added. But in creating the PlacementDefinition it tells me the "parameter is incorrect".
If I click through the error, I am able to manually create the hole feature, and all the sketch points are recognized automatically.
Does anyone see what is wrong with my code?