How do I get area information into my database?

How do I get area information into my database?

Anonymous
Not applicable
406 Views
7 Replies
Message 1 of 8

How do I get area information into my database?

Anonymous
Not applicable
I am creating a link between a drawing and database. Is it possible feed area data from a polyline automatically in to the database when linking the polyline to the data base.
0 Likes
407 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
yes as long as you have the handle of the polyline
you can link a variable, polMyPolyline, to the object. example

 

Dim polMyPolyline As AcadPolyLine, str As
String

 

set polMyPolyLine =
thisdrawing.HandleToObbject('Hanlde here')

 

'use a string to store the information it may be to
large for an integer and takes less memory than a long

 

str = polMyPolyLine.Area


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
am creating a link between a drawing and database. Is it possible feed area
data from a polyline automatically in to the database when linking the
polyline to the data base.
0 Likes
Message 3 of 8

Anonymous
Not applicable
Thanks for your response.

Could you go into to more detail of how to do this, I haven't used VBA before?
0 Likes
Message 4 of 8

Anonymous
Not applicable
First link your DBase I assume its Access so set
your references to use ADO, Microsoft ADO...". Dim a string Variable to link
your DBase with.

 

'Place this UNDER Option Explicit at the beginning
of your code.

Public Const strYourString As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\YourDBase.mdb"

 

"Private Function" OR "Public Sub" 'you choose'
modGetArea()

'this is an example of your code for the DBase
access

Dim polMyPolyline As AcadPolyLine, strMyString As
String

Dim strDBaseHandle As String, cnnConnection As New
ADODB.Connection

Dim rstMyRecordset As New
ADODB.Recordset

Dim strHandle As String

 

cnnConnection.Open strYourString


size=2>     rstMyRecordset.CursorLocation =
adUseClient
     rstMyRecordset.CursorType =
adOpenKeyset
     rstMyRecordset.LockType =
adLockOptimistic

'tblYour is the name of the table containing the
Handle for the Polyline and the Area of the
Polyline
     rstMyRecordset.Open "'tblYour ", cnn,
adOpenDynamic

 

Do While Not rstMyRecordset.EOF

    strHandle = rstMyRecordset!Handle

'Handle is the name of the field in the Table where the objects handle
is stored.

    

    set polMyPolyLine =
thisdrawing.HandleToObbject(strHandle)

 

    strMyString =
polMyPolyLine.Area

 

    rstMyRecordset!Area = strMyString

   'If you are using the Field AREA as a number in your
database then you need to use this

    'rstMyRecordset!Area = Val(strMyString) OR
USE rstMyRecordset!Area = CInt(strMyString)

    ' I recommend the first one.

Loop

 

End "Function OR Sub"

 

This will help you on your way.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Thanks
for your response.

Could you go into to more detail of how to do this, I haven't used VBA
before?

0 Likes
Message 5 of 8

Anonymous
Not applicable
Thank you

I'll have a go with this.
0 Likes
Message 6 of 8

Anonymous
Not applicable
I'm sorry, I can't get this to work. Do I have to do this in Access or AutoCAD?
0 Likes
Message 7 of 8

Anonymous
Not applicable
within ACAD. make sure that the string for your
public const is read as a single line. other than that I can't see where there
should be any problems. what errors are you getting.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I'm
sorry, I can't get this to work. Do I have to do this in Access or
AutoCAD?
0 Likes
Message 8 of 8

Anonymous
Not applicable
I'm not getting any errors, I guess I just don't know how to go about this.
0 Likes