<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: VBA 2015 in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/vba-2015/m-p/5459152#M9985</link>
    <description>&lt;P&gt;You can use the VBAIDE command to open the IDE. There you can set a breakpoint in your function, switch to AutoCAD and execute it, then when the breakpoint is hit you can step through&amp;nbsp;the code&amp;nbsp;line by line to inspect variable values and watch for errors to see where it does something unexpected. It looks like the bolt head and nut are created near the end of the function.&lt;/P&gt;</description>
    <pubDate>Mon, 05 Jan 2015 19:04:10 GMT</pubDate>
    <dc:creator>owenwengerd</dc:creator>
    <dc:date>2015-01-05T19:04:10Z</dc:date>
    <item>
      <title>VBA 2015</title>
      <link>https://forums.autodesk.com/t5/vba-forum/vba-2015/m-p/5458214#M9982</link>
      <description>&lt;P&gt;Why won't this work in 2015 compared to 2014?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Option Explicit&lt;BR /&gt;Dim DblDiameter As Double&lt;BR /&gt;Dim varPnt1 As Variant&lt;BR /&gt;Dim varPnt2 As Variant&lt;BR /&gt;Dim dblHeight As Double&lt;BR /&gt;Dim varPnt1UCS As Variant&lt;/P&gt;&lt;P&gt;Public Sub Bolts()&lt;/P&gt;&lt;P&gt;DblDiameter = ThisDrawing.Utility.GetInteger("Input bolt diameter: ")&lt;BR /&gt;varPnt1 = ThisDrawing.Utility.GetPoint(, "Pick bolt head side")&lt;BR /&gt;varPnt1UCS = ThisDrawing.Utility.TranslateCoordinates(varPnt1, acWorld, acUCS, False)&lt;BR /&gt;varPnt2 = ThisDrawing.Utility.GetPoint(varPnt1UCS, "Pick nut side")&lt;/P&gt;&lt;P&gt;dblHeight = Distance(varPnt1, varPnt2)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;SolidBolt&lt;BR /&gt;SolidNut&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;Function Add_UCS_improved(origin() As Double, xAxisPnt() _&lt;BR /&gt;As Double, yAxisPnt() As Double, ucsName As String) As AcadUCS&lt;BR /&gt;' origin, xAxisPnt, and yAxisPnt must all be dimmed (0 to 2)&lt;/P&gt;&lt;P&gt;Dim ucsObj As AcadUCS&lt;BR /&gt;Dim xAxisVec(0 To 2) As Double&lt;BR /&gt;Dim yAxisVec(0 To 2) As Double&lt;BR /&gt;Dim perpYaxisPnt(0 To 2) As Double&lt;BR /&gt;Dim xCy As Variant, perpYaxisVec As Variant&lt;/P&gt;&lt;P&gt;Debug.Print "xAxisPnt: " &amp;amp; xAxisPnt(0) &amp;amp; ", " &amp;amp; xAxisPnt(1) &amp;amp; ", " &amp;amp; xAxisPnt(2)&lt;BR /&gt;Debug.Print "yAxisPnt: " &amp;amp; yAxisPnt(0) &amp;amp; ", " &amp;amp; yAxisPnt(1) &amp;amp; ", " &amp;amp; yAxisPnt(2)&lt;BR /&gt;Debug.Print "origin: " &amp;amp; origin(0) &amp;amp; ", " &amp;amp; origin(1) &amp;amp; ", " &amp;amp; origin(2)&lt;/P&gt;&lt;P&gt;xAxisVec(0) = xAxisPnt(0) - origin(0)&lt;BR /&gt;xAxisVec(1) = xAxisPnt(1) - origin(1)&lt;BR /&gt;xAxisVec(2) = xAxisPnt(2) - origin(2)&lt;BR /&gt;yAxisVec(0) = yAxisPnt(0) - origin(0)&lt;BR /&gt;yAxisVec(1) = yAxisPnt(1) - origin(1)&lt;BR /&gt;yAxisVec(2) = yAxisPnt(2) - origin(2)&lt;/P&gt;&lt;P&gt;Debug.Print "xAxis: " &amp;amp; xAxisVec(0) &amp;amp; ", " &amp;amp; xAxisVec(1) &amp;amp; ", " &amp;amp; xAxisVec(2)&lt;BR /&gt;Debug.Print "yAxis: " &amp;amp; yAxisVec(0) &amp;amp; ", " &amp;amp; yAxisVec(1) &amp;amp; ", " &amp;amp; yAxisVec(2)&lt;/P&gt;&lt;P&gt;xCy = Cross3D(xAxisVec, yAxisVec)&lt;/P&gt;&lt;P&gt;Debug.Print "xCy: " &amp;amp; xCy(0) &amp;amp; ", " &amp;amp; xCy(1) &amp;amp; ", " &amp;amp; xCy(2)&lt;/P&gt;&lt;P&gt;perpYaxisVec = Cross3D(xCy, xAxisVec)&lt;/P&gt;&lt;P&gt;Debug.Print "perpYaxisVec: " &amp;amp; perpYaxisVec(0) &amp;amp; ", " &amp;amp; perpYaxisVec(1) &amp;amp; ", " &amp;amp; perpYaxisVec(2)&lt;/P&gt;&lt;P&gt;perpYaxisPnt(0) = perpYaxisVec(0) + origin(0)&lt;BR /&gt;perpYaxisPnt(1) = perpYaxisVec(1) + origin(1)&lt;BR /&gt;perpYaxisPnt(2) = perpYaxisVec(2) + origin(2)&lt;/P&gt;&lt;P&gt;Debug.Print "perpYaxisPnt: " &amp;amp; perpYaxisPnt(0) &amp;amp; ", " &amp;amp; perpYaxisPnt(1) &amp;amp; ", " &amp;amp; perpYaxisPnt(2)&lt;/P&gt;&lt;P&gt;Set ucsObj = ThisDrawing.UserCoordinateSystems.Add(origin, xAxisPnt, perpYaxisPnt, ucsName)&lt;BR /&gt;Set Add_UCS_improved = ucsObj&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;&lt;P&gt;Function Cross3D(A As Variant, B As Variant) As Variant&lt;BR /&gt;' A and B must be dimensioned Double(0 to 2)&lt;BR /&gt;Dim C(0 To 2) As Double&lt;BR /&gt;C(0) = A(1) * B(2) - A(2) * B(1)&lt;BR /&gt;C(1) = -(A(0) * B(2) - A(2) * B(0))&lt;BR /&gt;C(2) = A(0) * B(1) - A(1) * B(0)&lt;BR /&gt;Cross3D = C&lt;BR /&gt;End Function&lt;/P&gt;&lt;P&gt;Function Distance(p1, p2) As Variant&lt;/P&gt;&lt;P&gt;Dim xDist As Variant&lt;BR /&gt;Dim yDist As Variant&lt;BR /&gt;Dim zDist As Variant&lt;/P&gt;&lt;P&gt;xDist = p1(0) - p2(0)&lt;BR /&gt;yDist = p1(1) - p2(1)&lt;BR /&gt;zDist = p1(2) - p2(2)&lt;/P&gt;&lt;P&gt;Distance = Sqr(xDist ^ 2 + yDist ^ 2 + zDist ^ 2)&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;&lt;P&gt;Public Function RoundToValue(ByVal nValue, _&lt;BR /&gt;nCeiling As Double, Optional RoundUp As Boolean = True) _&lt;BR /&gt;As Double&lt;BR /&gt;&lt;BR /&gt;Dim tmp As Integer&lt;BR /&gt;Dim tmpVal&lt;BR /&gt;If Not IsNumeric(nValue) Then Exit Function&lt;BR /&gt;nValue = CDbl(nValue)&lt;BR /&gt;&lt;BR /&gt;'Round up to a whole integer -&lt;BR /&gt;'Any decimal value will force a round to the next integer.&lt;BR /&gt;'i.e. 0.01 = 1 or 0.8 = 1&lt;/P&gt;&lt;P&gt;tmpVal = ((nValue / nCeiling) + (-0.5 + (RoundUp And 1)))&lt;BR /&gt;tmp = Fix(tmpVal)&lt;BR /&gt;tmpVal = CInt((tmpVal - tmp) * 10 ^ 0)&lt;BR /&gt;nValue = tmp + tmpVal / 10 ^ 0&lt;/P&gt;&lt;P&gt;'Multiply by ceiling value to set RoundtoValue&lt;BR /&gt;RoundToValue = nValue * nCeiling&lt;BR /&gt;&lt;BR /&gt;End Function&lt;/P&gt;&lt;P&gt;Function SolCylinder(diameter As Double, Height As Double)&lt;/P&gt;&lt;P&gt;'This function creates a 3D cylinder based on supplied data. Centre is the point at the start&lt;BR /&gt;'of the cylinder. Diameter is self explanatory. Height is the length of the cylinder&lt;BR /&gt;'A negative value acts the same as the extrude command.&lt;/P&gt;&lt;P&gt;Dim dblRadius As Double&lt;BR /&gt;Dim dblCenter(2) As Double&lt;/P&gt;&lt;P&gt;dblRadius = diameter / 2&lt;/P&gt;&lt;P&gt;'' calculate center point from input&lt;BR /&gt;dblCenter(0) = 0&lt;BR /&gt;dblCenter(1) = 0&lt;BR /&gt;dblCenter(2) = (Height / 2)&lt;/P&gt;&lt;P&gt;If Height &amp;lt; 0 Then&lt;BR /&gt;Height = -Height&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;Set SolCylinder = ThisDrawing.ModelSpace.AddCylinder(dblCenter, dblRadius, Height)&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Function RotateAngle(Point1 As Variant, Point2 As Variant)&lt;/P&gt;&lt;P&gt;Dim yAxisPnt(2) As Double&lt;BR /&gt;Dim xAxisPnt(2) As Double&lt;BR /&gt;Dim origin(2) As Double&lt;BR /&gt;Dim testUCS As AcadUCS&lt;BR /&gt;Dim dblAngle As Double&lt;BR /&gt;Dim dbla As Double&lt;BR /&gt;Dim dblb As Double&lt;BR /&gt;Dim dblc As Double&lt;/P&gt;&lt;P&gt;yAxisPnt(0) = Point1(0)&lt;BR /&gt;yAxisPnt(1) = Point1(1)&lt;BR /&gt;yAxisPnt(2) = Point1(2) + Distance(Point1, Point2)&lt;/P&gt;&lt;P&gt;origin(0) = Point1(0)&lt;BR /&gt;origin(1) = Point1(1)&lt;BR /&gt;origin(2) = Point1(2)&lt;/P&gt;&lt;P&gt;xAxisPnt(0) = Point2(0)&lt;BR /&gt;xAxisPnt(1) = Point2(1)&lt;BR /&gt;xAxisPnt(2) = Point2(2)&lt;/P&gt;&lt;P&gt;If Point1(0) = Point2(0) And Point1(1) = Point2(1) Then&lt;BR /&gt;RotateAngle = 0&lt;BR /&gt;Else&lt;/P&gt;&lt;P&gt;Set testUCS = Add_UCS_improved(origin, xAxisPnt, yAxisPnt, "test")&lt;/P&gt;&lt;P&gt;ThisDrawing.ActiveUCS = testUCS&lt;/P&gt;&lt;P&gt;dbla = Distance(origin, xAxisPnt)&lt;BR /&gt;dblb = dbla&lt;BR /&gt;dblc = Distance(yAxisPnt, xAxisPnt)&lt;/P&gt;&lt;P&gt;dblAngle = ((dbla ^ 2 + dblb ^ 2 - dblc ^ 2) / (2 * dbla * dblb))&lt;BR /&gt;dblAngle = Atn(-dblAngle / Sqr(-dblAngle * dblAngle + 1)) + 2 * Atn(1)&lt;/P&gt;&lt;P&gt;RotateAngle = -dblAngle&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Private Sub SolidBolt()&lt;/P&gt;&lt;P&gt;' Define the UCS pointsCyl&lt;BR /&gt;Dim xAxisPnt(0 To 2) As Double&lt;BR /&gt;xAxisPnt(0) = 1: xAxisPnt(1) = 0: xAxisPnt(2) = 0&lt;BR /&gt;&lt;BR /&gt;Dim yAxisPnt(0 To 2) As Double&lt;BR /&gt;yAxisPnt(0) = 0: yAxisPnt(1) = 1: yAxisPnt(2) = 0&lt;BR /&gt;&lt;BR /&gt;Dim zAxisPnt(0 To 2) As Double&lt;BR /&gt;zAxisPnt(0) = 0: zAxisPnt(1) = 0: zAxisPnt(2) = 1&lt;/P&gt;&lt;P&gt;Dim origin(2) As Double&lt;BR /&gt;origin(0) = 0#: origin(1) = 0#: origin(2) = 0#&lt;BR /&gt;&lt;BR /&gt;' Add the UCS to the&lt;BR /&gt;' UserCoordinatesSystems collection&lt;BR /&gt;Dim ucsObj As AcadUCS&lt;BR /&gt;Set ucsObj = ThisDrawing.UserCoordinateSystems.Add(origin, xAxisPnt, zAxisPnt, "New_UCS")&lt;/P&gt;&lt;P&gt;' Make the new UCS the active UCS&lt;BR /&gt;ThisDrawing.ActiveUCS = ucsObj&lt;/P&gt;&lt;P&gt;Dim pointsCyl(0 To 9) As Double&lt;BR /&gt;Dim diameter As Double&lt;BR /&gt;Dim pi&lt;BR /&gt;&lt;BR /&gt;pi = 4 * Atn(1)&lt;BR /&gt;diameter = DblDiameter&lt;BR /&gt;&lt;BR /&gt;' Define the 2D polyline pointsCyl&lt;BR /&gt;pointsCyl(0) = 0: pointsCyl(1) = 0&lt;BR /&gt;pointsCyl(2) = ((0.8 * diameter) / Cos(30 * (pi / 180))): pointsCyl(3) = 0&lt;BR /&gt;pointsCyl(4) = ((0.8 * diameter) / Cos(30 * (pi / 180))): pointsCyl(5) = -((0.7 * diameter) - ((diameter / Cos(30 * (pi / 180))) - diameter))&lt;BR /&gt;pointsCyl(6) = 0.8 * diameter: pointsCyl(7) = -(0.7 * diameter)&lt;BR /&gt;pointsCyl(8) = 0: pointsCyl(9) = -(0.7 * diameter)&lt;/P&gt;&lt;P&gt;With ThisDrawing.ModelSpace&lt;BR /&gt;&lt;BR /&gt;Dim PlineCyl As AcadLWPolyline&lt;BR /&gt;' Create a lightweight Polyline object in model space&lt;BR /&gt;Set PlineCyl = .AddLightWeightPolyline(pointsCyl)&lt;BR /&gt;PlineCyl.Closed = True&lt;BR /&gt;&lt;BR /&gt;Dim RegionCyl(0) As Object&lt;BR /&gt;Set RegionCyl(0) = PlineCyl&lt;BR /&gt;&lt;BR /&gt;Dim RegionC As Variant&lt;BR /&gt;RegionC = .AddRegion(RegionCyl)&lt;BR /&gt;&lt;BR /&gt;Dim Axis(2) As Double&lt;BR /&gt;Axis(0) = 0#: Axis(1) = 0#: Axis(2) = 1#&lt;BR /&gt;&lt;BR /&gt;Dim SolidCyl As Acad3DSolid&lt;BR /&gt;Set SolidCyl = .AddRevolvedSolid(RegionC(0), origin, Axis, 360)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;End With&lt;BR /&gt;&lt;BR /&gt;PlineCyl.Delete&lt;BR /&gt;RegionC(0).Delete&lt;BR /&gt;&lt;BR /&gt;Dim dblLength As Double&lt;BR /&gt;dblLength = Distance(varPnt1, varPnt2)&lt;BR /&gt;dblLength = RoundToValue((dblLength + (0.2 * DblDiameter) + DblDiameter + 5), 5, True)&lt;BR /&gt;&lt;BR /&gt;Dim pointsCha(0 To 5) As Double&lt;BR /&gt;pointsCha(0) = ((diameter / 2) - (0.075 * diameter)): pointsCha(1) = dblLength&lt;BR /&gt;pointsCha(2) = (diameter / 2): pointsCha(3) = dblLength&lt;BR /&gt;pointsCha(4) = (diameter / 2): pointsCha(5) = (dblLength - (0.075 * diameter))&lt;BR /&gt;&lt;BR /&gt;With ThisDrawing.ModelSpace&lt;BR /&gt;&lt;BR /&gt;Dim PlineCha As AcadLWPolyline&lt;BR /&gt;' Create a lightweight Polyline object in model space&lt;BR /&gt;Set PlineCha = .AddLightWeightPolyline(pointsCha)&lt;BR /&gt;PlineCha.Closed = True&lt;BR /&gt;&lt;BR /&gt;Dim RegionCha(0) As Object&lt;BR /&gt;Set RegionCha(0) = PlineCha&lt;BR /&gt;&lt;BR /&gt;Dim RegionCh As Variant&lt;BR /&gt;RegionCh = .AddRegion(RegionCha)&lt;BR /&gt;&lt;BR /&gt;Dim SolidCha As Acad3DSolid&lt;BR /&gt;Set SolidCha = .AddRevolvedSolid(RegionCh(0), origin, Axis, 360)&lt;BR /&gt;&lt;BR /&gt;End With&lt;BR /&gt;&lt;BR /&gt;PlineCha.Delete&lt;BR /&gt;RegionCh(0).Delete&lt;BR /&gt;&lt;BR /&gt;Set ucsObj = ThisDrawing.UserCoordinateSystems.Add(origin, xAxisPnt, yAxisPnt, "New_UCS")&lt;/P&gt;&lt;P&gt;' Make the new UCS the active UCS&lt;BR /&gt;ThisDrawing.ActiveUCS = ucsObj&lt;BR /&gt;&lt;BR /&gt;Dim pointsHex(0 To 11) As Double&lt;BR /&gt;pointsHex(0) = ((0.8 * diameter) / Cos(30 * (pi / 180))): pointsHex(1) = 0&lt;BR /&gt;pointsHex(2) = ((0.8 * diameter) * Tan(30 * (pi / 180))): pointsHex(3) = (0.8 * diameter)&lt;BR /&gt;pointsHex(4) = -((0.8 * diameter) * Tan(30 * (pi / 180))): pointsHex(5) = (0.8 * diameter)&lt;BR /&gt;pointsHex(6) = -((0.8 * diameter) / Cos(30 * (pi / 180))): pointsHex(7) = 0&lt;BR /&gt;pointsHex(8) = -((0.8 * diameter) * Tan(30 * (pi / 180))): pointsHex(9) = -(0.8 * diameter)&lt;BR /&gt;pointsHex(10) = ((0.8 * diameter) * Tan(30 * (pi / 180))): pointsHex(11) = -(0.8 * diameter)&lt;BR /&gt;&lt;BR /&gt;With ThisDrawing.ModelSpace&lt;BR /&gt;&lt;BR /&gt;Dim PlineHex As AcadLWPolyline&lt;BR /&gt;' Create a lightweight Polyline object in model space&lt;BR /&gt;Set PlineHex = .AddLightWeightPolyline(pointsHex)&lt;BR /&gt;PlineHex.Closed = True&lt;/P&gt;&lt;P&gt;Dim RegionHex(0) As Object&lt;BR /&gt;Set RegionHex(0) = PlineHex&lt;BR /&gt;&lt;BR /&gt;Dim RegionH As Variant&lt;BR /&gt;RegionH = .AddRegion(RegionHex)&lt;BR /&gt;&lt;BR /&gt;Dim SolidHex As Acad3DSolid&lt;BR /&gt;Set SolidHex = .AddExtrudedSolid(RegionH(0), -(0.7 * diameter), 0)&lt;BR /&gt;&lt;BR /&gt;SolidCyl.Boolean acIntersection, SolidHex&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim SolidShaft As Acad3DSolid&lt;BR /&gt;Set SolidShaft = SolCylinder(DblDiameter, dblLength)&lt;/P&gt;&lt;P&gt;SolidCyl.Boolean acUnion, SolidShaft&lt;BR /&gt;SolidCyl.Boolean acSubtraction, SolidCha&lt;BR /&gt;SolidCyl.Move origin, varPnt1&lt;BR /&gt;SolidCyl.Rotate varPnt1, RotateAngle(varPnt1, varPnt2)&lt;BR /&gt;SolidCyl.Update&lt;BR /&gt;&lt;BR /&gt;Dim SolidWash1 As Acad3DSolid&lt;BR /&gt;Dim SolidWash2 As Acad3DSolid&lt;BR /&gt;Set SolidWash1 = SolCylinder((2 * DblDiameter), (0.2 * DblDiameter))&lt;BR /&gt;Set SolidWash2 = SolCylinder(DblDiameter, (0.2 * DblDiameter))&lt;BR /&gt;SolidWash1.Boolean acSubtraction, SolidWash2&lt;BR /&gt;SolidWash1.Move origin, varPnt1&lt;BR /&gt;SolidWash1.Rotate varPnt1, RotateAngle(varPnt1, varPnt2)&lt;BR /&gt;SolidWash1.Move varPnt1, varPnt2&lt;BR /&gt;&lt;BR /&gt;SolidWash1.Update&lt;BR /&gt;&lt;BR /&gt;PlineHex.Delete&lt;BR /&gt;RegionH(0).Delete&lt;/P&gt;&lt;P&gt;End With&lt;BR /&gt;&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Private Sub SolidNut()&lt;/P&gt;&lt;P&gt;' Define the UCS pointsCyl&lt;BR /&gt;Dim xAxisPnt(0 To 2) As Double&lt;BR /&gt;xAxisPnt(0) = 1: xAxisPnt(1) = 0: xAxisPnt(2) = 0&lt;BR /&gt;&lt;BR /&gt;Dim yAxisPnt(0 To 2) As Double&lt;BR /&gt;yAxisPnt(0) = 0: yAxisPnt(1) = 1: yAxisPnt(2) = 0&lt;BR /&gt;&lt;BR /&gt;Dim zAxisPnt(0 To 2) As Double&lt;BR /&gt;zAxisPnt(0) = 0: zAxisPnt(1) = 0: zAxisPnt(2) = 1&lt;/P&gt;&lt;P&gt;Dim origin(2) As Double&lt;BR /&gt;origin(0) = 0#: origin(1) = 0#: origin(2) = 0#&lt;BR /&gt;&lt;BR /&gt;' Add the UCS to the&lt;BR /&gt;' UserCoordinatesSystems collection&lt;BR /&gt;Dim ucsObj As AcadUCS&lt;BR /&gt;Set ucsObj = ThisDrawing.UserCoordinateSystems.Add(origin, xAxisPnt, zAxisPnt, "New_UCS")&lt;/P&gt;&lt;P&gt;' Make the new UCS the active UCS&lt;BR /&gt;ThisDrawing.ActiveUCS = ucsObj&lt;/P&gt;&lt;P&gt;Dim pointsCyl(0 To 11) As Double&lt;BR /&gt;Dim diameter As Double&lt;BR /&gt;Dim pi&lt;BR /&gt;&lt;BR /&gt;pi = 4 * Atn(1)&lt;BR /&gt;diameter = DblDiameter&lt;BR /&gt;&lt;BR /&gt;' Define the 2D polyline pointsCyl&lt;BR /&gt;pointsCyl(0) = diameter / 2: pointsCyl(1) = 0&lt;BR /&gt;pointsCyl(2) = 0.8 * diameter: pointsCyl(3) = 0&lt;BR /&gt;pointsCyl(4) = ((0.8 * diameter) / Cos(30 * (pi / 180))): pointsCyl(5) = -((diameter / Cos(30 * (pi / 180))) - diameter)&lt;BR /&gt;pointsCyl(6) = ((0.8 * diameter) / Cos(30 * (pi / 180))): pointsCyl(7) = -((0.8 * diameter) - ((diameter / Cos(30 * (pi / 180))) - diameter))&lt;BR /&gt;pointsCyl(8) = 0.8 * diameter: pointsCyl(9) = -(0.8 * diameter)&lt;BR /&gt;pointsCyl(10) = diameter / 2: pointsCyl(11) = -(0.8 * diameter)&lt;/P&gt;&lt;P&gt;With ThisDrawing.ModelSpace&lt;BR /&gt;&lt;BR /&gt;Dim PlineCyl As AcadLWPolyline&lt;BR /&gt;' Create a lightweight Polyline object in model space&lt;BR /&gt;Set PlineCyl = .AddLightWeightPolyline(pointsCyl)&lt;BR /&gt;PlineCyl.Closed = True&lt;BR /&gt;&lt;BR /&gt;Dim RegionCyl(0) As Object&lt;BR /&gt;Set RegionCyl(0) = PlineCyl&lt;BR /&gt;&lt;BR /&gt;Dim RegionC As Variant&lt;BR /&gt;RegionC = .AddRegion(RegionCyl)&lt;BR /&gt;&lt;BR /&gt;Dim Axis(2) As Double&lt;BR /&gt;Axis(0) = 0#: Axis(1) = 0#: Axis(2) = 1#&lt;BR /&gt;&lt;BR /&gt;Dim SolidCyl As Acad3DSolid&lt;BR /&gt;Set SolidCyl = .AddRevolvedSolid(RegionC(0), origin, Axis, 360)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;End With&lt;BR /&gt;&lt;BR /&gt;PlineCyl.Delete&lt;BR /&gt;RegionC(0).Delete&lt;BR /&gt;&lt;BR /&gt;Dim dblLength As Double&lt;BR /&gt;dblLength = Distance(varPnt1, varPnt2)&lt;BR /&gt;dblLength = RoundToValue((dblLength + DblDiameter), 5, True)&lt;BR /&gt;&lt;BR /&gt;Set ucsObj = ThisDrawing.UserCoordinateSystems.Add(origin, xAxisPnt, yAxisPnt, "New_UCS")&lt;/P&gt;&lt;P&gt;' Make the new UCS the active UCS&lt;BR /&gt;ThisDrawing.ActiveUCS = ucsObj&lt;BR /&gt;&lt;BR /&gt;Dim pointsHex(0 To 11) As Double&lt;BR /&gt;pointsHex(0) = ((0.8 * diameter) / Cos(30 * (pi / 180))): pointsHex(1) = 0&lt;BR /&gt;pointsHex(2) = ((0.8 * diameter) * Tan(30 * (pi / 180))): pointsHex(3) = (0.8 * diameter)&lt;BR /&gt;pointsHex(4) = -((0.8 * diameter) * Tan(30 * (pi / 180))): pointsHex(5) = (0.8 * diameter)&lt;BR /&gt;pointsHex(6) = -((0.8 * diameter) / Cos(30 * (pi / 180))): pointsHex(7) = 0&lt;BR /&gt;pointsHex(8) = -((0.8 * diameter) * Tan(30 * (pi / 180))): pointsHex(9) = -(0.8 * diameter)&lt;BR /&gt;pointsHex(10) = ((0.8 * diameter) * Tan(30 * (pi / 180))): pointsHex(11) = -(0.8 * diameter)&lt;BR /&gt;&lt;BR /&gt;With ThisDrawing.ModelSpace&lt;BR /&gt;&lt;BR /&gt;Dim PlineHex As AcadLWPolyline&lt;BR /&gt;' Create a lightweight Polyline object in model space&lt;BR /&gt;Set PlineHex = .AddLightWeightPolyline(pointsHex)&lt;BR /&gt;PlineHex.Closed = True&lt;/P&gt;&lt;P&gt;Dim RegionHex(0) As Object&lt;BR /&gt;Set RegionHex(0) = PlineHex&lt;BR /&gt;&lt;BR /&gt;Dim RegionH As Variant&lt;BR /&gt;RegionH = .AddRegion(RegionHex)&lt;BR /&gt;&lt;BR /&gt;Dim SolidHex As Acad3DSolid&lt;BR /&gt;Set SolidHex = .AddExtrudedSolid(RegionH(0), -(0.8 * diameter), 0)&lt;BR /&gt;&lt;BR /&gt;SolidCyl.Boolean acIntersection, SolidHex&lt;/P&gt;&lt;P&gt;Dim nutLen(0 To 2) As Double&lt;BR /&gt;nutLen(0) = 0: nutLen(1) = 0: nutLen(2) = (Distance(varPnt1, varPnt2) + diameter)&lt;BR /&gt;&lt;BR /&gt;SolidCyl.Move origin, nutLen&lt;BR /&gt;SolidCyl.Move origin, varPnt1&lt;BR /&gt;SolidCyl.Rotate varPnt1, RotateAngle(varPnt1, varPnt2)&lt;BR /&gt;SolidCyl.Update&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;PlineHex.Delete&lt;BR /&gt;RegionH(0).Delete&lt;/P&gt;&lt;P&gt;End With&lt;BR /&gt;&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jan 2015 00:45:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/vba-2015/m-p/5458214#M9982</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-01-05T00:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: VBA 2015</title>
      <link>https://forums.autodesk.com/t5/vba-forum/vba-2015/m-p/5458254#M9983</link>
      <description>&lt;P&gt;This is a technical forum, so you're much more likely to get help if you use precise terminology. Phrases like "won't work"&amp;nbsp;are not helpful in diagnosing the problem. It would also be helpful if you trace the problem to a specific line of code. Ideally you should describe what steps you take, what you expect to happen, and what actually happens.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jan 2015 02:22:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/vba-2015/m-p/5458254#M9983</guid>
      <dc:creator>owenwengerd</dc:creator>
      <dc:date>2015-01-05T02:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: VBA 2015</title>
      <link>https://forums.autodesk.com/t5/vba-forum/vba-2015/m-p/5458260#M9984</link>
      <description>&lt;P&gt;Thanks for the tip &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It&amp;nbsp;is suppose to draw a 3d model of a bolt with nut and washer (metric) after inputing diameter and picking 2 points.&lt;/P&gt;&lt;P&gt;Now all it draws is a cylinder for the bolt and a washer (refer to attached images)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG border="0" src="https://forums.autodesk.com/t5/image/serverpage/image-id/147628i918A60DF9A830324/image-size/original?v=mpbl-1&amp;amp;px=-1" title="5-01-2015 1-29-53 PM.png" alt="5-01-2015 1-29-53 PM.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG border="0" src="https://forums.autodesk.com/t5/image/serverpage/image-id/147629iF6F32DB46E3BB901/image-size/original?v=mpbl-1&amp;amp;px=-1" title="5-01-2015 1-31-41 PM.png" alt="5-01-2015 1-31-41 PM.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I isolate a line of code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Simon&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jan 2015 02:34:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/vba-2015/m-p/5458260#M9984</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-01-05T02:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: VBA 2015</title>
      <link>https://forums.autodesk.com/t5/vba-forum/vba-2015/m-p/5459152#M9985</link>
      <description>&lt;P&gt;You can use the VBAIDE command to open the IDE. There you can set a breakpoint in your function, switch to AutoCAD and execute it, then when the breakpoint is hit you can step through&amp;nbsp;the code&amp;nbsp;line by line to inspect variable values and watch for errors to see where it does something unexpected. It looks like the bolt head and nut are created near the end of the function.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jan 2015 19:04:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/vba-2015/m-p/5459152#M9985</guid>
      <dc:creator>owenwengerd</dc:creator>
      <dc:date>2015-01-05T19:04:10Z</dc:date>
    </item>
  </channel>
</rss>

