HoleFeatures

HoleFeatures

Anonymous
Not applicable
441 Views
3 Replies
Message 1 of 4

HoleFeatures

Anonymous
Not applicable
I'm having a difficult time trying to add a Thru Hole to an extruded part.

I must add the hole After the part is extruded.

The part is very basic, just a rectangle extruded to a thickness of 1/2"

Here is the Sample Code:

Dim oInventorApp As Object

Set oInventorApp = GetObject(, "Inventor.Application")

Dim oPartCompDef As PartComponentDefinition
Set oPartCompDef = ThisApplication.ActiveDocument.ComponentDefinition

Dim oSketch As PlanarSketch
Set oSketch = oPartCompDef.Sketches.Item(1)

Dim oCenterPoints As ObjectCollection
Set oCenterPoints = oInventorApp.TransientObjects.CreateObjectCollection
oCenterPoints.Add oSketch.SketchPoints.Add(oInventorApp.TransientGeometry.CreatePoint2d(1, 1))

Dim oNewHole As HoleFeature
Set oNewHole = oPartCompDef.Features.HoleFeatures.AddDrilledByThroughAllExtent(oCenterPoints, 2, kPositiveExtentDirection)


VB gives me a "Type Mismatch" error when I Add the new hole definition to variable: oNewHole.

In the VB debugger, the AddDrilledByThroughAllExtent() is shown as having a Data Type of "Integer"

Any help would be greatly appreciated.
Brian
0 Likes
442 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Brian, Since you are creating the sketch point on the sketch consumed by the extrude feature, you will need to share the sketch before you create a hole feature with it. (Use oSketch.Shared = True ). Or, create a new sketch for the hole feature. Sanjay- "Stache" wrote in message news:5718519.1112731842191.JavaMail.jive@jiveforum1.autodesk.com... > I'm having a difficult time trying to add a Thru Hole to an extruded part. > > I must add the hole After the part is extruded. > > The part is very basic, just a rectangle extruded to a thickness of 1/2" > > Here is the Sample Code: > > Dim oInventorApp As Object > > Set oInventorApp = GetObject(, "Inventor.Application") > > Dim oPartCompDef As PartComponentDefinition > Set oPartCompDef = ThisApplication.ActiveDocument.ComponentDefinition > > Dim oSketch As PlanarSketch > Set oSketch = oPartCompDef.Sketches.Item(1) > > Dim oCenterPoints As ObjectCollection > Set oCenterPoints = oInventorApp.TransientObjects.CreateObjectCollection > oCenterPoints.Add > oSketch.SketchPoints.Add(oInventorApp.TransientGeometry.CreatePoint2d(1, > 1)) > > Dim oNewHole As HoleFeature > Set oNewHole = > oPartCompDef.Features.HoleFeatures.AddDrilledByThroughAllExtent(oCenterPoints, > 2, kPositiveExtentDirection) > > > VB gives me a "Type Mismatch" error when I Add the new hole definition to > variable: oNewHole. > > In the VB debugger, the AddDrilledByThroughAllExtent() is shown as having > a Data Type of "Integer" > > Any help would be greatly appreciated. > Brian
0 Likes
Message 3 of 4

Anonymous
Not applicable
Thank you very much Sanjay, that solved the problem.

Brian
0 Likes
Message 4 of 4

Anonymous
Not applicable
Is this the complete example code and if it is how do you get it to work?
Should it work in INV8?


wrote in message news:4801344@discussion.autodesk.com...
> I'm having a difficult time trying to add a Thru Hole to an extruded part.
>
> I must add the hole After the part is extruded.
>
> The part is very basic, just a rectangle extruded to a thickness of 1/2"
>
> Here is the Sample Code:
>
> Dim oInventorApp As Object
>
> Set oInventorApp = GetObject(, "Inventor.Application")
>
> Dim oPartCompDef As PartComponentDefinition
> Set oPartCompDef = ThisApplication.ActiveDocument.ComponentDefinition
>
> Dim oSketch As PlanarSketch
> Set oSketch = oPartCompDef.Sketches.Item(1)
>
> Dim oCenterPoints As ObjectCollection
> Set oCenterPoints = oInventorApp.TransientObjects.CreateObjectCollection
> oCenterPoints.Add
oSketch.SketchPoints.Add(oInventorApp.TransientGeometry.CreatePoint2d(1, 1))
>
> Dim oNewHole As HoleFeature
> Set oNewHole =
oPartCompDef.Features.HoleFeatures.AddDrilledByThroughAllExtent(oCenterPoint
s, 2, kPositiveExtentDirection)
>
>
> VB gives me a "Type Mismatch" error when I Add the new hole definition to
variable: oNewHole.
>
> In the VB debugger, the AddDrilledByThroughAllExtent() is shown as having
a Data Type of "Integer"
>
> Any help would be greatly appreciated.
> Brian
0 Likes