Yes, this is possible. I'm not sure what you mean by P.C.D. (path
controlled direction?) Regardless, the approach is the same for all
variations of patterns. The code below demonstrates getting the position of
holes in a pattern. This makes one basic, but critical assumption. The
hole feature being patterned contains a single hole. You can handle
patterns with multiple holes but this sample doesn't handle that case.
Public Sub GetHolePositionsFromPattern()
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
' Get a pattern. This just gets the first rectangular pattern in the
part.
Dim oPattern As RectangularPatternFeature
Set oPattern =
oPartDoc.ComponentDefinition.Features.RectangularPatternFeatures.Item(2)
' Get the parent hole feature of hte pattern. This assumes that the
' pattern contains a hole.
Dim oParentHole As HoleFeature
Set oParentHole = oPattern.ParentFeatures.Item(1)
' Determine the position of the parent hole. Remember that a hole
feature
' can result in the creation of many physical holes. This just gets the
' position of the first hole within the hole feature.
'
' Depending on how the hole was created this will return either the
sketch
' points that defined the hole center or it will return a Point object
that
' reports the position of the hole. This will handle either case to end
up
' with a Point object.
Dim oHoleCenter As Point
If TypeOf oParentHole.HoleCenterPoints.Item(1) Is SketchPoint Then
' Get the sketch point.
Dim oSketchPoint As SketchPoint
Set oSketchPoint = oParentHole.HoleCenterPoints.Item(1)
' Get the position of the sketch point in model space.
Dim oSketch As PlanarSketch
Set oSketch = oSketchPoint.Parent
Set oHoleCenter = oSketch.SketchToModelSpace(oSketchPoint.Geometry)
Else
Set oHoleCenter = oParentHole.HoleCenterPoints.Item(1)
End If
' Iterate through the elements of the pattern. This includes the
original hole.
Dim oElement As FeaturePatternElement
For Each oElement In oPattern.PatternElements
' Create a copy of the original hole position.
Dim oNewHoleCenter As Point
Set oNewHoleCenter =
ThisApplication.TransientGeometry.CreatePoint( _
oHoleCenter.X, oHoleCenter.Y, oHoleCenter.Z)
' Transform this point using the transform for the current element.
Call oNewHoleCenter.TransformBy(oElement.Transform)
' Write the position of the transformed hole.
Debug.Print "Hole Center: " & Format(oNewHoleCenter.X, "0.0000") &
", " & _
Format(oNewHoleCenter.Y, "0.0000") & ",
" & _
Format(oNewHoleCenter.Z, "0.0000")
Next
End Sub
--
Brian Ekins
Autodesk Inventor API
wrote in message news:5313424@discussion.autodesk.com...
Can anybody tell me if it is possible, using a Vba module, to extract
information on (ipt parts) hole patterns?
Say I had a plate with a drilled hole in it. Now say I made that hole, using
the pattern feature, into 12 holes on a P.C.D.
I need to be able to extract either the XY coordinates of each hole or the
pattern information, eg number of holes, P.C.D etc.
I also need this for a Rectangular pattern as well.
Can anybody help?
Many thanks in advance!!!
IsoCAM Group