Message 1 of 3
Vba Pline... Better Way?

Not applicable
06-09-2003
10:12 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have manage to create a pline on demand with my vba program written like this :
(but I find it preatty "beginner"...)
There must be a better way???
Public Sub GoforTheLine()
InsBlock.Hide
Dim plineObj As AcadPolyline
Dim returnPnt As Variant
' This example returns a point entered by the user.
Dim newVertex(0 To 2) As Double
Dim basePnt(0 To 2) As Double
Dim endPnt(0 To 2) As Double
Dim returnPntList(0 To 5) As Double
basePnt(0) = MainGlobal.insertionPnt(0): basePnt(1) = MainGlobal.insertionPnt(1): basePnt(2) = MainGlobal.insertionPnt(2)
' Return a point using a prompt
On Error Resume Next
I = 0
While IsNull(returnPnt) = False
returnPnt = ThisDrawing.Utility.GetPoint(basePnt, "Pick the next point: ")
If Err Then GoTo FINEND
If (I > 0) Then
newVertex(0) = returnPnt(0): newVertex(1) = returnPnt(1): newVertex(2) = returnPnt(2)
plineObj.AppendVertex newVertex
Else
returnPntList(0) = basePnt(0)
returnPntList(1) = basePnt(1)
returnPntList(2) = basePnt(2)
returnPntList(3) = returnPnt(0)
returnPntList(4) = returnPnt(1)
returnPntList(5) = returnPnt(2)
Set plineObj = ThisDrawing.ModelSpace.AddPolyline(returnPntList)
If MainGlobal.ajretG = True Then
Call Group.AjoutRetrait 'Ajouter au groupe l'objet précédent
End If
End If
basePnt(0) = returnPnt(0)
basePnt(1) = returnPnt(1)
basePnt(2) = returnPnt(2)
I = I + 1
ThisDrawing.Regen (acActiveViewport)
Wend
FINEND:
'plineObj.SetWidth 0, 1, 1 ''' actually this is not working
End Sub
The goal of the program is to create a ballon type... You know... A circle with attributes with a "pline2 starting from the "insertion" [insertionPnt] point to the pointed object...
(but I find it preatty "beginner"...)
There must be a better way???
Public Sub GoforTheLine()
InsBlock.Hide
Dim plineObj As AcadPolyline
Dim returnPnt As Variant
' This example returns a point entered by the user.
Dim newVertex(0 To 2) As Double
Dim basePnt(0 To 2) As Double
Dim endPnt(0 To 2) As Double
Dim returnPntList(0 To 5) As Double
basePnt(0) = MainGlobal.insertionPnt(0): basePnt(1) = MainGlobal.insertionPnt(1): basePnt(2) = MainGlobal.insertionPnt(2)
' Return a point using a prompt
On Error Resume Next
I = 0
While IsNull(returnPnt) = False
returnPnt = ThisDrawing.Utility.GetPoint(basePnt, "Pick the next point: ")
If Err Then GoTo FINEND
If (I > 0) Then
newVertex(0) = returnPnt(0): newVertex(1) = returnPnt(1): newVertex(2) = returnPnt(2)
plineObj.AppendVertex newVertex
Else
returnPntList(0) = basePnt(0)
returnPntList(1) = basePnt(1)
returnPntList(2) = basePnt(2)
returnPntList(3) = returnPnt(0)
returnPntList(4) = returnPnt(1)
returnPntList(5) = returnPnt(2)
Set plineObj = ThisDrawing.ModelSpace.AddPolyline(returnPntList)
If MainGlobal.ajretG = True Then
Call Group.AjoutRetrait 'Ajouter au groupe l'objet précédent
End If
End If
basePnt(0) = returnPnt(0)
basePnt(1) = returnPnt(1)
basePnt(2) = returnPnt(2)
I = I + 1
ThisDrawing.Regen (acActiveViewport)
Wend
FINEND:
'plineObj.SetWidth 0, 1, 1 ''' actually this is not working
End Sub
The goal of the program is to create a ballon type... You know... A circle with attributes with a "pline2 starting from the "insertion" [insertionPnt] point to the pointed object...