Message 1 of 10
Error type missmatch

Not applicable
06-17-2009
03:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I took a code right from a book for programming AutoCAD via vba, an error is given as a type missmatch in the line highlighted , any ideas ??
dim nbp as integer
For nbp = 0 To Val(Type_rad_form.TextBox1.Text) Step nbp + 1
MsgBox "SVP, choisir le chemin correspondant pour la tuyauterie du radiateur, " & nbp + 1 & vbNewLine & "(Uilisez un polyline)"
Dim objent As AcadLWPolyline
Dim dblnew() As Double
Dim lnglastvertex As Long
Dim varpick1, varpick2, varwcs As Variant
Dim varpick As Variant
ThisDrawing.SetVariable "ORTHOMODE", 1
With ThisDrawing.Utility
varpick1 = .GetPoint(, "Point 1 :")
varpick2 = .GetPoint(, "Point 2 :")
varpick2(0) = varpick1(0)
ReDim dblnew(0 To 3)
dblnew(0) = varpick1(0): dblnew(1) = varpick1(1)
dblnew(2) = varpick2(0): dblnew(3) = varpick2(1)
''obent = .GetEntity(,varpick,
If ThisDrawing.ActiveSpace = acModelSpace Then
Set objent = ThisDrawing.ModelSpace.AddLightWeightPolyline(dblnew)
Else
Set objent = ThisDrawing.PaperSpace.AddLightWeightPolyline(dblnew)
End If
objent.Update
''If objEnt Is Nothing Then Exit Sub
'' exit if not a lwpolyline
''/////So far everythinggoes well ////////"
'' copy last vertex of pline into pickpoint to begin loop
''/////////////////////////////////////////////////////////////////// the next line gives the error while double can be assigned to variant ????
''/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
''/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
varpick(0) = objent.Coordinates(UBound(objent.Coordinates) - 1)
varpick(1) = objent.Coordinates(UBound(objent.Coordinates))
varpick(2) = 0
'' append vertexes in a loop
Do
'' translate picked point to UCS for basepoint below
varwcs = .TranslateCoordinates(varpick, acWorld, acUCS, True)
'' get user point for new vertex, use last pick as basepoint
varpick = .GetPoint(varwcs, vbCr & "Pick another point: ")
'' exit loop if no point picked
If Err Then Exit Do
'' copy picked point X and Y into new 2d point
dblnew(0) = varpick(0): dblnew(1) = varpick(1)
'' get last vertex offset. it is one half the array size
lnglastvertex = (UBound(objent.Coordinates) + 1) / 2
'' add new vertex to pline at last offset
objent.AddVertex lnglastvertex, dblnew
Loop
End With
objent.Update
dim nbp as integer
For nbp = 0 To Val(Type_rad_form.TextBox1.Text) Step nbp + 1
MsgBox "SVP, choisir le chemin correspondant pour la tuyauterie du radiateur, " & nbp + 1 & vbNewLine & "(Uilisez un polyline)"
Dim objent As AcadLWPolyline
Dim dblnew() As Double
Dim lnglastvertex As Long
Dim varpick1, varpick2, varwcs As Variant
Dim varpick As Variant
ThisDrawing.SetVariable "ORTHOMODE", 1
With ThisDrawing.Utility
varpick1 = .GetPoint(, "Point 1 :")
varpick2 = .GetPoint(, "Point 2 :")
varpick2(0) = varpick1(0)
ReDim dblnew(0 To 3)
dblnew(0) = varpick1(0): dblnew(1) = varpick1(1)
dblnew(2) = varpick2(0): dblnew(3) = varpick2(1)
''obent = .GetEntity(,varpick,
If ThisDrawing.ActiveSpace = acModelSpace Then
Set objent = ThisDrawing.ModelSpace.AddLightWeightPolyline(dblnew)
Else
Set objent = ThisDrawing.PaperSpace.AddLightWeightPolyline(dblnew)
End If
objent.Update
''If objEnt Is Nothing Then Exit Sub
'' exit if not a lwpolyline
''/////So far everythinggoes well ////////"
'' copy last vertex of pline into pickpoint to begin loop
''/////////////////////////////////////////////////////////////////// the next line gives the error while double can be assigned to variant ????
''/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
''/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
varpick(0) = objent.Coordinates(UBound(objent.Coordinates) - 1)
varpick(1) = objent.Coordinates(UBound(objent.Coordinates))
varpick(2) = 0
'' append vertexes in a loop
Do
'' translate picked point to UCS for basepoint below
varwcs = .TranslateCoordinates(varpick, acWorld, acUCS, True)
'' get user point for new vertex, use last pick as basepoint
varpick = .GetPoint(varwcs, vbCr & "Pick another point
'' exit loop if no point picked
If Err Then Exit Do
'' copy picked point X and Y into new 2d point
dblnew(0) = varpick(0): dblnew(1) = varpick(1)
'' get last vertex offset. it is one half the array size
lnglastvertex = (UBound(objent.Coordinates) + 1) / 2
'' add new vertex to pline at last offset
objent.AddVertex lnglastvertex, dblnew
Loop
End With
objent.Update