Reply
Solved! Go to solution

Macro Request - select all underconstrained items BOM level 1

Hello all,

 

I have been super busy since SEU15 and have had litterally no time on the community...

 

I'm in need of a quick / dirty macro and wondered if someone had one or would be willing to contribute...

 

The need:

 

From an open assembly, Select all underconstrained items in the active assy. BOM level 1 only.

 

Please and thank you!!!

 

I owe you (the community) one!

 

 

5 REPLIES
Solution
Solution
Accepted by topic author MattJohnsonPAC
‎02-04-2016 08:07 AM

Re: Macro Request - select all underconstrained items BOM level 1

[ Edited ]

Hi Matt

 

Try this in a VB.net console project,

 

Module Module1

    Sub Main()
        Dim objapp As SolidEdgeFramework.Application = SolidEdgeCommunity.SolidEdgeUtils.Connect()
        Dim objASM As SolidEdgeAssembly.AssemblyDocument = Nothing

'Check if active document is an ASM. If not, program exits If objapp.ActiveDocumentType = SolidEdgeFramework.DocumentTypeConstants.igAssemblyDocument Then objASM = objapp.ActiveDocument Else Exit Sub End If

'Remove all objects from selection. objapp.ActiveSelectSet.RemoveAll()
'Iterate for all occurrences at first level. For Each occu As SolidEdgeAssembly.Occurrence In objASM.Occurrences 'If underconstrained add occurrence to selectset
If occu.Status = SolidEdgeAssembly.OccurrenceStatusConstants.seOccurrenceStatusUnderDefined Then objapp.ActiveSelectSet.Add(occu) End If Next End Sub End Module

The only thing you have to do is to add the Community and the Solid Edge Nuget packages to the project.

 

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: Macro Request - select all underconstrained items BOM level 1

thank you very much!

 

 

Re: Macro Request - select all underconstrained items BOM level 1

i cleaned this up to not update during add to select set...  runs faster...

 

wanted to share .

 

odule Module1

 

Sub Main()

Console.SetWindowSize(1, 1)

Console.Title = "Batch Select UnderConstrained Items..."

Console.WriteLine("Adding items to select set...")

Console.WriteLine("")

Console.WriteLine("HOLD PLEASE...")

 

Dim objapp As SolidEdgeFramework.Application = GetObject(, "solidedge.application") 'try to connect to running instance of SE 'SolidEdgeCommunity.SolidEdgeUtils.Connect()

Dim objASM As SolidEdgeAssembly.AssemblyDocument = Nothing

 

'Check if active document is an ASM. If not, program exits

If objapp.ActiveDocumentType = SolidEdgeFramework.DocumentTypeConstants.igAssemblyDocument Then

objASM = objapp.ActiveDocument

Else

Exit Sub

End If

 

objapp.Interactive = False

objapp.ScreenUpdating = False

 

'Remove all objects from selection

objapp.ActiveSelectSet.RemoveAll()

objapp.ActiveSelectSet.SuspendDisplay()

'Iterate for all occurrences at first level.

For Each occu As SolidEdgeAssembly.Occurrence In objASM.Occurrences

'If underconstrained add occurrence to selectset

If occu.Status = SolidEdgeAssembly.OccurrenceStatusConstants.seOccurrenceStatusUnderDefined Then

objapp.ActiveSelectSet.Add(occu)

End If

Next

objapp.ActiveSelectSet.ResumeDisplay()

objapp.ActiveSelectSet.RefreshDisplay()

objapp.ScreenUpdating = True

objapp.Interactive = True

End Sub

End Module

Re: Macro Request - select all underconstrained items BOM level 1

Thanks for sharing the code fellas. I created a SelectUnderConstrainedOccurrences sample on GitHub to add to the collection.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Macro Request - select all underconstrained items BOM level 1

Thanks for sharing

 

This kind of things is what I forget to implement always. Smiley LOL

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