generate lines from excel data

generate lines from excel data

Anonymous
Not applicable
731 Views
7 Replies
Message 1 of 8

generate lines from excel data

Anonymous
Not applicable
i want to generate lines from excel data in autocad by directly linking excel data to autocad. may be vba will help me in this. i know that can be done by making csv file and then saving that in scr format. but i want to do it form microsoft excel data directly. CAN YOU HELP ME??
0 Likes
732 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
A line is defined by at least two points. Store the points in contiguous
rows, for example X in column B and Y in column C. Read these coordinates
from the Excel sheet, each X and Y will be used to create a point in a
variant varaible, and then use the points to create the lines.

Gilles Plante


wrote in message news:5453993@discussion.autodesk.com...
i want to generate lines from excel data in autocad by directly linking
excel data to autocad. may be vba will help me in this. i know that can be
done by making csv file and then saving that in scr format. but i want to do
it form microsoft excel data directly. CAN YOU HELP ME??
0 Likes
Message 3 of 8

Anonymous
Not applicable


Gilles,


With autocad open and vaules in excel cells a1,b1,c1
This should draw a circle.


 not sure where I got it from


 


Sub drawcircle()


Dim oAcadApp As AcadApplication


Dim oAcadDoc As AcadDocument


Dim oHatch As AcadHatch


Dim oEntArray(0 To 0) As AcadEntity


Dim dCenterPoint(0 To 2) As Double


Dim dRadius As Double


Set oAcadApp = GetObject(,
"Autocad.application")


Set oAcadDoc = oAcadApp.ActiveDocument


AppActivate oAcadApp.Caption


dCenterPoint(0) = ThisWorkbook.ActiveSheet.Cells(1,
1).Value


dCenterPoint(1) = ThisWorkbook.ActiveSheet.Cells(1,
2).Value


dCenterPoint(2) = 0#


dRadius = ThisWorkbook.ActiveSheet.Cells(1,
3).Value


Set oEntArray(0) =
oAcadDoc.ModelSpace.AddCircle(dCenterPoint, dRadius)


Set oHatch = oAcadDoc.ModelSpace.AddHatch(0, "Solid",
True)


With oHatch


.AppendOuterLoop oEntArray


End With


End Sub


 

 

john coon

 

 

A line is defined by at least two
points. Store the points in contiguous
rows, for example X in column B and Y
in column C. Read these coordinates
from the Excel sheet, each X and Y will
be used to create a point in a
variant varaible, and then use the points to
create the lines.

Gilles Plante


<subodhsapkota> wrote in
message

size=2>news:5453993@discussion.autodesk.com

size=2>...
i want to generate lines from excel data in autocad by directly
linking
excel data to autocad. may be vba will help me in this. i know that
can be
done by making csv file and then saving that in scr format. but i
want to do
it form microsoft excel data directly. CAN YOU HELP
ME??
0 Likes
Message 4 of 8

Anonymous
Not applicable

John,

 

you can draw anything you wish with values
from "outside". These values can be anything you mean they are.

 

From "Developper HELP" under Help:

 


RetVal = object.AddLine(StartPoint, EndPoint)

Object



href="mk:@MSITStore:J:\Program%20Files\AutoCAD%202007\help\acadauto.chm::/idh_modelspace_collection...
,
href="mk:@MSITStore:J:\Program%20Files\AutoCAD%202007\help\acadauto.chm::/idh_paperspace_collection...
,
href="mk:@MSITStore:J:\Program%20Files\AutoCAD%202007\help\acadauto.chm::/idh_block_object.htm">Blo...

The
object or objects this method applies to.

StartPoint


Variant (three-element array of doubles);
input-only
The 3D WCS coordinates specifying the line start point.

EndPoint


Variant (three-element array of doubles);
input-only
The 3D WCS coordinates specifying the line endpoint.

RetVal



href="mk:@MSITStore:J:\Program%20Files\AutoCAD%202007\help\acadauto.chm::/idh_line_object.htm">Line

object
The newly created Line object.


Gilles Plante



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">



Gilles,


With autocad open and vaules in excel cells
a1,b1,c1
This should draw a circle.


 not sure where I got it from


 


Sub drawcircle()


Dim oAcadApp As AcadApplication


Dim oAcadDoc As AcadDocument


Dim oHatch As AcadHatch


Dim oEntArray(0 To 0) As AcadEntity


Dim dCenterPoint(0 To 2) As Double


Dim dRadius As Double


Set oAcadApp = GetObject(,
"Autocad.application")


Set oAcadDoc = oAcadApp.ActiveDocument


AppActivate oAcadApp.Caption


dCenterPoint(0) = ThisWorkbook.ActiveSheet.Cells(1,
1).Value


dCenterPoint(1) = ThisWorkbook.ActiveSheet.Cells(1,
2).Value


dCenterPoint(2) = 0#


dRadius = ThisWorkbook.ActiveSheet.Cells(1,
3).Value


Set oEntArray(0) =
oAcadDoc.ModelSpace.AddCircle(dCenterPoint, dRadius)


Set oHatch = oAcadDoc.ModelSpace.AddHatch(0,
"Solid", True)


With oHatch


.AppendOuterLoop oEntArray


End With


End Sub


 

 

john coon

 

 

A line is defined by at least
two points. Store the points in contiguous
rows, for example X in column B
and Y in column C. Read these coordinates
from the Excel sheet, each X and
Y will be used to create a point in a
variant varaible, and then use the
points to create the lines.

Gilles
Plante


<subodhsapkota> wrote in message

href="news:5453993@discussion.autodesk.com">
size=2>news:5453993@discussion.autodesk.com

size=2>...
i want to generate lines from excel data in autocad by directly
linking
excel data to autocad. may be vba will help me in this. i know
that can be
done by making csv file and then saving that in scr format.
but i want to do
it form microsoft excel data directly. CAN YOU HELP
ME??
0 Likes
Message 5 of 8

Anonymous
Not applicable

Gilles,

 

Thanks for the info, I guess I clicked on the work
post. the data was for subodhsapkota.

 

I have been looking for ways to draw complete
drawings or at least details with excel but have yet to find very many samples
other than like the one I supplied.

I need to find better or more complete sample to be
able to see how I can change my of my existing routines and offer them in
excel.

 

I've created a lot of routines that run directly in
AutoCAD but I think offering some of these tools driven from excel would
add a lot of power and might open my eyes to newer ways of generating
drawing content.

 

Have a great day.

 

John

 



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

John,

 

you can draw anything you wish with values
from "outside". These values can be anything you mean they are.

 

From "Developper HELP" under Help:

 


RetVal = object.AddLine(StartPoint, EndPoint)

Object



href="mk:@MSITStore:J:\Program%20Files\AutoCAD%202007\help\acadauto.chm::/idh_modelspace_collecti...
,
href="mk:@MSITStore:J:\Program%20Files\AutoCAD%202007\help\acadauto.chm::/idh_paperspace_collecti...
,
href="mk:@MSITStore:J:\Program%20Files\AutoCAD%202007\help\acadauto.chm::/idh_block_object.htm">B...

The
object or objects this method applies to.

StartPoint


Variant (three-element array of doubles);
input-only
The 3D WCS coordinates specifying the line start point.

EndPoint


Variant (three-element array of doubles);
input-only
The 3D WCS coordinates specifying the line endpoint.

RetVal



href="mk:@MSITStore:J:\Program%20Files\AutoCAD%202007\help\acadauto.chm::/idh_line_object.htm">Li...

object
The newly created Line object.


Gilles Plante



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">



Gilles,


With autocad open and vaules in excel cells
a1,b1,c1
This should draw a
circle.


 not sure where I got it from


 


Sub drawcircle()


Dim oAcadApp As AcadApplication


Dim oAcadDoc As AcadDocument


Dim oHatch As AcadHatch


Dim oEntArray(0 To 0) As AcadEntity


Dim dCenterPoint(0 To 2) As Double


Dim dRadius As Double


Set oAcadApp = GetObject(,
"Autocad.application")


Set oAcadDoc = oAcadApp.ActiveDocument


AppActivate oAcadApp.Caption


dCenterPoint(0) =
ThisWorkbook.ActiveSheet.Cells(1, 1).Value


dCenterPoint(1) =
ThisWorkbook.ActiveSheet.Cells(1, 2).Value


dCenterPoint(2) = 0#


dRadius = ThisWorkbook.ActiveSheet.Cells(1,
3).Value


Set oEntArray(0) =
oAcadDoc.ModelSpace.AddCircle(dCenterPoint, dRadius)


Set oHatch = oAcadDoc.ModelSpace.AddHatch(0,
"Solid", True)


With oHatch


.AppendOuterLoop oEntArray


End With


End Sub


 

 

john coon

 

 

A line is defined by at least
two points. Store the points in contiguous
rows, for example X in column
B and Y in column C. Read these coordinates
from the Excel sheet, each X
and Y will be used to create a point in a
variant varaible, and then use
the points to create the lines.

Gilles
Plante


<subodhsapkota> wrote in message

href="news:5453993@discussion.autodesk.com">
size=2>news:5453993@discussion.autodesk.com

size=2>...
i want to generate lines from excel data in autocad by
directly linking
excel data to autocad. may be vba will help me in this.
i know that can be
done by making csv file and then saving that in scr
format. but i want to do
it form microsoft excel data directly. CAN YOU
HELP ME??
0 Likes
Message 6 of 8

Anonymous
Not applicable
You can add Microsoft Office Spreadsheet control into VBA editor.
and use that control to running excel spreadsheet.
0 Likes
Message 7 of 8

Anonymous
Not applicable
I can give this VBA macro to you, leave your e-mail address here.
0 Likes
Message 8 of 8

Anonymous
Not applicable
Here is an simple example how it
must be to do
A2005, MS Excel 2003
Change references to AutoCAD library
by your current version

Open AutoCAD then minimize its window
but do not close it
Open this Excel file, then select region
all the 4 columns but without headers
and hit "Draw Lines" button

Hth

~'J'~
0 Likes