Cancel
Showing results for 
Search instead for 
Did you mean: 

Solid Edge Assembly API Tutorials

Creator
Creator

Can someone share link to SE assembly API tutorials ? Thanks.

2 REPLIES

Re: Solid Edge Assembly API Tutorials

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

What kind of task do you wish to accomplish using the Assembly API.

 

Here are a few samples to help you learn the Assembly API:

https://github.com/SolidEdgeCommunity/Samples/tree/master/Assembly

Re: Solid Edge Assembly API Tutorials

Creator
Creator

Thanks Tushar. I am trying to mate new component by distance mate with existing component. The code is as follows for co-incident mate, but I want to add distance mate. Can you help ?

 

Private Sub btnTestSePlnrDistMate_Click(sender As Object, e As EventArgs) Handles btnTestSePlnrDistMate.Click
Dim oapp As SolidEdgeFramework.Application
Dim odocs As SolidEdgeFramework.Documents
Dim odoc As SolidEdgeDocument
Dim oasm As SolidEdgeAssembly.AssemblyDocument
Dim opart As SolidEdgePart.PartDocument
Dim opartp As SolidEdgePart.PartDocument
Dim ooccu As SolidEdgeAssembly.Occurrence
Dim ooccup As SolidEdgeAssembly.Occurrence

Dim prefpl, crefpl As SolidEdgePart.RefPlane
Dim orel3d As Reference
Dim orel3d2 As Reference
Dim firstrel As SolidEdgeAssembly.PlanarRelation3d

Dim ogroundrel As SolidEdgeAssembly.GroundRelation3d

Dim arrDou1 As Array
Dim arrDou2 As Array
Dim cref, pref As String

Try
oapp = Marshal.GetActiveObject("SolidEdge.Application")
oapp.Visible = True
Catch ex As Exception
End Try
If oapp Is Nothing Then
Dim acType As Type = Type.GetTypeFromProgID("SolidEdge.Application")
oapp = CType(Activator.CreateInstance(acType, True), SolidEdgeFramework.Application)
oapp.Visible = True
End If
odocs = oapp.Documents
For i = 0 To odocs.Count - 1
odoc = odocs(i)
odoc.Close(True)
Next
Dim AsmPath = txtAsmPath.Text
Dim ParentNameWithExt = txtParentNamewithExt.Text
Dim ChildPath = txtChildPath.Text
oapp.Documents.Open(AsmPath)
oasm = oapp.ActiveDocument

Dim ooccus As SolidEdgeAssembly.Occurrences
ooccus = oasm.Occurrences
ooccu = ooccus.AddByFilename(ChildPath)

For j = 1 To oasm.Occurrences.Count
Dim CurOccName As String = oasm.Occurrences.Item(j).Name
If CurOccName.Substring(0, CurOccName.LastIndexOf(":")) = ParentNameWithExt Then
ooccup = oasm.Occurrences.Item(j)
Exit For
End If
Next

opart = ooccu.OccurrenceDocument
opartp = ooccup.OccurrenceDocument

cref = "Front (xz)"
pref = "Front (xz)"

For j = 1 To opartp.RefPlanes.Count - 1
If opartp.RefPlanes.Item(j).EdgebarName = pref Then

prefpl = opartp.RefPlanes.Item(j)
End If
Next

For j = 1 To opart.RefPlanes.Count - 2
If opart.RefPlanes.Item(j).EdgebarName = cref Then
crefpl = opart.RefPlanes.Item(j)
End If
Next

orel3d = oasm.CreateReference(ooccup, prefpl)
orel3d2 = oasm.CreateReference(ooccu, crefpl)

ogroundrel = oasm.Relations3d.Item(2)
Call ogroundrel.Delete()

arrDou1 = Array.CreateInstance(Type.GetType("System.Double"), 3)
arrDou2 = Array.CreateInstance(Type.GetType("System.Double"), 3)

firstrel = oasm.Relations3d.AddPlanar(orel3d, orel3d2, False, arrDou1, arrDou2)

End Sub