Imports System.Runtime.InteropServices
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim objApplication As SolidEdgeFramework.Application = Nothing
Dim objAsmDoc As SolidEdgeAssembly.AssemblyDocument = Nothing
Dim objType As Type = Nothing
Dim Occurrences As SolidEdgeAssembly.Occurrences
Dim Occurrence As SolidEdgeAssembly.Occurrence
Dim objDoc As SolidEdgePart.PartDocument
Dim objEdges As SolidEdgeGeometry.Edges
Dim pathSegarray(12)
Dim objLineSegments As SolidEdgeAssembly.LineSegments = Nothing
Dim objLineSegment As SolidEdgeAssembly.LineSegment = Nothing
Dim objStructuralFrames As SolidEdgeAssembly.StructuralFrames = Nothing
Dim objStructuralFrame As SolidEdgeAssembly.StructuralFrame = Nothing
Dim PartFileName As String
Dim NumPaths As Integer
Dim objPath(0) As Object
Dim StartPoint(0 To 2) As Double
Dim EndPoint(0 To 2) As Double
Try
'Following example will create 2 Frames in an assembly
'First frame will be using a single line and cross section
'Second frame will be using a Body Edges and cross section
'To create second frame you need an assembly file with a square block(part) in it.
' Create/get the application with specific settings
objApplication = Marshal.GetActiveObject("SolidEdge.Application")
If objApplication Is Nothing Then
' Get the type from the Solid Edge ProgID
objType = Type.GetTypeFromProgID("SolidEdge.Application")
' Start Solid Edge
objApplication = Activator.CreateInstance(objType)
' Make Solid Edge visible
objApplication.Visible = True
End If
'Get reference to active document
objAsmDoc = objApplication.ActiveDocument()
PartFileName = "C:\Program Files (x86)\Solid Edge ST6\Frames\DIN\I-Beam\I-Beam 80x46.par"
StartPoint(0) = 0
StartPoint(1) = 0
StartPoint(2) = 0
EndPoint(0) = 0
EndPoint(1) = 0
EndPoint(2) = 50
objLineSegments = objAsmDoc.LineSegments
objLineSegment = objLineSegments.Add(StartPoint, EndPoint)
NumPaths = 1
objPath(0) = objLineSegments.Item(1)
'obtain frame collection object
objStructuralFrames = objAsmDoc.StructuralFrames
objStructuralFrame = objStructuralFrames.Add(PartFileName, NumPaths, objPath)
'Frame is made invisible to
objStructuralFrame.Visible = False
'getocurrence collection object
Occurrences = objAsmDoc.Occurrences
'get first occurence item
Occurrence = Occurrences.Item(1)
'create reference for edges
objDoc = Occurrence.OccurrenceDocument
objEdges = objDoc.Models.Item(1).ExtrudedProtrusions.Item(1).Edges(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll)
'add refrence of edge to safearray to craete path
For value As Integer = 0 To objEdges.Count()
pathSegarray(value) = objAsmDoc.CreateReference(Occurrence, objEdges.Item(value))
Next
'obtain frame collection object
objStructuralFrames = objAsmDoc.StructuralFrames
' create frame
objStructuralFrame = objStructuralFrames.Add(PartFileName, 12, pathSegarray)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class