Get Body that was mirrored

Get Body that was mirrored

Raider_71
Collaborator Collaborator
223 Views
4 Replies
Message 1 of 5

Get Body that was mirrored

Raider_71
Collaborator
Collaborator

Hi I am struggling to find a way to get the body or bodies collection of a Part Mirror feature. Basically, if a Surface Body of a multi-body part was mirrored, instead of mirroring a feature or features.

Please see sample parts attached for clarity.

 

I have tried to retrieve the information from the MirrorFeatureDefinition object but cant seem to find a property that exposes the collection of mirrored surface bodies. The ParentFeatures property is empty in this case because its a not a feature mirror.

 

Any idea?

 

    Function GetExtrudeFeatureFromMirror(oMirrorFeature As Inventor.MirrorFeature) As Inventor.SurfaceBody
        Dim oDef As MirrorFeatureDefinition
        oDef = oMirrorFeature.Definition

        For Each oFeat In oDef.ParentFeatures

        Next

        Return Nothing
    End Function

 

0 Likes
Accepted solutions (1)
224 Views
4 Replies
Replies (4)
Message 2 of 5

C_Haines_ENG
Collaborator
Collaborator

This will show you the name of the first surface body in the mirror feature.

 

Sub Main
	
	Dim oDoc As PartDocument = ThisDoc.Document
	
	Dim oMirror As MirrorFeature = oDoc.ComponentDefinition.Features.MirrorFeatures(1)
	
	MsgBox(oMirror.SurfaceBodies.Item(1).Name)


End Sub
0 Likes
Message 3 of 5

Raider_71
Collaborator
Collaborator

Hi @C_Haines_ENG 

 

Thanks for your reply. I did not think of that, but when I tried your solution, it returns the name "Solid2". I am trying to determine which solid was mirrored to create Solid2. i.e. I need the function to tell me "Solid1" because that was the body which was mirrored to create "Solid2".  

I hope that makes sense?

0 Likes
Message 4 of 5

C_Haines_ENG
Collaborator
Collaborator
Accepted solution

Ah I see. I remember running into this issue a while back, and the solution sucks! This will do what you're looking for, but it requires the code to go through the entire browser tree to find the "Pattern of" nodes. I'm sure there's a way of optimizing this, but this is the most "error free" version.

 

Sub Main

	Dim oDoc As PartDocument = ThisDoc.Document

	Dim oSolidBodyNode As BrowserNode = GetSolidBodyNode

	For Each oSolidNode As BrowserNode In oSolidBodyNode.BrowserNodes

		Dim oPatternNode As String = CheckForPattern(oSolidNode)
		
		If oPatternNode IsNot Nothing Then MsgBox( _
			"Patterened Solid : " & oPatternNode & vbLf & "Created Solid : " & oSolidNode.BrowserNodeDefinition.Label & vbLf)

	Next

End Sub

Function GetSolidBodyNode

	For Each oNode_1 As BrowserNode In ThisDoc.Document.BrowserPanes.Item("Model").TopNode.BrowserNodes

		If oNode_1.BrowserNodeDefinition.Label.Contains("Solid Bodies") Then Return oNode_1

	Next

End Function

Function CheckForPattern(oNode As BrowserNode)

	For Each oSubSolidNode As BrowserNode In oNode.BrowserNodes

		If oSubSolidNode.BrowserNodeDefinition.Label.Contains("Pattern of ")

			Return Replace(Split(oSubSolidNode.BrowserNodeDefinition.Label, ":")(0), "Pattern of ", "")

		End If

	Next
	
	Return Nothing

End Function

 

0 Likes
Message 5 of 5

Raider_71
Collaborator
Collaborator

Hi @C_Haines_ENG, thanks for the workaround. It's crazy that we have to do it this way... @Autodesk PLEASE sort this out and add a method / property for us to get the source solid body(s) of a pattern.

 

Just an FYI, what I have done is build a dictionary upfront by traversing the browser tree once. Because I have to get references many times its much faster this way compared to having to traverse the browser tree for each check.

 

Cheers and thanks again for your help!