09-15-2016
05:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-15-2016
05:13 AM
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oHoleFeat As HoleFeature
For Each oHoleFeat In oDoc.ComponentDefinition.Features.HoleFeatures
Debug.Print ("X:" & oHoleFeat.HoleCenterPoints.Item(1).X)
Debug.Print ("Y:" & oHoleFeat.HoleCenterPoints.Item(1).Y)
Debug.Print ("Z:" & oHoleFeat.HoleCenterPoints.Item(1).Z)
Debug.Print ("Durchmesser:" & oHoleFeat.HoleDiameter.Expression)
Debug.Print ("Bohrungstiefe:" & oHoleFeat.Extent.Distance.Expression)
Next
'#################
Sub addHole()
Dim oDoc As PartDocument
Set oDoc = ThisDocument
Dim oCD As PartComponentDefinition
Set oCD = oDoc.ComponentDefinition
Dim oHF As HoleFeature
Set oHF = oCD.Features.HoleFeatures.Item(1)
Dim oSK As PlanarSketch
Set oSK = oHF.Sketch
Call oSK.Edit
Dim oPt As Inventor.Point2d
Set oPt = ThisApplication.TransientGeometry.CreatePoint2d(3, 1)
Call oSK.SketchPoints.Add(oPt, True)
Call oSK.ExitEdit
Dim oNewObjColl As ObjectCollection
Set oNewObjColl = ThisApplication.TransientObjects.CreateObjectCollection
Call oNewObjColl.Add(oCD.Sketches(2).SketchPoints(1)) ' Existing hole centre
Call oNewObjColl.Add(oCD.Sketches(2).SketchPoints(2)) ' New hole centre
oHF.HoleCenterPoints = oNewObjColl
End Sub