Put this code In a standard module:
Option Explicit
Const pi = 3.14159265358979
Public SlotLengths As Double
Public SlotDias As Double
Function dtr(a As Double) As Double
dtr = (a / 180) * pi
End Function
Sub Slots()
Dim InsertPoint As Variant
Dim SlotLength As Double
Dim SlotDia As Double
Dim Prompt1 As String
Dim Prompt2 As String
Dim Prompt3 As String
Dim pt1 As Variant
Dim pt2 As Variant
Dim pt3 As Variant
Dim pt4 As Variant
Dim pt5 As Variant
Dim pt6 As Variant
Dim pt7 As Variant
Dim LineObj As AcadLine
Dim ArcObj As AcadArc
On Error Resume Next
Prompt1 = vbCrLf & "Insertion Point : "
InsertPoint = ThisDrawing.Utility.GetPoint(, Prompt1)
Prompt2 = vbCrLf & "Slot Length (Inches)<" & Format(SlotLengths, "0.0000") & ">: "
SlotLength = ThisDrawing.Utility.GetReal(Prompt2)
If SlotLength = 0 Then
SlotLength = SlotLengths
Else
SlotLengths = SlotLength
End If
Prompt3 = vbCrLf & "Slot Diameter (Inches)<" & Format(SlotDias, "0.0000") & ">: "
SlotDia = ThisDrawing.Utility.GetReal(Prompt3)
If SlotDia = 0 Then
SlotDia = SlotDias
Else
SlotDias = SlotDia
End If
pt1 = ThisDrawing.Utility. _
PolarPoint(InsertPoint, dtr(270#), SlotDia / 2)
pt2 = ThisDrawing.Utility. _
PolarPoint(pt1, dtr(180#), SlotLength / 2)
pt3 = ThisDrawing.Utility. _
PolarPoint(pt2, dtr(90#), SlotDia)
pt4 = ThisDrawing.Utility. _
PolarPoint(pt3, dtr(0#), SlotLength)
pt5 = ThisDrawing.Utility. _
PolarPoint(pt4, dtr(270#), SlotDia)
pt6 = ThisDrawing.Utility. _
PolarPoint(InsertPoint, dtr(180#), SlotLength / 2)
pt7 = ThisDrawing.Utility. _
PolarPoint(InsertPoint, dtr(0#), SlotLength / 2)
Set LineObj = ThisDrawing.ModelSpace. _
AddLine(pt5, pt2)
Set LineObj = ThisDrawing.ModelSpace. _
AddLine(pt3, pt4)
Set ArcObj = ThisDrawing.ModelSpace. _
AddArc(pt6, SlotDia / 2, dtr(90), dtr(270))
Set ArcObj = ThisDrawing.ModelSpace. _
AddArc(pt7, SlotDia / 2, dtr(270), dtr(90))
pt1 = ThisDrawing.Utility. _
PolarPoint(pt7, dtr(0#), SlotDia + 0.25)
pt2 = ThisDrawing.Utility. _
PolarPoint(pt6, dtr(180#), SlotDia + 0.25)
Set LineObj = ThisDrawing.ModelSpace. _
AddLine(pt1, pt2)
LineObj.Layer = "center"
pt1 = ThisDrawing.Utility. _
PolarPoint(InsertPoint, dtr(90#), SlotDia + 0.25)
pt2 = ThisDrawing.Utility. _
PolarPoint(InsertPoint, dtr(270#), SlotDia + 0.25)
Set LineObj = ThisDrawing.ModelSpace. _
AddLine(pt1, pt2)
LineObj.Layer = "center"
ActiveDocument.Regen acActiveViewport
Set LineObj = Nothing
Set ArcObj = Nothing
Err.Clear
On Error GoTo 0
End Sub
|