Create a simple hole with a specific depth

Create a simple hole with a specific depth

Anonymous
Not applicable
437 Views
2 Replies
Message 1 of 3

Create a simple hole with a specific depth

Anonymous
Not applicable

Hi All

 

 I ‘m trying to create  a simple hole  by adding the depth, and it throws  the  next exception.

$exception         {"El parámetro no es correcto. (Excepción de HRESULT: 0x80070057 (E_INVALIDARG))"}                System.ArgumentException}

 

Does anyone know what the error is in the parameter?

hole2 = oComDef.Features.HoleFeatures.AddDrilledByDistanceExtent(oHoleCenters2, "8 mm", "10 mm", PartFeatureExtentDirectionEnum.kNegativeExtentDirection, True, "118 deg")

 

Public Sub createSimpleHole()

        Dim hole2 As HoleFeature
        Dim oPoint, oPoint2 As Point2d
        oPoint = oTransGeom.CreatePoint2d(1, 1)
        oPoint2 = oTransGeom.CreatePoint2d(1, 1)

       Dim point, point2 As SketchPoint
        point = oSketch.SketchPoints.Add(oPoint, True)
        point2 = oSketch.SketchPoints.Add(oPoint2, True)

        point.HoleCenter = True
        point2.HoleCenter = True

        Dim offset, o2 As TwoPointDistanceDimConstraint
        offset = oSketch.DimensionConstraints.AddTwoPointDistance(lineWidth.StartSketchPoint, point, DimensionOrientationEnum.kVerticalDim, oTransGeom.CreatePoint2d(2, 2), False)
        o2 = oSketch.DimensionConstraints.AddTwoPointDistance(lineHight.StartSketchPoint, point, DimensionOrientationEnum.kHorizontalDim, oTransGeom.CreatePoint2d(-2, 0), False)
        offset.Parameter.Value = (offsetWidth / 10)
        o2.Parameter.Value = Math.Abs(15 / 10)


        Dim d1, d2, d3, d4 As TwoPointDistanceDimConstraint
        d1 = oSketch.DimensionConstraints.AddTwoPointDistance(lineWidth.StartSketchPoint, point2, DimensionOrientationEnum.kVerticalDim, oTransGeom.CreatePoint2d(2, 2), False)
        d2 = oSketch.DimensionConstraints.AddTwoPointDistance(lineHight.StartSketchPoint, point2, DimensionOrientationEnum.kHorizontalDim, oTransGeom.CreatePoint2d(-2, 0), False)
        d1.Parameter.Value = (offsetWidth / 10)
        d2.Parameter.Value = Math.Abs(30 / 10)


        oSketch.ExitEdit()


        Dim oHoleCenters2 As ObjectCollection
        oHoleCenters2 = m_invApp.TransientObjects.CreateObjectCollection

        oHoleCenters2.Add(point)
        oHoleCenters2.Add(point2)

        hole2 = oComDef.Features.HoleFeatures.AddDrilledByDistanceExtent(oHoleCenters2, "8 mm", "10 mm", PartFeatureExtentDirectionEnum.kNegativeExtentDirection, True, "118 deg")

    End Sub

 

 

 

program goalprogram goalprogram goalprogram goal

 

 

0 Likes
438 Views
2 Replies
Replies (2)
Message 2 of 3

t_remal
Autodesk
Autodesk

Hi,

 

I don't see an error in your code (other than you probably wanted to pass False to AddDrilledByDistanceExtent, because otherwise the last parameter will not be used, but that should not throw an exception).

 

Could you please share the dataset (with the information what "lineWidth" and "lineHight" are)?

 

Lubomir

0 Likes
Message 3 of 3

Anonymous
Not applicable

Hi.

 

Thanks,  I appreciate your comments.

I detected the problem, I has passed   to the parameter an incorrect object, Linewidth and lineHeight are a sketchlines that the user selects.

0 Likes