Cancel
Showing results for 
Search instead for 
Did you mean: 

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 tried several times to reply, but it fails everytime.

 

Here's is the code in a pastiebin:  https://www.pastiebin.com/5c3f0449d7cb5

It contains 3 functions and a test at the bottom.

I hope it works this way.

 

It gives me the right results as shown in the attached image.

________[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

Legend
Legend

@JanWillem, here it works like a charm.

 

EDIT:

It's funny that solid edge spy doesn't show any item in the AssemblyCopies collection but a step by step debug can get the first item in this collection.AssemblyCopies.png

 

 

 

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

Creator
Creator

Hey JanWillem,

Thanks about it, but maybe I didn't say it quite correctly because your code gives me the list of all mirror occurrences but not mirrored occurrences (copy sources).

I can easily get mirror parts or assemblies by ".IsCopy" property but can't get copy sources ?

For example and following SE 3d model I sent you yesterday:

  • Mirrored occurrences (copy sources) : « Valvaut DN40.asm:1”, “Valvaut DN15.par:1”…
  • Mirror occurrences (result of copying) : « Valvaut DN40_mir.asm:1”, “Valvaut DN15_mir2.par:1”…

 

Thanks,

Re: Detect a mirrored part or assembly

Legend
Legend

hi @JonaMeha,

 

For assemblies:

 

We have the properties SourceDocument (returns an object)  and SourceFilename (returns a string) in the AssemblyCopy object in order to obtain the mirrored asm.

 

Using the @JanWillem code:

 

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)
'Add this file to get the mirrored object Dim seMirroredsource As SolidEdgeAssembly.AssemblyDocument = objAssemblyCopy.SourceDocument If (objAssemblyCopy.AssemblyCopyType = SolidEdgeAssembly.AssemblyCopyTypeConstants.seAssemblyCopyTypeMirror) Then
'objAssemblyCopy.SourceFilename returns the source filename. Return objAssemblyCopy.SourceFilename & " - " & True End If Catch ex As Exception End Try Return False End Function

 

For parts:

We have to access to the CopiedPart object in the Model object of the OccurrenceDocument in order to obtain the source filename.

 

Use this function instead of @JanWillem one:

 

Private Function isMirroredPart(doc As SolidEdgeAssembly.Occurrence)
        For Each model As SolidEdgePart.Model In doc.OccurrenceDocument.Models
            If model.CopiedParts.Count > 0 Then
                For Each copiedPart As SolidEdgePart.CopiedPart In model.CopiedParts
                    Dim plane As SolidEdgePart.RefPlane = Nothing
                    Try
                        Return copiedPart.FileName & " - " & Not IsNothing(copiedPart.Plane)
                    Catch ex As Exception                        
                    End Try
                Next
            End If
        Next
        Return False
    End Function

 

The result is:result.PNG

 

 

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

Creator
Creator

Hey Hector,

 

That's ok now, your code is running well...thanks!

Otherwise and not wanting to waste, I do wonder about 2 points always concerning the same subject : 

* Do you know why the "IsCopied" property does not exist in contrast to "IsPatterned" property regarding occurrences copy ? It is a really strange part of SE architecture !?

* By your code, I can get parent occurrence file name of mirrored parts or assy and that's, of course, nice but might it be possible to get its full name in the tree structure ...I mean and for example "...par:1" ?

 

Thanks you for your cooperation.