Getting mirrored holes

Getting mirrored holes

NickBrege
Advocate Advocate
647 Views
2 Replies
Message 1 of 3

Getting mirrored holes

NickBrege
Advocate
Advocate

Let's say I have a solid part with a hole feature that has 6 instances of holes. Now I mirror that hole feature to give me 6 more holes on the opposite side of the part face.  How can I programatically get the 6 original holes & the 6 mirrored holes so that I can get the center points?  What I'm trying to do is create a CSV file that contains the x,y & z coordinates of all 12 holes.  Thanks for any help...

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

Anonymous
Not applicable

I would include the points you are looking for as part of the hole features, or maybe use an iFeature for this.

Easiest way to do this is to use a "Centre Point of Loop of Edges"

@ClintBrown3D Autodesk Inventor 177.png

Mirror the holes and the points together

@ClintBrown3D Autodesk Inventor 178.png

Then run the iLogic code that I have written for exporting points to CSV or TXT, it looks something like this:

autodesk-inventor-ilogic-export-points-to-txt.gif

I've tested it and it works with mirrored points.

Message 3 of 3

JhoelForshav
Mentor
Mentor

Hi @NickBrege 

I havn't done a lot of testing but how about this approach? 🙂

If the mirror plane is a workplane and the hole feature is based on sketch points it should work?

 

Dim oDoc As PartDocument = ThisDoc.Document
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim oMirror As MirrorFeature = oDef.Features.MirrorFeatures.Item("Mirror1")

Dim originalPoints As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim mirroredPoints As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection

For Each oFeature As PartFeature In oMirror.Definition.ParentFeatures
	If TypeOf (oFeature) Is HoleFeature
		Dim oHole As HoleFeature = oFeature
		For Each sPoint As SketchPoint In oHole.HoleCenterPoints
			originalPoints.Add(sPoint.Geometry3d)
		Next
	End If
Next
Dim oPlane As Plane = oMirror.Definition.MirrorPlaneEntity.Plane
For Each oPoint As Point In originalPoints
	Dim dD As Double
	dD = -(oPlane.RootPoint.X * oPlane.Normal.X + oPlane.RootPoint.Y *
	oPlane.Normal.Y + oPlane.RootPoint.Z * oPlane.Normal.Z)

	Dim MinDistPointToPlane As Double = (oPlane.Normal.X * oPoint.X + oPlane.Normal.Y *
	oPoint.Y + oPlane.Normal.Z * oPoint.Z + dD) / Sqrt(oPlane.Normal.X ^ 2 +
	oPlane.Normal.Y ^ 2 + oPlane.Normal.Z ^ 2)
	
	Dim oNewPoint As Point = oPoint.Copy
	Dim oVector As Vector = oPlane.Normal.AsVector
	oVector.ScaleBy(MinDistPointToPlane * (-2))
	
	oNewPoint.TranslateBy(oVector)
	mirroredPoints.Add(oNewPoint)
Next

'You now have an objectcollection for the original points and an objectcollection for the mirrored points
'Let's create some workpoints to see that they're correct.
For Each oPoint As Point In originalPoints
	oDef.WorkPoints.AddFixed(oPoint)
Next
For Each oPoint As Point In mirroredPoints
	oDef.WorkPoints.AddFixed(oPoint)
Next