line creation under VBA

Hi, I am having trouble with plotting points that are stored down as variants to create a 'line'. I get a type mismatch. What I have done is resorting to using a 'polyline' command to try and avoid the variant. Polyline using doubles stored down as an array.I anyone could post some example code that will create a line that would be great,cheers - Darren

Comments

  • Below some code that creates both a line and a polyline. Start in the 'main' routine to create both some lines and a closed polyine. IntelliCAD uses a true object model, and therefore points etc. are defined as objects, and not as arrays of variants or doubles. I created this code in the ThisDocument object of IntelleCAD's VBA interface; be sure to paste in there to run the code. You could also replace the 'me' keyword in the code below by another 'IntelliCAD.Document' object.Public Sub main() AddLines AddPolyline Me.ActiveViewport.ZoomExtentsEnd SubPrivate Sub AddLines() Dim pt1 As IntelliCAD.Point Dim pt2 As IntelliCAD.Point Dim pt3 As IntelliCAD.Point Set pt1 = Me.Application.Library.CreatePoint(0, 0, 0) Set pt2 = Me.Application.Library.CreatePoint(5, 5, 0) Set pt3 = Me.Application.Library.CreatePoint(0, 5, 0) Me.ModelSpace.AddLine pt1, pt2 Me.ModelSpace.AddLine pt2, pt3 Me.ModelSpace.AddLine pt3, pt1 Set pt1 = Nothing Set pt2 = Nothing Set pt3 = NothingEnd SubPrivate Sub AddPolyline() Dim pts As Points Dim Pl As IntelliCAD.Polyline Set pts = Me.Application.Library.CreatePoints pts.Add 5, 0, 0 pts.Add 5, 5, 0 pts.Add 0, 5, 0 Set Pl = Me.ModelSpace.AddPolyline(pts) Pl.Color = vicRed Pl.Closed = True Pl.Update Set pts = Nothing Set Pl = NothingEnd Sub

This discussion has been closed.