Reply

how to select a suboccurrence?

[ Edited ]

 

Hi to everybody.

I'm working on a small search utility to navigate through the assembly tree and select and highlight the occurrences that match the criteria.

Unfortunately,  I'm able to select only the occurrences using the instruction

Call objOccurrence.Select(Replace:=False)

Call objSelectSet.Add(objOccurrence)

if I try to make the same with a suboccurrence the system returns an error as the Select method doesn't exist for the suboccurrence object.

what am I supposed to do to select a suboccurrence?

Thank in advance

 

Posted by: Davide Ricci
Post date: 7/7/2009 8:41:42 PM

5 REPLIES

RE: how to select a suboccurrence?

[ Edited ]

You must add it to the document selecset.

Dim objAsm as SolidEdgeAssembly.AssemblyDocument

Dim objSelSet as SelectSet

Dim objSubOccurrence as SubOccurrence

 

Set objSelSet=objAsm.SelecSet

objSelSet.RemoveAll

objSelectSet.Add objSubOccurrence

 

Posted by: Julian Guillo
Post date: 7/7/2009 9:29:12 PM

RE: how to select a suboccurrence?

[ Edited ]

 

Thanks for the quick reply.

I tried your suggestion but unfortunately it doesn't work. The suboccurrence is put into the selectset but is not highlighted.

I noticed that if i put the suboccurrence in the selectset using

objSelectSet.Add objSubOccurrence

the type of the item in the selectset is igsubOccurrence while if I select the same suboccurrence using the Pathfinder, the type of the item in the selectset is igReference (and , of course, the suboccurrence il highlighted)

Any suggestions?

 

thanks

 

 

 

 

Posted by: Davide Ricci
Post date: 7/7/2009 11:22:11 PM

RE: how to select a suboccurrence?

[ Edited ]

Davide,

Look for Reference object in the SDK help. It's difficult for me to explain that in English. It's clear there.

You are right, selecting by hand in SE you don't get the SubOccurrence object.

What you get is a reference to the Occurrence inside that is inside the Subassembly Occurrence.

I don't know if you are looking for the visual selection effect, you need in your program the Occurrence object, the Reference object or the Suboccurrence object.

Anyway, to get the same effect than selecting by hand try this:

 

Dim oSE As SolidEdgeFramework.Application

Dim oAsm As SolidEdgeAssembly.AssemblyDocument

Dim oRef As Reference

 

Private Sub Command1_Click()

'Connect to Solid Edge.

Set oSE = GetObject(, "solidedge.application")

Set oAsm = oSE.ActiveDocument

oAsm.SelectSet.RemoveAll

'I'm selecting the first occurrence (OCU1) in the first subassembly (SA1)

'The first Occurrence in the main assembly (MA) is the subassembly (SA1)

Set oRef = oAsm.CreateReference(oAsm.Occurrences(1), oAsm.Occurrences(1).SubOccurrences(1).ThisAsOccurrence)

oAsm.SelectSet.Add oRef

 

'oRef is a reference, oRef.Object is the Occurrence object OCU1.

'oRef.Object is the same thing as oAsm.Occurrences(1).OccurrenceDocument.Occurrences(1)

End Sub

 

 

Posted by: Julian Guillo
Post date: 7/8/2009 12:36:42 AM

RE: how to select a suboccurrence?

[ Edited ]

 

that was exactly what I was looking for!!!

Many thanks

Davide

 

Posted by: Davide Ricci
Post date: 7/8/2009 2:12:04 AM

how to select a suboccurrence?

[ Edited ]

:lol: I found solution on the forum.

 

In VBA (I use on Excel)

 

 Set app = GetObject(, "solidedge.application")

 Set act = app.ActiveDocument

 app.ActiveSelectSet.RemoveAll

 Set proP = act.Occurrences.Item(i)

 If 'Occurrences.Item(i) is target object' then

'First level part or Assm.

   Call app.ActiveSelectSet.Add(proP)

 Else

   Set proO = proP.SubOccurrences.Item(i)

   If 'proO is target' then

'Second level'

      Set RefO = act.CreateReference(proP, proO.ThisAsOccurrence)

      Call app.ActiveSelectSet.Add(RefO)

   Else

'Third or more'

jp1:

      Set proP = proO

      Set proO = proP.SubOccurrences.Item(i)

      If 'proO is target' then

         Set proP1 = proO.Parent

         Set proP2 = proP1.Parent

         Set RefP = proP2.OccurrenceDocument.CreateReference _

                  (proP1.ThisAsOccurrence, proO.ThisAsOccurrence)

         Set RefO = proO.TopLevelDocument.CreateReference(proP2, RefP)

         Call app.ActiveSelectSet.Add(RefO)

      Else

         goto jp1

      End If

   End If

 End If

 

Posted by: Shoji Nakahara
Post date: 12/25/2012 3:04:43 AM