Message 1 of 13
VBA revolve problem, help...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I have one problem, with this code below, there is no way to revolve polyline around red centerline if polyline is set at specific angle. Example (Drawing1test.dwg):
Error: "General modeling failure"
Public Sub TestAddRevolvedSolid()
Dim objShape As AcadLWPolyline
Dim varPick As Variant
Dim objEnt As AcadEntity
Dim varPnt1 As Variant
Dim dblOrigin(2) As Double
Dim varVec As Variant
Dim dblAngle As Double
Dim objEnts() As AcadEntity
Dim varRegions As Variant
Dim varItem As Variant
'' draw the shape and get rotation from user
With ThisDrawing.Utility
'' pick a shape
On Error Resume Next
.GetEntity objShape, varPick, "pick a polyline shape"
If Err Then
MsgBox "You did not pick the correct type of shape"
Exit Sub
End If
On Error GoTo Done
objShape.Closed = True
'' add pline to region input array
ReDim objEnts(0)
Set objEnts(0) = objShape
'' get the axis points
.InitializeUserInput 1
varPnt1 = .GetPoint(, vbLf & "Pick an origin of revolution: ")
.InitializeUserInput 1
varVec = .GetPoint(dblOrigin, vbLf & _
"Indicate the axis of revolution: ")
'' get the angle to revolve
.InitializeUserInput 1
dblAngle = .GetAngle(, vbLf & "Angle to revolve: ")
End With
'' make the region, then revolve it into a solid
With ThisDrawing.ModelSpace
'' make region from closed pline
varRegions = .AddRegion(objEnts)
'' revolve solid about axis
Set objEnt = .AddRevolvedSolid(varRegions(0), varPnt1, varVec, _
dblAngle)
objEnt.color = acRed
End With
Done:
If Err Then MsgBox Err.Description
'' delete the temporary geometry
For Each varItem In objEnts: varItem.Delete: Next
If Not IsEmpty(varRegions) Then
For Each varItem In varRegions: varItem.Delete: Next
End If
ThisDrawing.SendCommand "_shade" & vbCr
End Sub
any Help? Thank you
Moderator edit: put code into code window using </> button.