Imports System.Runtime.InteropServices
Public Class BoltHoleCircle
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim objApplication As SolidEdgeFramework.Application = Nothing
Dim ObjDraftDoc As SolidEdgeDraft.DraftDocument = Nothing
Dim objSheet As SolidEdgeDraft.Sheet = Nothing
Dim objCircle As SolidEdgeFrameworkSupport.Circle2d = Nothing
Dim objCircle2 As SolidEdgeFrameworkSupport.Circle2d = Nothing
Dim objBoltHoleCircles As SolidEdgeFrameworkSupport.BoltHoleCircles = Nothing
Dim objBoltHoleCircle As SolidEdgeFrameworkSupport.BoltHoleCircle = Nothing
Dim objType As Type = Nothing
Dim x1, y1, x2, y2 As Double
Dim a1, b1, a2, b2 As Double
Try
' 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
ObjDraftDoc = objApplication.ActiveDocument
'getting the Active Sheet object
objSheet = ObjDraftDoc.ActiveSheet
objBoltHoleCircles = objSheet.BoltHoleCircles
objCircle = objSheet.Circles2d.AddByCenterRadius(x:=0.25, y:=0.25, Radius:=0.05)
objCircle2 = objSheet.Circles2d.AddByCenterRadius(x:=0.5, y:=0.5, Radius:=0.05)
objBoltHoleCircle = objBoltHoleCircles.AddBoltHoleCircleBy2Points( _
objCircle, 0, _
objCircle2, 0)
If objBoltHoleCircle.IsDefinedBy2Points() = False Then
MsgBox("Method IsDefinedBy2Points() failed.")
End If
objCircle.GetCenterPoint(x1, y1)
objCircle2.GetCenterPoint(x2, y2)
objBoltHoleCircle.SetTrimArcEndPoints(x1, y1, 0, x2, y2, 0)
objBoltHoleCircle.GetTrimArcEndPoints(a1, b1, 0, a2, b2, 0)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class