Imports System.IO
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 SEInstallDir As DirectoryInfo
Dim objAssemblyDocument As SolidEdgeAssembly.AssemblyDocument = Nothing
Dim objAsmRefPlanes As SolidEdgeAssembly.AsmRefPlanes
Dim objAsmRefPlane As SolidEdgeAssembly.AsmRefPlane
Dim objOcc As SolidEdgeAssembly.Occurrence = Nothing
Dim AssyPatterns As SolidEdgeAssembly.AssemblyPatterns = Nothing
Dim AssyPattern As SolidEdgeAssembly.AssemblyPattern = Nothing
Dim curve1 As SolidEdgeGeometry.Curve = Nothing
Dim objLayouts As SolidEdgeAssembly.Layouts = Nothing
Dim objLayout As SolidEdgeAssembly.Layout = Nothing
Dim objProfile As SolidEdgePart.Profile = Nothing
Dim curvebody As SolidEdgeGeometry.CurveBody = Nothing
Dim occArray As System.Array = Array.CreateInstance(GetType(SolidEdgeAssembly.Occurrence), 1)
Dim curveArray As System.Array = Array.CreateInstance(GetType(SolidEdgeGeometry.Curve), 1)
Try
objApplication = Marshal.GetActiveObject("SolidEdge.Application")
SEInstallDir = GetTrainingFolder()
objAssemblyDocument = objApplication.Documents.Open(SEInstallDir.FullName + "\carrier.asm")
objAsmRefPlanes = objAssemblyDocument.AsmRefPlanes
objAsmRefPlane = objAsmRefPlanes.AddParallelByDistance(objAsmRefPlanes(0), 0.02111)
objLayouts = objAssemblyDocument.Layouts
objLayout = objLayouts.Add(objAsmRefPlane)
objProfile = objLayout.Profile
'objProfile.Lines2d.AddBy2Points(0.0, 0.0, 0.0, 1)
objProfile.Arcs2d.AddByCenterStartEnd(0.0, 0.0, -1.0, 0.0, 1.0, 0.0)
objProfile = objLayout.Profile
curvebody = objProfile.CurveBody
curve1 = curvebody.Curves.Item(0)
curveArray(0) = curve1
AssyPatterns = objAssemblyDocument.AssemblyPatterns
objOcc = objAssemblyDocument.Occurrences.Item(1)
occArray(0) = objOcc
AssyPatterns.CreateAlongCurve(1, occArray, 1, curveArray, curve1.CurveVertices(0), SolidEdgePart.PatternCurveAnchorSideConstants.sePatternCurveRightSide, 0,
SolidEdgeAssembly.PatternOffsetTypeConstants.sePatternFitOffset, 4, 3, 0, occArray, 0, Nothing, 0, Nothing, 0, 0,
SolidEdgePart.PatternTransformTypeConstants.sePatternTransformLinear, SolidEdgePart.PatternTransformRotateTypeConstants.sePatternTransformRotateOnCurvePosition, Nothing, "Test Pattern")
AssyPattern = AssyPatterns.Item(1)
Dim msg = MsgBox("Do you want to edit this pattern?", MsgBoxStyle.YesNo, "Pattern along curve")
If msg = MsgBoxResult.Yes Then
AssyPattern.EditAlongCurve(1, occArray, 1, curveArray, curve1.CurveVertices(0), SolidEdgePart.PatternCurveAnchorSideConstants.sePatternCurveRightSide, 0,
SolidEdgeAssembly.PatternOffsetTypeConstants.sePatternFitOffset, 2, 3, 0, occArray, 0, Nothing, 0, Nothing, 0, 0,
SolidEdgePart.PatternTransformTypeConstants.sePatternTransformLinear, SolidEdgePart.PatternTransformRotateTypeConstants.sePatternTransformRotateOnCurvePosition, Nothing, "Test Pattern")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Function GetTrainingFolder() As DirectoryInfo
Dim objInstallData As SEInstallDataLib.SEInstallData = Nothing
Dim objInstallFolder As DirectoryInfo = Nothing
Dim objTrainingFolder As DirectoryInfo = Nothing
Try
objInstallData = New SEInstallDataLib.SEInstallData
objInstallFolder = New DirectoryInfo(objInstallData.GetInstalledPath())
objTrainingFolder = New DirectoryInfo(Path.Combine(objInstallFolder.Parent.FullName, "Training"))
Catch
Finally
If Not (objInstallData Is Nothing) Then
Marshal.FinalReleaseComObject(objInstallData)
objInstallData = Nothing
End If
End Try
Return objTrainingFolder
End Function
End Class