OK, since I already started this thread, I figure I can continue here. The above code is all fixed and working great. I have a new issue in that I am creating 3 3dsolids, separately, and would like to union them together.
Public Sub AddDeadEnd(PhSpace As Double, PoleSp As Double, PoleHt As Double, BmHt As Double)
Const VK_ESCAPE = &H1B
Const VK_LBUTTON = &H1
Const VK_SPACE = &H20
Const VK_RETURN = &HD
Const VK_LEFT = &H25
On Err GoTo err_control
Dim inspt As Variant, dblRotation As Double, dblTOC As Double, leftLeg As Variant, rightLeg As Variant
Dim oCurrLayeR As AcadLayer, intAutoSnap As Integer, intOSMode As Integer, PI As Double, LL2 As Variant
Dim oPline As AcadLWPolyline, oEntity(0) As AcadEntity, regent(0) As AcadEntity, obj3d As Acad3DSolid
Dim objRegion
Set oCurrLayeR = ThisDrawing.ActiveLayer
'IsSetup
dblTOC = CDbl(InputBox("What is T.O.C. elevation? ie 12 or 0 or -12"))
ThisDrawing.SetVariable "ORTHOMODE", 1
intAutoSnap = ThisDrawing.GetVariable("AUTOSNAP")
ThisDrawing.SetVariable "AUTOSNAP", 0
intOSMode = ThisDrawing.GetVariable("OSMODE")
ThisDrawing.SetVariable "OSMODE", 32
inspt = ThisDrawing.Utility.GetPoint(, "Select Deadend Insertion Point: ")
ThisDrawing.SetVariable "OSMODE", 512
dblRotation = ThisDrawing.Utility.GetAngle(inspt, "Pick Line Direction: ")
PI = Atn(1) * 4
ThisDrawing.SetVariable "OSMODE", 0
inspt(2) = inspt(2) + dblTOC
leftLeg = ThisDrawing.Utility.PolarPoint(inspt, dblRotation - ((PI * 90) / 180), PoleSp / 2)
rightLeg = ThisDrawing.Utility.PolarPoint(inspt, dblRotation + ((PI * 90) / 180), PoleSp / 2)
Call LayerSet("3D-STEL", 235)
DrawDeadendPole leftLeg, PoleHt
DrawDeadendPole rightLeg, PoleHt
leftLeg(2) = leftLeg(2) + BmHt
Set oPline = ThisDrawing.ModelSpace.AddLightWeightPolyline(PolygonVexs(leftLeg, 8, 5))
oPline.Closed = True
oPline.Elevation = BmHt
oPline.Update
Set regent(0) = oPline
objRegion = ThisDrawing.ModelSpace.AddRegion(regent)
Set obj3d = ThisDrawing.ModelSpace.AddExtrudedSolid(objRegion(0), PoleSp, 0)
regent(0).Delete
objRegion(0).Delete
LL2 = ThisDrawing.Utility.PolarPoint(leftLeg, dblRotation, 12)
obj3d.Rotate3D leftLeg, LL2, ((PI * -90) / 180)
Exit_Here:
ThisDrawing.ActiveLayer = oCurrLayeR
ThisDrawing.SetVariable "AUTOSNAP", intAutoSnap
ThisDrawing.SetVariable "OSMODE", intOSMode
ThisDrawing.SetVariable "INSUNITS", 1
Exit Sub
err_control:
Select Case Err.Number
Case -2147352567
'Debug.Print Err.Number, Err.Description
varcancel = ThisDrawing.GetVariable("LASTPROMPT")
If InStr(1, varcancel, "*Cancel*") <> 0 Then
If GetAsyncKeyState(VK_ESCAPE) And 8000 > 0 Then
Err.Clear
Resume Exit_Here
ElseIf GetAsyncKeyState(VK_LBUTTON) > 0 Then
Err.Clear
Resume
End If
Else
If GetAsyncKeyState(VK_SPACE) Then
Resume Exit_Here
End If
'Missed the pick, send them back!
Err.Clear
Resume
End If
Case Else
MsgBox Err.Description
Resume Exit_Here
End Select
End Sub
DrawDeadendPole leftLeg and Right leg are the first 2 3d objs, the 3rd you can see at the bottom of the code.
the code for that is Private Sub DrawDeadendPole(insptpole As Variant, PoleHt As Double)
Dim dblBase As Double, dblTop As Double, dblHeight As Double
Dim obj3d As Acad3DSolid, regent(0) As AcadEntity
Dim oPline As AcadLWPolyline
Dim cenPt As Variant, iNum As Integer, intAutoSnap As Integer
Dim dblAng As Double, dblRad As Double, dblAngle As Double
Dim objRegion
dblHeight = PoleHt
dblTop = 18 / 2
dblAngle = Atn((dblTop - dblBase) / dblHeight)
iNum = 12
cenPt = insptpole
dblRad = 29 / 2
Set oPline = ThisDrawing.ModelSpace.AddLightWeightPolyline(PolygonVexs(cenPt, iNum, dblRad))
oPline.ConstantWidth = 0
oPline.Layer = "0"
oPline.Closed = True
oPline.Update
Set regent(0) = oPline
objRegion = ThisDrawing.ModelSpace.AddRegion(regent)
Set obj3d = ThisDrawing.ModelSpace.AddExtrudedSolid(objRegion(0), dblHeight, dblAngle)
regent(0).Delete
objRegion(0).Delete
ThisDrawing.Regen acActiveViewport
End Sub
Function PolygonVexs(cenPt As Variant, iNum As Integer, _
dblRad As Double, Optional mode As Integer = 0) As Variant
Dim tmpPt As Variant
Dim iCnt As Integer
Dim vCnt As Integer
Dim vxCnt As Integer
Dim PI As Double
PI = Atn(1) * 4
Dim dltAng As Double
Dim dblAng As Double
Dim initAng As Double
dltAng = 2 * PI / iNum
initAng = dltAng / 2
vxCnt = 2 * iNum - 1
iCnt = 0
vCnt = 0
ReDim ptsarr(0 To vxCnt) As Double
If mode = 0 Then dblRad = dblRad / Cos(dltAng / 2)
While iCnt < iNum
dblAng = initAng + dltAng * iCnt
tmpPt = ThisDrawing.Utility.PolarPoint(cenPt, dblAng, dblRad)
iCnt = iCnt + 1
ptsarr(vCnt) = tmpPt(0): ptsarr(vCnt + 1) = tmpPt(1)
vCnt = vCnt + 2
Wend
PolygonVexs = ptsarr
End Function
Anyway, the question is how can I capture the 3d solids as they are created to use the Boolean union later