I'm new to programming. Any thoughts as to why I getting this error? Thanks.
Just a couple of questions. First, are we talking about VBA or VB? Second, do you have a drawing open? Third, can you perhaps post the offending code? Joe
The code worked for me. Try using the <F8> to step thru your code, line by line. What line does the error occur on? -- R. Robert Bell VBA I believe because its within AutoCAD. The code I'm using is from the samples that Autodesk provides. Yes I have a drawing open. Here is the code: Sub Example_Layer() ' This example creates a new layer named "ABC" (colored red.) ' It then creates a circle and assigns it to layer "ABC" ' Create new layer Dim layerObj As AcadLayer Set layerObj = ThisDrawing.Layers.Add("ABC") layerObj.Color = acRed ' Create Circle Dim circleObj As AcadCircle Dim center(0 To 2) As Double Dim radius As Double center(0) = 3: center(1) = 3: center(2) = 0 radius = 1.5 Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius) ZoomAll MsgBox "The circle has been created on layer " & circleObj.Layer, , "Layer Example" ' Set the layer of new circle to "ABC" circleObj.Layer = "ABC" ' Refresh view ThisDrawing.Regen (True) MsgBox "The circle is now on layer " & circleObj.Layer, , "Layer Example" End Sub
Did you properly declare the aline, startpoint, and endpoint variables like the following Dim aline As AcadLine Dim StartPoint(2) As Double Dim EndPoint(2) As Double and did you initialize the StartPoint and EndPoint variables with values like the following StartPoint(0)=0:StartPoint(1)=0:StartPoint(2)=0 EndPoint(0)=1:EndPoint(1)=1:EndPoint(2)=0 This would be the coordinates to draw a line at 45 degrees from 0,0 to 1,1 Joe --
VBA I believe because its within AutoCAD. The code I'm using is from the samples that Autodesk provides. Yes I have a drawing open. Here is the code: Sub Example_Layer() ' This example creates a new layer named "ABC" (colored red.) ' It then creates a circle and assigns it to layer "ABC" ' Create new layer Dim layerObj As AcadLayer Set layerObj = ThisDrawing.Layers.Add("ABC") layerObj.Color = acRed ' Create Circle Dim circleObj As AcadCircle Dim center(0 To 2) As Double Dim radius As Double center(0) = 3: center(1) = 3: center(2) = 0 radius = 1.5 Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius) ZoomAll MsgBox "The circle has been created on layer " & circleObj.Layer, , "Layer Example" ' Set the layer of new circle to "ABC" circleObj.Layer = "ABC" ' Refresh view ThisDrawing.Regen (True) MsgBox "The circle is now on layer " & circleObj.Layer, , "Layer Example" End Sub
No bother. Happy to have "helped". -- R. Robert Bell I have re-installed AuoCAD and it works fine now. sorry for the bother.
Thanks Terry. I was just verifying that we were on the same tree. -- R. Robert Bell I've had the same error, yes in VBA. Terry