Reply

Deleting Multiple Occurrences in an Assembly

[ Edited ]

 

Does anyone know how to correctly delete multiple occurences from an assembly?

I tried adding the occurrences to a SelectSet and then doing a SelectSet.Delete

but that causes Solid Edge to crash.

 

I noticed that if I did this on a part that had no constraints, the delete worked

but the pathfinder did not update.

 

Do I need to delete the relationships to other occurences before I can delete the

occurrence itself, using the SelectSet?

 

I'd like to save processing time by not deleting each part separately, that is why

I am using SelectSet.

 

-------------------

Carl Breving

cbreving@sandc.com

S&C Electric

-------------------

 

 

Posted by: Carl Breving
Post date: 3/6/2007 3:53:20 PM

7 REPLIES

RE: Deleting Multiple Occurrences in an Assembly

[ Edited ]

Carl,

 

If you'll reply with a .zip of an example assembly and example source, I'll look into it for you. I would create the assmebly myself but you have to remember that I'm not much of a Solid Edge user .

 

Thanks.

 

Posted by: Jason Newell
Post date: 3/8/2007 5:33:28 AM

RE: Deleting Multiple Occurrences in an Assembly

[ Edited ]

Jason.

 

I have included a simple assembly and the code.

 

The code also contains a detailed explanation of what I am trying to accomplish.

 

Thanks.

Carl

 

Posted by: Carl Breving
Post date: 3/9/2007 4:57:33 AM

RE: Deleting Multiple Occurrences in an Assembly

[ Edited ]

Whoops, here are the files

 

Posted by: Carl Breving
Post date: 3/9/2007 5:03:03 AM

RE: Deleting Multiple Occurrences in an Assembly

[ Edited ]

Carl,

 

Sorry for not getting back sooner. I used this VB.NET code in V20 Beta and I had no problems whatsoever.

 

 

Dim objApp As SolidEdgeFramework.Application

Dim objAsm As SolidEdgeAssembly.AssemblyDocument

Dim objOccurrences As SolidEdgeAssembly.Occurrences

Dim objOccurrence As SolidEdgeAssembly.Occurrence

 

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

Set objAsm = objApp.ActiveDocument

Set objOccurrences = objAsm.Occurrences

 

Do While objOccurrences.Count > 0

objOccurrence = objOccurrences.Item(1)

objOccurrence.Delete()

Loop

 

 

Posted by: Jason Newell
Post date: 3/14/2007 2:54:00 PM

RE: Deleting Multiple Occurrences in an Assembly

[ Edited ]

Jason.

 

I am aware of the method you are using, objOccurrence.Delete(), and I have no problem with it.

 

However, this will delete each occurrence one at a time and I believe Solid Edge will process changes after each delete (I assume). If I am deleting a large number of occurrences I'd like to reduce the processing SE is doing between deletes. I am looking to select all of the occurrences I want using SelectSet and then delete all of them together.

 

With the SelectSet method I get a crash when I do SelectSet.Delete, but I do not get a crash when I add them to the SelectSet and then do:

Call objSE.StartCommand(AssemblyEditDelete)

 

So I'm wondering if there is a way to do it with SelectSet.Delete. I have a feeling there may be something I need to do prior to that, like delete any references between those parts and others in the assy.

 

Since the StartCommand works, it may not be worth investigating, except to see if it is possible. So don't put too much effort into it except for curiosities sake.

 

Thanks.

Carl

 

Posted by: Carl Breving
Post date: 3/15/2007 4:46:45 AM

RE: Deleting Multiple Occurrences in an Assembly

[ Edited ]

Carl,

 

Sorry for not getting you what you wanted the 1st time. Try this:

 

 

Dim objApp As SolidEdgeFramework.Application

Dim objAsm As SolidEdgeAssembly.AssemblyDocument

Dim objOccurrences As SolidEdgeAssembly.Occurrences

Dim objOccurrence As SolidEdgeAssembly.Occurrence

 

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

Set objAsm = objApp.ActiveDocument

 

objApp.ActiveSelectSet.RemoveAll()

objOccurrences = objAsm.Occurrences

 

For Each objOccurrence In objOccurrences

objAsm.SelectSet.Add(objOccurrence)

Next

 

objApp.StartCommand(SolidEdgeConstants.AssemblyCommandConstants.AssemblyEditDelete)

 

 

Posted by: Jason Newell
Post date: 3/15/2007 5:36:50 AM

RE: Deleting Multiple Occurrences in an Assembly

[ Edited ]

That is exactly how I ended up doing it. I figured out this method a couple of days after my initial post. I only figured it out after downloading and using Solid Edge Spy.

Thanks for the help.

 

Posted by: Carl Breving
Post date: 3/15/2007 6:46:42 AM