Suboccurrences not visible...?

 

Hi there

This might be a simple task, but i am very much confused how to solve it. And want your help.

I am openning an assembly. It consists of several parts and a subassembly.

All are hide. I am making visible all the stuff. Parts and subassembly is getting visible.

But the suboccurrences(parts in subassembly) are not getting visible.

I am doing following:

Dim oSEApp As SolidEdgeFramework.Application

Dim oSEAsm As SolidEdgeAssembly.AssemblyDocument

Dim oSuboccs As SolidEdgeAssembly.SubOccurrences

Dim objOccs As SolidEdgeAssembly.Occurrences

Dim pc as integer

oSEApp = GetObject(, "SolidEdge.Application")

oSEAsm = oSEApp.Documents.Open(path & "\" & "XYZ.asm")

oSEApp.DisplayAlerts = False

objOccs = oSEAsm.Occurrences

       For pc = 1 To objOccs.Count

           objOccs.Item(pc).Visible = True

       Next

Thanks in Advance

 

 

Posted by: Prasad Pawar
Post date: 11/5/2007 8:34:04 PM

9 REPLIES

RE: Suboccurrences not visible...?

I tried using SubOccurrences properties and methods also. But it didnt worked for me.

 

Posted by: Prasad Pawar
Post date: 11/5/2007 8:35:31 PM

RE: Suboccurrences not visible...?

is there any option to show all the occurrences (including suboccurrences) of an assembly as we do it manually.

i tried this also:

For pc = 1 To objOccs.Count

objOcc = objOccs.Item(pc)

objOcc.Visible = True

If objOcc.Subassembly Then

oSuboccs = objOcc.SubOccurrence

oSuboccs.Item(1).Visible = True

End If

Next

 

but this is also not working. any suggetion?

 

Posted by: Prasad Pawar
Post date: 11/5/2007 10:00:27 PM

RE: Suboccurrences not visible...?

 

Try this:

 

Dim oSEApp As SolidEdgeFramework.Application

Dim oSEAsm As SolidEdgeAssembly.AssemblyDocument

Dim oSuboccs As SolidEdgeAssembly.SubOccurrences

Dim objOccs As SolidEdgeAssembly.Occurrences

Dim pc As Integer

Dim x

Set oSEApp = GetObject(, "SolidEdge.Application")

Set oSEAsm = oSEApp.ActiveDocument

oSEApp.DisplayAlerts = False

Set objOccs = oSEAsm.Occurrences

       For pc = 1 To objOccs.Count

            If objOccs.Item(pc).Subassembly = True Then

                For x = 1 To objOccs.Item(pc).SubOccurrences.Count

                objOccs.Item(pc).SubOccurrences.Item(x).Visible = True

                Next

            End If

           objOccs.Item(pc).Visible = True

       Next

 

This works for me ...

 

Posted by: Bill Ledbetter
Post date: 11/6/2007 10:14:04 AM

RE: Suboccurrences not visible...?

hi

it is not working and giving the following error:

Object reference not set to an instance of an object.

 

Posted by: Prasad Pawar
Post date: 11/6/2007 5:39:37 PM

RE: Suboccurrences not visible...?

 

Hi prasad,

try to open your asm document as follows:

Override configuration "all parts activated" by adding 2 linefeed separated statements to your asm filename to be opened.

oSEAsm = oSEApp.Documents.Open(path & "\" & "XYZ.asm" & vbLf & "Foobar" & vbLf & "2")

Best regards,

Wolfgang Kunert

www.wksyspro.de

 

 

Posted by: Wolfgang Kunert
Post date: 11/6/2007 11:15:51 PM

RE: Suboccurrences not visible...?

 

Sub Main()

'

' Connect to Solid Edge.

'

Dim oSEApp As SolidEdgeFramework.Application

Dim oSEAsm As SolidEdgeAssembly.AssemblyDocument

Dim oSuboccs As SolidEdgeAssembly.SubOccurrences

Dim objOccs As SolidEdgeAssembly.Occurrences

Dim pc As Integer

Dim x

Set oSEApp = GetObject(, "SolidEdge.Application")

Set oSEAsm = oSEApp.ActiveDocument

oSEApp.DisplayAlerts = False

Set objOccs = oSEAsm.Occurrences

       For pc = 1 To objOccs.Count

        objOccs.Item(pc).Visible = True

            If objOccs.Item(pc).Subassembly = True Then

                oSEAsm.Occurrences.Item(pc).Select True

                For x = 1 To objOccs.Item(pc).SubOccurrences.Count

                objOccs.Item(pc).SubOccurrences.Item(x).Visible = True

                Next

            End If

       Next

End Sub

 

I added the line above in BOLD, because I noticed that if the Subassembly wasn't expanded, then the program was failing. Also, check to make sure you have all of your required reference libraries loaded in your project. The only thing I have different from your code is that I am using an assembly already open.

One more thing, how many sub-levels deep are you trying to go?

 

Posted by: Bill Ledbetter
Post date: 11/7/2007 2:12:50 AM

RE: Suboccurrences not visible...?

Hi Bill and Wolfgang Kunert

thanks for your reply. But it is still not working and giving me the same error on the following line:

objOccs.Item(pc).SubOccurrences.Item(x).Visible = True

 

Only upto 2 levels i am going.(main assembly and a subasm)

 

 

Posted by: Prasad Pawar
Post date: 11/12/2007 3:38:05 PM

RE: Suboccurrences not visible...?

This shoul work

 

Module Module1

 

Sub main()

 

Dim oSEApp As SolidEdgeFramework.Application

Dim oSEAsm As SolidEdgeAssembly.AssemblyDocument

Dim objOccs As SolidEdgeAssembly.Occurrences

 

oSEApp = GetObject(, "SolidEdge.Application")

 

oSEAsm = oSEApp.ActiveDocument

objOccs = oSEAsm.Occurrences()

visibleOccurrences(objOccs)

 

End Sub

 

 

Sub visibleOccurrences(ByVal objOccs As SolidEdgeAssembly.Occurrences)

 

Dim objOcc As SolidEdgeAssembly.Occurrence

Dim subOccs As SolidEdgeAssembly.SubOccurrences

 

For Each objOcc In objOccs

 

objOcc.Visible = True

If objOcc.Subassembly = True Then

subOccs = objOcc.SubOccurrences

visibleSubOccurrences(subOccs)

End If

Next

End Sub

 

 

Sub visibleSubOccurrences(ByVal objSubOccs As SolidEdgeAssembly.SubOccurrences)

 

Dim objSubOcc As SolidEdgeAssembly.SubOccurrence

 

For Each objSubOcc In objSubOccs

 

objSubOcc.Visible = True

If objSubOcc.Subassembly = True Then

objSubOccs = objSubOcc.SubOccurrences

visibleSubOccurrences(objSubOccs)

End If

Next

End Sub

 

End Module

 

Posted by: Martin Rendler
Post date: 11/12/2007 9:51:59 PM

RE: Suboccurrences not visible...?

Hi all,

Thanks for your suggestions. The earlier code is working fine now. I dont know how but i got what i wanted.

Thanks again.

 

Posted by: Prasad Pawar
Post date: 11/15/2007 3:52:16 PM