Reply
Solved! Go to solution

Problem Deleting Ground Relation

Hi!

 

I add occurences to my assembly file and in order to build the relationships among them, I want to delete the Ground relation (It was suggested somewhere but I don't remember where I read it, I think it was somewhere in the documentation).

 

But for some occurences, calling " occurrence5.Relations3d.Item[1].Delete(); " for example, is causing SE to close at the end of the assembling.

 

I working in code wirten by another developer. I don't know if theres's some problem in the code he wrote to make the part. I revised his code and I couldn't identify mistakes.

 

Has anyone had this problem yet ???

 

Thanx !

3 REPLIES

Re: Problem Deleting Ground Relation

I believe, the following code should work:

'----------------------------------------------------------------------
' Delete the ground relation of all occurrences in the toplevel assembly
'----------------------------------------------------------------------
Dim objDoc As SolidEdgeAssembly.AssemblyDocument = objApp.ActiveDocument
For Each objOcc As SolidEdgeAssembly.Occurrence In objDoc.Occurrences
  Dim objRels3d As SolidEdgeAssembly.Relations3d = objOcc.Relations3d
  For Each objRel In objRels3d
    Dim relationType As Integer = objRel.GetType().InvokeMember("Type", Reflection.BindingFlags.GetProperty, Nothing, objRel, Nothing)
    If relationType = SolidEdgeFramework.ObjectType.igGroundRelation3d Then
      objRel.GetType().InvokeMember("Delete", Reflection.BindingFlags.InvokeMethod, Nothing, objRel, Nothing)
      Exit For
    End If
  Next
Next

 

Solution
Solution
Accepted by topic author Marcio_Lima
‎08-26-2015 04:32 AM

Re: Problem Deleting Ground Relation

Thanx Martin!!!

 

This code really works!!!

 

 

Re: Problem Deleting Ground Relation

Try it: (C#)

 

AssemblyDocument montagem = null;
Relations3d relMontagem= null;
// Código
relMontagem = montagem.Relations3d;
                foreach (var relationType in relMontagem )
                {
                    var relationObjectType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue<SolidEdgeFramework.ObjectType>(relationType, "Type", (SolidEdgeFramework.ObjectType)0);
                    if (relationObjectType==SolidEdgeFramework.ObjectType.igGroundRelation3d)
                    {
                        GroundRelation3d groundDeletar = (GroundRelation3d)relationType;
                        groundDeletar.Delete();
                    }
}


==========================
Kabir Costa
Industrial Designer
kabircosta@gmail.com