Matchcoordinate system between occurrence and SubOccurrence

Pioneer
Pioneer

Hi ,

I have structure in Solid Edge assembly like this.

TreeStr.png

I want to add Match coordinate system between Level_1_B.Par:1 and box.par:1 using API automation.

I have tried manually and it is working. 

 

I have tried some of the approaches but for this case exception is coming when I am trying to use Solid Edge API.

relation3D = seAsmDoc.Relations3d;
planar = relation3D.AddPlanar( );

 

Is there any sample code available so that I refer the same and change my codes accordingly. 

 

Note: I don't have sample driver currently for this scenario. I will update description as soon as I will prepare. 

Also I have used createReference() API's when getting the objects. In case of suboccurence (box1)maybe that value is not coming correctly or some issues.

 

Thanks in advance. Please let me know.

 

Regards,

Onkarp

 

4 REPLIES

Re: Matchcoordinate system between occurrence and SubOccurrence

Pioneer
Pioneer

No replies on this.

Can anybody check this ?

Re: Matchcoordinate system between occurrence and SubOccurrence

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Based on your test files, you should create the following references to the planes in each occurrence to get a valid "Match Coordinate Systems" relation:

'----------------------------------------------------------------------
' ASM: Create a "Match Coordinate Systems" relation between two occurrences
'----------------------------------------------------------------------
Dim topLevelDoc As SolidEdgeAssembly.AssemblyDocument = objApp.ActiveDocument

' Get the two occurrences and their documents
Dim level1AOcc As Occurrence = topLevelDoc.Occurrences.Item(1)
Dim level1BOcc As Occurrence = topLevelDoc.Occurrences.Item(2)
Dim level1ADoc As AssemblyDocument = level1AOcc.OccurrenceDocument
Dim level1BDoc As PartDocument = level1BOcc.OccurrenceDocument
Dim boxOcc As Occurrence = level1ADoc.Occurrences.Item(1)
Dim boxDoc As PartDocument = boxOcc.OccurrenceDocument

' Ensure that the Level_1_B occurrence is NOT grounded
Dim level1BRels As Relations3d = level1BOcc.Relations3d
If level1BRels.Count > 0 Then
  ' Delete any existing ground relation
  For Each rel In level1BRels
    Dim relationType As Integer = rel.GetType().InvokeMember("Type", Reflection.BindingFlags.GetProperty, Nothing, rel, Nothing)
    If relationType = SolidEdgeFramework.ObjectType.igGroundRelation3d Then
      rel.GetType().InvokeMember("Delete", Reflection.BindingFlags.InvokeMethod, Nothing, rel, Nothing)
      Exit For
    End If
  Next
End If

' Get the three reference planes of the box occurrence
Dim boxPlane1 As SolidEdgePart.RefPlane = boxDoc.RefPlanes.Item(1)
Dim boxPlane2 As SolidEdgePart.RefPlane = boxDoc.RefPlanes.Item(2)
Dim boxPlane3 As SolidEdgePart.RefPlane = boxDoc.RefPlanes.Item(3)

' Create references to the three reference planes of the box occurrence
Dim refToBoxPlane1 As Reference = topLevelDoc.CreateReference(level1AOcc, level1ADoc.CreateReference(boxOcc, boxPlane1))
Dim refToBoxPlane2 As Reference = topLevelDoc.CreateReference(level1AOcc, level1ADoc.CreateReference(boxOcc, boxPlane2))
Dim refToBoxPlane3 As Reference = topLevelDoc.CreateReference(level1AOcc, level1ADoc.CreateReference(boxOcc, boxPlane3))

' Create a reference to the three reference planes of the Level_1_B occurrence
Dim refToLevel1BPlane1 As Reference = topLevelDoc.CreateReference(level1BOcc, level1BDoc.RefPlanes.Item(1))
Dim refToLevel1BPlane2 As Reference = topLevelDoc.CreateReference(level1BOcc, level1BDoc.RefPlanes.Item(2))
Dim refToLevel1BPlane3 As Reference = topLevelDoc.CreateReference(level1BOcc, level1BDoc.RefPlanes.Item(3))

' Create the three planar relations
Dim pnt1(2) As Double
Dim pnt2(2) As Double
topLevelDoc.Relations3d.AddPlanar(refToLevel1BPlane1, refToBoxPlane1, False, pnt1, pnt2)
topLevelDoc.Relations3d.AddPlanar(refToLevel1BPlane2, refToBoxPlane2, False, pnt1, pnt2)
topLevelDoc.Relations3d.AddPlanar(refToLevel1BPlane3, refToBoxPlane3, False, pnt1, pnt2)

Re: Matchcoordinate system between occurrence and SubOccurrence

Pioneer
Pioneer

Martin,

 

Thanks for help. This worked.

Is there any documentation about how to add relations in Solid Edge?

I have following questions about adding relationships:

How to decide when to create reference and when to not for feature object ?(If occurence or suboccurrence is "SubAssembly")

Is it correct to create constrainst always with respect to Top Level document ?

Is creating constraint with respect to (Reference to ) top level and at individual document level is different ?

Can you please help so that it can help me to work with other relationships also.

 

Thanks in Advance,

OnkarP

Re: Matchcoordinate system between occurrence and SubOccurrence

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Is there any documentation about how to add relations in Solid Edge?

There is no general documentation on how to add relations, but you can check the sample which is included in the documentation of the AddPlanar method.

 

How to decide when to create reference and when to not for feature object ?

In general, you will ALWAYS need to reference another object in Solid Edge, if it is NOT directly accessible in the SAME document (at least for ASM, in DFT you may also need to reference objects between different sheets).

So when you create an assembly relationship, let's say a planar relation on the toplevel document, you will need to create a reference, if the related face/plane is in any other document on a lower assembly level, and you can use the plane directly, if it exists directly in the toplevel assembly, e.g. any of the 3 assembly reference planes.

If you need to access a topology in any lower level, you will need to recursively create the references starting from the lowest level until the assembly document, where you want to create the relationship.

topLevel
  +--- upperAsm
          +--- lowerAsm
                  +--- lowestPar

ref1 = lowerAsm_Doc.CreateReference(lowestPar_Occ, Face_in_lowestPar)
ref2 = upperAsm_Doc.CreateReference(lowerAsm_Occ, ref1)
refToFace = topLevel_Doc.CreateReference(upperAsm_Occ, ref2)

 

Is it correct to create constrainst always with respect to Top Level document ?

The constraints themselves do not need to be in the toplevel document, as long as they are created in a common parent document of both objects to be related in the constraint.

 

Is creating constraint with respect to (Reference to ) top level and at individual document level is different ?

Creating references on the toplevel or in any other sublevel assembly is almost the same with only one difference. You will stop creating your references already on the sublevel assembly, where you are going to create the relations. For that reason, is it much easier and more logical in terms of reusage to create the relations on the lowest level possible.

 

Can you please help so that it can help me to work with other relationships also.

I hope, I could help a little...Smiley Wink