Cancel
Showing results for 
Search instead for 
Did you mean: 

Detect a mirrored part or assembly

Creator
Creator

In VB.Net, how can I know if a part or an assembly is a mirrored part (assembly)?

 

Thank you in advance for your cooperation.

16 REPLIES 16

Re: Detect a mirrored part or assembly

Legend
Legend

Hi @JonaMeha

 

I haven't found a direct way to achieve this, at least for ST9

 

What I do for PARTS is the next:

  • I look in the Part.Models collection for each Model in the part.
  • then i check if this model has CopiedParts.
  • If it has copiedParts and the copiedPart.Plane property is not null, then the part is a mirrored one.

 

mirror.png

 

For assemblies, I haven't found a solution, what I do is checking the asm name looking for "_mir", but that a file contains "_mir" in his name not necessarily implies that file to be a mirrored one.

 

Hope it helps.

Héctor Pelayo Izquierdo
Engineering Department, JAE Ingeniería y Desarrollos, S.L.
Solid Edge ST9 MP5 | NX 9
Development: VB.NET

Re: Detect a mirrored part or assembly

Valued Contributor
Valued Contributor

Here is a solution for both Part and Assembly types:

    Private Function isAssemblyMirrored(doc As SolidEdgeAssembly.AssemblyDocument)
        Try
            Dim objAssemblyCopies As SolidEdgeAssembly.AssemblyCopies = doc.AssemblyCopies
            Dim objAssemblyCopy As SolidEdgeAssembly.AssemblyCopy = objAssemblyCopies.Item(1)
            Return (objAssemblyCopy.AssemblyCopyType = SolidEdgeAssembly.AssemblyCopyTypeConstants.seAssemblyCopyTypeMirror)
        Catch ex As Exception
        End Try
        Return False
    End Function

    Private Function isPartMirrored(doc As SolidEdgePart.PartDocument)
        Dim ebf As SolidEdgePart.EdgebarFeatures = doc.DesignEdgebarFeatures
        For Each obj As Object In ebf
            Try
                Dim feat As CopiedPart = obj
                Return Not IsNothing(feat.Plane)
            Catch ex As Exception
            End Try
        Next
        Return False
    End Function
________[Oo\____/oO]________

The truth is .... I am Dutch

C# - VS Ex 2015 - Solid Edge ST10 MP3 - TC11.4
Key-User, IT-student, no admin rights

Re: Detect a mirrored part or assembly

Creator
Creator
Hey Hector, Hey JanWillem,

Thank you so much for your all help but none of what you are proposing works.
I once thought it was due to the planes of symmetry I used for my tests, because I used standard reference planes (top, right or front) but in any event...I can't get any result.

Thank you again.

Re: Detect a mirrored part or assembly

Valued Contributor
Valued Contributor

Which one doesn't work? In my case, both functions work.

Can you share a part file that doesn't work for you?

________[Oo\____/oO]________

The truth is .... I am Dutch

C# - VS Ex 2015 - Solid Edge ST10 MP3 - TC11.4
Key-User, IT-student, no admin rights

Re: Detect a mirrored part or assembly

Creator
Creator

Hi,

 

Please find enclosed a compressed file containing the main assembly file ("Asm2.asm") and all its sub-asm and parts.

See no technical consistency in it, it is only used for tests.

More precisely, for processing (collection of description, quantity, etc...) of assemblies and parts in various situations (copied, copy, mirrored, mirror, copy of mirror, mirror of copy, etc...).

 

Hoping you can do something with it.

 

Thanks a lot,

Re: Detect a mirrored part or assembly

Valued Contributor
Valued Contributor

I've modified my code to test on your assembly:

    Private Function checkMirrored(doc As SolidEdgeAssembly.Occurrence)
        If doc.Subassembly Then
            Return isAssemblyMirrored(doc)
        Else
            Return isPartMirrored(doc)
        End If
    End Function

    Private Function isAssemblyMirrored(doc As SolidEdgeAssembly.Occurrence)
        Dim assyDoc As SolidEdgeAssembly.AssemblyDocument = doc.OccurrenceDocument
        Try
            Dim objAssemblyCopies As SolidEdgeAssembly.AssemblyCopies = assyDoc.AssemblyCopies
            Dim objAssemblyCopy As SolidEdgeAssembly.AssemblyCopy = objAssemblyCopies.Item(1)
            If (objAssemblyCopy.AssemblyCopyType = SolidEdgeAssembly.AssemblyCopyTypeConstants.seAssemblyCopyTypeMirror) Then
                Return True
            End If
        Catch ex As Exception
        End Try
        Return False
    End Function

    Private Function isPartMirrored(doc As SolidEdgeAssembly.Occurrence)
        Dim partDoc As SolidEdgePart.PartDocument = doc.OccurrenceDocument
        Dim ebf As SolidEdgePart.EdgebarFeatures = partDoc.DesignEdgebarFeatures
        For Each obj As Object In ebf
            Try
                Dim feat As CopiedPart = obj
                Return Not IsNothing(feat.Plane)
            Catch ex As Exception
            End Try
        Next
        Return False
    End Function

As a test, I ran this code:

Dim Occurences As SolidEdgeAssembly.Occurrences
        Occurences = seADocument.Occurrences
        Dim message As String
        message = "Testing" + vbNewLine
        For index = 1 To Occurences.Count
            Dim doc As SolidEdgeAssembly.Occurrence = Occurences.Item(index)
            message += doc.Name.ToString
            message += "  -  "
            message += checkMirrored(doc).ToString
            message += vbNewLine
        Next
        MsgBox(message)

I believe the result is what you're looking for (see image attached)

________[Oo\____/oO]________

The truth is .... I am Dutch

C# - VS Ex 2015 - Solid Edge ST10 MP3 - TC11.4
Key-User, IT-student, no admin rights

Re: Detect a mirrored part or assembly

Valued Contributor
Valued Contributor

I've modified my code to test on your assembly:

    Private Function checkMirrored(doc As SolidEdgeAssembly.Occurrence)
        If doc.Subassembly Then
            Return isAssemblyMirrored(doc)
        Else
            Return isPartMirrored(doc)
        End If
    End Function

    Private Function isAssemblyMirrored(doc As SolidEdgeAssembly.Occurrence)
        Dim assyDoc As SolidEdgeAssembly.AssemblyDocument = doc.OccurrenceDocument
        Try
            Dim objAssemblyCopies As SolidEdgeAssembly.AssemblyCopies = assyDoc.AssemblyCopies
            Dim objAssemblyCopy As SolidEdgeAssembly.AssemblyCopy = objAssemblyCopies.Item(1)
            If (objAssemblyCopy.AssemblyCopyType = SolidEdgeAssembly.AssemblyCopyTypeConstants.seAssemblyCopyTypeMirror) Then
                Return True
            End If
        Catch ex As Exception
        End Try
        Return False
    End Function

    Private Function isPartMirrored(doc As SolidEdgeAssembly.Occurrence)
        Dim partDoc As SolidEdgePart.PartDocument = doc.OccurrenceDocument
        Dim ebf As SolidEdgePart.EdgebarFeatures = partDoc.DesignEdgebarFeatures
        For Each obj As Object In ebf
            Try
                Dim feat As CopiedPart = obj
                Return Not IsNothing(feat.Plane)
            Catch ex As Exception
            End Try
        Next
        Return False
    End Function

As a test, I ran this code:

Dim Occurences As SolidEdgeAssembly.Occurrences
        Occurences = seADocument.Occurrences
        Dim message As String
        message = "Testing" + vbNewLine
        For index = 1 To Occurences.Count
            Dim doc As SolidEdgeAssembly.Occurrence = Occurences.Item(index)
            message += doc.Name.ToString
            message += "  -  "
            message += checkMirrored(doc).ToString
            message += vbNewLine
        Next
        MsgBox(message)

I believe the result is what you're looking for (see image attached)

________[Oo\____/oO]________

The truth is .... I am Dutch

C# - VS Ex 2015 - Solid Edge ST10 MP3 - TC11.4
Key-User, IT-student, no admin rights

Re: Detect a mirrored part or assembly

Valued Contributor
Valued Contributor

I've modified my code to test on your assembly:

    Private Function checkMirrored(doc As SolidEdgeAssembly.Occurrence)
        If doc.Subassembly Then
            Return isAssemblyMirrored(doc)
        Else
            Return isPartMirrored(doc)
        End If
    End Function

    Private Function isAssemblyMirrored(doc As SolidEdgeAssembly.Occurrence)
        Dim assyDoc As SolidEdgeAssembly.AssemblyDocument = doc.OccurrenceDocument
        Try
            Dim objAssemblyCopies As SolidEdgeAssembly.AssemblyCopies = assyDoc.AssemblyCopies
            Dim objAssemblyCopy As SolidEdgeAssembly.AssemblyCopy = objAssemblyCopies.Item(1)
            If (objAssemblyCopy.AssemblyCopyType = SolidEdgeAssembly.AssemblyCopyTypeConstants.seAssemblyCopyTypeMirror) Then
                Return True
            End If
        Catch ex As Exception
        End Try
        Return False
    End Function

    Private Function isPartMirrored(doc As SolidEdgeAssembly.Occurrence)
        Dim partDoc As SolidEdgePart.PartDocument = doc.OccurrenceDocument
        Dim ebf As SolidEdgePart.EdgebarFeatures = partDoc.DesignEdgebarFeatures
        For Each obj As Object In ebf
            Try
                Dim feat As CopiedPart = obj
                Return Not IsNothing(feat.Plane)
            Catch ex As Exception
            End Try
        Next
        Return False
    End Function

As a test, I ran this code:

Dim Occurences As SolidEdgeAssembly.Occurrences
        Occurences = seADocument.Occurrences
        Dim message As String
        message = "Testing" + vbNewLine
        For index = 1 To Occurences.Count
            Dim doc As SolidEdgeAssembly.Occurrence = Occurences.Item(index)
            message += doc.Name.ToString
            message += "  -  "
            message += checkMirrored(doc).ToString
            message += vbNewLine
        Next
        MsgBox(message)

I believe the result is what you're looking for (see image attached)

________[Oo\____/oO]________

The truth is .... I am Dutch

C# - VS Ex 2015 - Solid Edge ST10 MP3 - TC11.4
Key-User, IT-student, no admin rights

Re: Detect a mirrored part or assembly

Valued Contributor
Valued Contributor

I've modified my code to test on your assembly:

 

    Private Function checkMirrored(doc As SolidEdgeAssembly.Occurrence)
        If doc.Subassembly Then
            Return isAssemblyMirrored(doc)
        Else
            Return isPartMirrored(doc)
        End If
    End Function

    Private Function isAssemblyMirrored(doc As SolidEdgeAssembly.Occurrence)
        Dim assyDoc As SolidEdgeAssembly.AssemblyDocument = doc.OccurrenceDocument
        Try
            Dim objAssemblyCopies As SolidEdgeAssembly.AssemblyCopies = assyDoc.AssemblyCopies
            Dim objAssemblyCopy As SolidEdgeAssembly.AssemblyCopy = objAssemblyCopies.Item(1)
            If (objAssemblyCopy.AssemblyCopyType = SolidEdgeAssembly.AssemblyCopyTypeConstants.seAssemblyCopyTypeMirror) Then
                Return True
            End If
        Catch ex As Exception
        End Try
        Return False
    End Function

    Private Function isPartMirrored(doc As SolidEdgeAssembly.Occurrence)
        Dim partDoc As SolidEdgePart.PartDocument = doc.OccurrenceDocument
        Dim ebf As SolidEdgePart.EdgebarFeatures = partDoc.DesignEdgebarFeatures
        For Each obj As Object In ebf
            Try
                Dim feat As CopiedPart = obj
                Return Not IsNothing(feat.Plane)
            Catch ex As Exception
            End Try
        Next
        Return False
    End Function

As a test, I ran this code:

Dim Occurences As SolidEdgeAssembly.Occurrences
Occurences = seADocument.Occurrences
Dim message As String
message = "Testing" + vbNewLine
For index = 1 To Occurences.Count
  Dim doc As SolidEdgeAssembly.Occurrence = Occurences.Item(index)
  message += doc.Name.ToString
  message += "  -  "
  message += checkMirrored(doc).ToString
  message += vbNewLine
Next
MsgBox(message)

I believe the result is what you're looking for (see image attached)

________[Oo\____/oO]________

The truth is .... I am Dutch

C# - VS Ex 2015 - Solid Edge ST10 MP3 - TC11.4
Key-User, IT-student, no admin rights