Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

How to add planar Distance Mates between two parts in assembly ?

Pioneer
Pioneer

Hi all,

 

I am able to programmatically add planar coincident mate between reference planes of two parts.

 

But how to give distance mate ?

 

I tried different values of the system arrays but everytime it creates coincident mates only

 

Looking for your inputs. Thanks.

2 REPLIES 2

Re: How to add planar Distance Mates between two parts in assembly ?

Siemens Phenom Siemens Phenom
Siemens Phenom

@mdspl when you call Relations3d.AddPlanar, it returns a PlanarRelation3d object. On the PlanarRelation3d object that is returned, I believe you just need to set the Offset property to the desired offset.

 

Greg

Re: How to add planar Distance Mates between two parts in assembly ?

Pioneer
Pioneer

Hi Greg, thanks a lot. It worked.

 

My code which works as expected (it creates distance mate) is as follows :

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'se variables
Dim oapp As SolidEdgeFramework.Application
Dim oasm As SolidEdgeAssembly.AssemblyDocument
Dim comp1name As String = "boss.par"
Dim comp2name As String = "cyl.par"
Dim ooccu1, ooccu2 As SolidEdgeAssembly.Occurrence

oapp = Marshal.GetActiveObject("SolidEdge.Application")
oasm = oapp.ActiveDocument

For j = 1 To oasm.Occurrences.Count
Dim crocname As String = oasm.Occurrences.Item(j).Name
If crocname.Substring(0, crocname.LastIndexOf(":")) = comp1name Then
ooccu1 = oasm.Occurrences.Item(j)
End If
Next

For j = 1 To oasm.Occurrences.Count
Dim crocname As String = oasm.Occurrences.Item(j).Name
If crocname.Substring(0, crocname.LastIndexOf(":")) = comp2name Then
ooccu2 = oasm.Occurrences.Item(j)
End If
Next

Dim opart1 As SolidEdgePart.PartDocument = ooccu1.OccurrenceDocument
Dim opart2 As SolidEdgePart.PartDocument = ooccu2.OccurrenceDocument
Dim part1refpl, part2refpl As SolidEdgePart.RefPlane
Dim orel3d1 As Reference
Dim orel3d2 As Reference
Dim temprefname As String

For j = 1 To opart1.RefPlanes.Count

Try
temprefname = opart1.RefPlanes.Item(j).EdgebarName
If opart1.RefPlanes.Item(j).EdgebarName = "Top (xy)" Then
part1refpl = opart1.RefPlanes.Item(j)
Exit For
End If
Catch ex As Exception

End Try

Next

For j = 1 To opart2.RefPlanes.Count
Try
temprefname = opart2.RefPlanes.Item(j).EdgebarName
If opart2.RefPlanes.Item(j).EdgebarName = "Top (xy)" Then
part2refpl = opart2.RefPlanes.Item(j)
Exit For
End If
Catch ex As Exception

End Try

Next

orel3d1 = oasm.CreateReference(ooccu1, part1refpl)

orel3d2 = oasm.CreateReference(ooccu2, part2refpl)

Dim firstrel As SolidEdgeAssembly.PlanarRelation3d

Dim arrDou1 As Array = Array.CreateInstance(Type.GetType("System.Double"), 3)
Dim arrDou2 As Array = Array.CreateInstance(Type.GetType("System.Double"), 3)
'arrDou1 = {0.0, 0.0, 0.0}
'arrDou2 = {0.0, 0.0, 0.0}

firstrel = oasm.Relations3d.AddPlanar(orel3d1, orel3d2, False, arrDou1, arrDou2)
firstrel.Offset = 0.2

End Sub